From 9e3ffae4d1121ccb2c3c3eabe8d42dbf0c4c10e1 Mon Sep 17 00:00:00 2001 From: CodegassW Date: Mon, 18 Mar 2024 04:08:23 -0400 Subject: [PATCH] Split the PropertyTest.test into testPropertyValuesUpdateAndEffect and testServiceInitializationWithDefaultProperties --- .../archaius/property/PropertyTest.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/archaius2-core/src/test/java/com/netflix/archaius/property/PropertyTest.java b/archaius2-core/src/test/java/com/netflix/archaius/property/PropertyTest.java index 9b453b91..65bd6ebe 100644 --- a/archaius2-core/src/test/java/com/netflix/archaius/property/PropertyTest.java +++ b/archaius2-core/src/test/java/com/netflix/archaius/property/PropertyTest.java @@ -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()); }