Skip to content

Commit

Permalink
Merge pull request #713 from Codegass/refactoring-assume
Browse files Browse the repository at this point in the history
Enhancing Clarity with assume API in Precondition Checks for `validatePropertyUpdates` and `validateApiWhenRemovingChild`
  • Loading branch information
rgallardo-netflix authored Mar 26, 2024
2 parents 6654803 + 7547fde commit 55a05d6
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 55a05d6

Please sign in to comment.