diff options
author | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-07-02 16:42:43 +0200 |
---|---|---|
committer | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-07-02 16:42:43 +0200 |
commit | 4b6ce58f339d69c70ef746ceecae78bf7ed0f0ba (patch) | |
tree | 7708c40ffdc7e29aa784ee5d26308f18aa1f460b /src/test/java/at/gv/egiz | |
parent | 030488bb7ff9572f35032d80d4101c06cfc98bf5 (diff) | |
download | moa-zs-4b6ce58f339d69c70ef746ceecae78bf7ed0f0ba.tar.gz moa-zs-4b6ce58f339d69c70ef746ceecae78bf7ed0f0ba.tar.bz2 moa-zs-4b6ce58f339d69c70ef746ceecae78bf7ed0f0ba.zip |
Handle tnvz Query Edge Cases by Improving Validation
TnvzHelper Fixes
- Handle additional edge cases.
- Mzs:Schema Change: Eliminate PreAdviceNote redundancy by removing it
from mzs:DeliveryRequest/TnvzMetaData; PreadviceNote is already in
the Receiver element. Update TnvzHelper accordingly.
- Implement and integrate tnvz completeness check into
DeliveryRequestAugmenter to ensure that, after augmentation, tnvz
can be performed.
Refactor mzs:DeliveryRequest Validation:
- Before: Validating, merging and generatig ConfigType in ConfigUtil.
- Change: Need to add validation of DeliveryRequest (Reason: For
performing Tnvz Requests, the DeliveryRequest needs to be in a
consistent state).
- Problem: DeliveryRequest validation does not fit into ConfigUtil.
- Solution: Put validation of DeliveryRequest and Config into new
Component "MzsValidation".
Diffstat (limited to 'src/test/java/at/gv/egiz')
-rw-r--r-- | src/test/java/at/gv/egiz/moazs/ConfigProfileGeneratorTest.java | 11 | ||||
-rw-r--r-- | src/test/java/at/gv/egiz/moazs/DeliveryRequestAugmenterTest.java | 12 |
2 files changed, 16 insertions, 7 deletions
diff --git a/src/test/java/at/gv/egiz/moazs/ConfigProfileGeneratorTest.java b/src/test/java/at/gv/egiz/moazs/ConfigProfileGeneratorTest.java index 95cccd1..3157447 100644 --- a/src/test/java/at/gv/egiz/moazs/ConfigProfileGeneratorTest.java +++ b/src/test/java/at/gv/egiz/moazs/ConfigProfileGeneratorTest.java @@ -1,5 +1,6 @@ package at.gv.egiz.moazs; +import at.gv.egiz.moazs.mzs.MzsValidator; import at.gv.egiz.moazs.preprocess.*; import org.junit.Test; import org.junit.runner.RunWith; @@ -24,6 +25,9 @@ public class ConfigProfileGeneratorTest { private ConfigUtil util; @Mock + private MzsValidator validator; + + @Mock private SpringPropertiesFacade properties; @Test @@ -87,7 +91,7 @@ public class ConfigProfileGeneratorTest { public void cancelAtIncompleteDefaultProfile() { var propMap = Map.of(PREFIX + "." + DEFAULT + ".property-a", "value-a"); var generator = setupMocksAndBuilder(propMap).build(); - when(util.isComplete(any())).thenReturn(false); + when(validator.isConfigProfileComplete(any())).thenReturn(false); generator.generate(); } @@ -96,7 +100,7 @@ public class ConfigProfileGeneratorTest { public void continueAtIncompleteDefaultWhenVerificationDisabled() { var propMap = Map.of(PREFIX + "." + DEFAULT + ".property-a", "value-a"); - when(util.isComplete(any())).thenReturn(false); + when(validator.isConfigProfileComplete(any())).thenReturn(false); var generator = setupMocksAndBuilder(propMap) .withVerifyCompletenessOfDefaultConfiguration(false) @@ -112,14 +116,15 @@ public class ConfigProfileGeneratorTest { when(properties.getPropertyNames()).thenReturn(propMap.keySet().stream()); when(properties.getProperty(any())).thenAnswer(i -> propMap.get(i.getArgument(0))); when(util.merge(any(), any())).thenAnswer(i -> i.getArgument(0)); - when(util.isComplete(any())).thenReturn(true); when(util.convert(any())).thenReturn(configTypeBuilder().build()); + when(validator.isConfigProfileComplete(any())).thenReturn(true); return configProfileGeneratorBuilder() .withProperties(properties) .withConfigUtil(util) .withDefaultConfigKey(DEFAULT) .withProfilePrefix(PREFIX) + .withValidator(validator) .withVerifyCompletenessOfDefaultConfiguration(true); } diff --git a/src/test/java/at/gv/egiz/moazs/DeliveryRequestAugmenterTest.java b/src/test/java/at/gv/egiz/moazs/DeliveryRequestAugmenterTest.java index 4bd64ef..424dce1 100644 --- a/src/test/java/at/gv/egiz/moazs/DeliveryRequestAugmenterTest.java +++ b/src/test/java/at/gv/egiz/moazs/DeliveryRequestAugmenterTest.java @@ -1,5 +1,6 @@ package at.gv.egiz.moazs; +import at.gv.egiz.moazs.mzs.MzsValidator; import at.gv.egiz.moazs.preprocess.ConfigUtil; import at.gv.egiz.moazs.preprocess.DeliveryRequestAugmenter; import at.gv.zustellung.app2mzs.xsd.ConfigType; @@ -8,7 +9,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import java.util.Map; @@ -28,9 +28,13 @@ public class DeliveryRequestAugmenterTest { @Mock private ConfigUtil configUtil; + @Mock + private MzsValidator validator; + @Before public void setupMock() { - when(configUtil.isComplete(Mockito.any())).thenReturn(true); + when(validator.isConfigProfileComplete(any())).thenReturn(true); + when(validator.isTnvzComplete(any())).thenReturn(true); when(configUtil.merge(any(), any())).thenCallRealMethod(); } @@ -105,11 +109,11 @@ public class DeliveryRequestAugmenterTest { } private DeliveryRequestAugmenter createAugmenter(ConfigType fallback) { - return new DeliveryRequestAugmenter(Map.of("default", fallback), configUtil); + return new DeliveryRequestAugmenter(Map.of("default", fallback), configUtil, validator); } private DeliveryRequestAugmenter createAugmenter(Map<String, ConfigType> profiles) { - return new DeliveryRequestAugmenter(profiles, configUtil); + return new DeliveryRequestAugmenter(profiles, configUtil, validator); } private ConfigType createConfig(String url, Boolean performTnvz) { |