Skip to content

Commit

Permalink
Replace the Assert with Assume API in Junit 5, also adding the orElse…
Browse files Browse the repository at this point in the history
…(null) to avoid the issue that the key does not present.
  • Loading branch information
Codegass committed Mar 18, 2024
1 parent 6654803 commit 7547fde
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.spy;
Expand Down Expand Up @@ -76,9 +77,11 @@ public void validatePropertyUpdates() {
config.addConfig(Layers.APPLICATION, child);

// Validate initial state
assertEquals("propvalue", config.getProperty("propname").get());
assertEquals("propvalue", config.getRawProperty("propname"));

assumeTrue("propvalue".equals(config.getProperty("propname").orElse(null)),
"Property 'propname' does not have the expected value 'propvalue', test assumptions not met.");
assumeTrue("propvalue".equals(config.getRawProperty("propname")),
"Raw property 'propname' does not have the expected value 'propvalue', test assumptions not met.");

// Update the property value
child.setProperty("propname", "propvalue2");

Expand All @@ -103,8 +106,10 @@ public void validateApiWhenRemovingChild() {
Mockito.verify(listener, Mockito.times(1)).onConfigUpdated(any());

// Validate initial state
assertEquals("propvalue", config.getProperty("propname").get());
assertEquals("propvalue", config.getRawProperty("propname"));
assumeTrue("propvalue".equals(config.getProperty("propname").orElse(null)),
"Property 'propname' does not have the expected value 'propvalue', test assumptions not met.");
assumeTrue("propvalue".equals(config.getRawProperty("propname")),
"Raw property 'propname' does not have the expected value 'propvalue', test assumptions not met.");

// Remove the child
config.removeConfig(Layers.APPLICATION, child.getName());
Expand Down

0 comments on commit 7547fde

Please sign in to comment.