Skip to content

Commit

Permalink
Merge pull request #715 from Codegass/refactoring-PropertyTest
Browse files Browse the repository at this point in the history
Split the PropertyTest.test into `testPropertyValuesUpdateAndEffect` and `testServiceInitializationWithDefaultProperties`
  • Loading branch information
rgallardo-netflix authored Mar 26, 2024
2 parents 084a29d + 9e3ffae commit 25fccb7
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,32 @@ public String toString() {
}

@Test
public void test() throws ConfigException {
public void testServiceInitializationWithDefaultProperties() {
SettableConfig config = new DefaultSettableConfig();
DefaultPropertyFactory factory = DefaultPropertyFactory.from(config);

MyService service = new MyService(factory);

assertEquals(1, (int)service.value.get());
assertEquals(2, (int)service.value2.get());
// Verify initial property values
assertEquals(1, (int) service.value.get());
assertEquals(2, (int) service.value2.get());
// Verify setValue() was called once for each initialization
assertEquals(0, service.setValueCallsCounter.get());
}

@Test
public void testPropertyValuesUpdateAndEffect() {
SettableConfig config = new DefaultSettableConfig();
DefaultPropertyFactory factory = DefaultPropertyFactory.from(config);
MyService service = new MyService(factory);

// Setting up properties
config.setProperty("foo", "123");

// Assertions after properties update
assertEquals(123, (int)service.value.get());
assertEquals(123, (int)service.value2.get());
// setValue() is called once when we init to 1 and twice when we set foo to 123.
// setValue() is called once for each property update
assertEquals(1, service.setValueCallsCounter.get());
}

Expand Down

0 comments on commit 25fccb7

Please sign in to comment.