From a5b8668c0c7916a8fe2b84122d537a3e0bd67002 Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Fri, 29 Nov 2019 14:54:28 +0100 Subject: Alter Case Handling "Get Notification where AppDeliveryID is unknown" - Former: Fail with Exception. - Now: Issue a warning and fall back to default configuration profile after verifying that sinks in default configuration profile are correctly configured. - Refactor: Make DEFAULT_CONFIG_KEY static. --- .../gv/egiz/moazs/ConfigProfileGeneratorTest.java | 25 +++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src/test/java/at/gv/egiz') diff --git a/src/test/java/at/gv/egiz/moazs/ConfigProfileGeneratorTest.java b/src/test/java/at/gv/egiz/moazs/ConfigProfileGeneratorTest.java index 10670ff..1fec8ec 100644 --- a/src/test/java/at/gv/egiz/moazs/ConfigProfileGeneratorTest.java +++ b/src/test/java/at/gv/egiz/moazs/ConfigProfileGeneratorTest.java @@ -32,6 +32,7 @@ import org.mockito.junit.MockitoJUnitRunner; import java.util.Map; import static at.gv.egiz.moazs.MoaZSException.moaZSException; +import static at.gv.egiz.moazs.preprocess.ConfigProfileGenerator.DEFAULT_CONFIG_KEY; import static at.gv.egiz.moazs.preprocess.ConfigProfileGenerator.configProfileGeneratorBuilder; import static at.gv.zustellung.app2mzs.xsd.ConfigType.configTypeBuilder; import static org.mockito.ArgumentMatchers.any; @@ -46,7 +47,6 @@ import static org.mockito.Mockito.*; public class ConfigProfileGeneratorTest { private static final String PREFIX = "prefix"; - private static final String DEFAULT = "default"; @Mock private ConfigUtil util; @@ -60,9 +60,9 @@ public class ConfigProfileGeneratorTest { @Test public void assembleDefaultProfile() { var propMap = Map.of( - PREFIX + "." + DEFAULT + ".property-a", "value-a", - PREFIX + "." + DEFAULT + ".property-b", "value-b", - PREFIX + "." + DEFAULT + ".property-c", "value-c"); + PREFIX + "." + DEFAULT_CONFIG_KEY + ".property-a", "value-a", + PREFIX + "." + DEFAULT_CONFIG_KEY + ".property-b", "value-b", + PREFIX + "." + DEFAULT_CONFIG_KEY + ".property-c", "value-c"); var generator = setupMocksAndBuilder(propMap).build(); var profiles = generator.generate(); @@ -71,12 +71,12 @@ public class ConfigProfileGeneratorTest { "property-a", "value-a", "property-b", "value-b", "property-c", "value-c")); - assertThat(profiles.keySet()).containsExactlyInAnyOrder(DEFAULT); + assertThat(profiles.keySet()).containsExactlyInAnyOrder(DEFAULT_CONFIG_KEY); } @Test public void assembleEmptyDefault() { - var propMap = Map.of(PREFIX + "." + DEFAULT, ""); + var propMap = Map.of(PREFIX + "." + DEFAULT_CONFIG_KEY, ""); var generator = setupMocksAndBuilder(propMap).build(); var profiles = generator.generate(); @@ -99,8 +99,8 @@ public class ConfigProfileGeneratorTest { @Test public void assembleMultipleProfiles() { var propMap = Map.of( - PREFIX + "." + DEFAULT+ ".property-a", "value-a", - PREFIX + "." + DEFAULT+ ".property-b", "value-b", + PREFIX + "." + DEFAULT_CONFIG_KEY + ".property-a", "value-a", + PREFIX + "." + DEFAULT_CONFIG_KEY + ".property-b", "value-b", PREFIX + "." + "profile-1.property-c", "value-c", PREFIX + "." + "profile-2.property-d", "value-d"); @@ -111,12 +111,12 @@ public class ConfigProfileGeneratorTest { verify(util).convert(Map.of("property-a", "value-a", "property-b", "value-b")); verify(util).convert(Map.of("property-c", "value-c")); verify(util).convert(Map.of("property-d", "value-d")); - assertThat(profiles.keySet()).containsExactlyInAnyOrder(DEFAULT, "profile-1", "profile-2"); + assertThat(profiles.keySet()).containsExactlyInAnyOrder(DEFAULT_CONFIG_KEY, "profile-1", "profile-2"); } @Test(expected = MoaZSException.class) public void cancelAtIncompleteDefaultProfile() { - var propMap = Map.of(PREFIX + "." + DEFAULT + ".property-a", "value-a"); + var propMap = Map.of(PREFIX + "." + DEFAULT_CONFIG_KEY + ".property-a", "value-a"); var generator = setupMocksAndBuilder(propMap).build(); doThrow(moaZSException("Not Complete.")).when(validator).isConfigProfileComplete(any()); @@ -125,7 +125,7 @@ public class ConfigProfileGeneratorTest { @Test public void continueAtIncompleteDefaultWhenVerificationDisabled() { - var propMap = Map.of(PREFIX + "." + DEFAULT + ".property-a", "value-a"); + var propMap = Map.of(PREFIX + "." + DEFAULT_CONFIG_KEY + ".property-a", "value-a"); doThrow(moaZSException("Not Complete.")).when(validator).isConfigProfileComplete(any()); @@ -136,7 +136,7 @@ public class ConfigProfileGeneratorTest { var profiles = generator.generate(); verify(util).convert(Map.of("property-a", "value-a")); - assertThat(profiles.keySet()).containsExactlyInAnyOrder(DEFAULT); + assertThat(profiles.keySet()).containsExactlyInAnyOrder(DEFAULT_CONFIG_KEY); } private ConfigProfileGenerator.ConfigProfileGeneratorBuilder setupMocksAndBuilder(Map propMap) { @@ -148,7 +148,6 @@ public class ConfigProfileGeneratorTest { return configProfileGeneratorBuilder() .withProperties(properties) .withConfigUtil(util) - .withDefaultConfigKey(DEFAULT) .withProfilePrefix(PREFIX) .withValidator(validator) .withVerifyCompletenessOfDefaultConfiguration(true); -- cgit v1.2.3