diff options
Diffstat (limited to 'src/test/java/at')
-rw-r--r-- | src/test/java/at/gv/egiz/moazs/DeliveryRequestAugmenterTest.java | 80 | ||||
-rw-r--r-- | src/test/java/at/gv/egiz/moazs/SameThreadDeliveryPipelineTest.java | 3 |
2 files changed, 82 insertions, 1 deletions
diff --git a/src/test/java/at/gv/egiz/moazs/DeliveryRequestAugmenterTest.java b/src/test/java/at/gv/egiz/moazs/DeliveryRequestAugmenterTest.java new file mode 100644 index 0000000..a98da74 --- /dev/null +++ b/src/test/java/at/gv/egiz/moazs/DeliveryRequestAugmenterTest.java @@ -0,0 +1,80 @@ +package at.gv.egiz.moazs; + +import at.gv.zustellung.app2mzs.xsd.ConfigType; +import at.gv.zustellung.app2mzs.xsd.DeliveryRequestType; +import org.junit.Test; + +import static at.gv.zustellung.app2mzs.xsd.ConfigType.configTypeBuilder; +import static at.gv.zustellung.app2mzs.xsd.DeliveryRequestType.deliveryRequestTypeBuilder; +import static at.gv.zustellung.app2mzs.xsd.ServerType.serverTypeBuilder; +import static org.assertj.core.api.Assertions.assertThat; + +public class DeliveryRequestAugmenterTest { + + private final String msgUrl = "http://mzs"; + + @Test + public void augmentPrimaryWithoutConfig() { + var fallback = createConfig(msgUrl, false); + var augmenter = new DeliveryRequestAugmenter(fallback); + + var actual = augmenter.augment(createRequest(null)).getConfig(); + + assertThat(actual).isEqualToComparingFieldByFieldRecursively(fallback); + } + + @Test + public void augmentPrimaryWithEmptyConfig() { + var fallback = createConfig(msgUrl, false); + var augmenter = new DeliveryRequestAugmenter(fallback); + var primary = createConfig(null, null); + + var actual = augmenter.augment(createRequest(primary)).getConfig(); + + assertThat(actual).isEqualToComparingFieldByFieldRecursively(fallback); + } + + @Test + public void overrideFallbacksUrlWithPrimary() { + var fallback = createConfig("http://fallback.url", false); + var primary = createConfig("http://primary.url", null); + var augmenter = new DeliveryRequestAugmenter(fallback); + + var actual = augmenter.augment(createRequest(primary)).getConfig(); + + var expected = createConfig("http://primary.url", false); + assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); + } + + @Test + public void overrideFallbacksTvnzQueryWithPrimary() { + var fallback = createConfig(msgUrl, false); + var primary = createConfig(null, true); + var augmenter = new DeliveryRequestAugmenter(fallback); + + var actual = augmenter.augment(createRequest(primary)).getConfig(); + + var expected = createConfig(msgUrl, true); + assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); + } + + private ConfigType createConfig(String url, Boolean performTnvz) { + + var server = serverTypeBuilder() + .withZUSEUrlID(url) + .build(); + + return configTypeBuilder() + .withServer(server) + .withPerformQueryPersonRequest(performTnvz) + .build(); + } + + private DeliveryRequestType createRequest(ConfigType config) { + + return deliveryRequestTypeBuilder() + .withConfig(config) + .build(); + } + +} diff --git a/src/test/java/at/gv/egiz/moazs/SameThreadDeliveryPipelineTest.java b/src/test/java/at/gv/egiz/moazs/SameThreadDeliveryPipelineTest.java index f394a63..9ee3ceb 100644 --- a/src/test/java/at/gv/egiz/moazs/SameThreadDeliveryPipelineTest.java +++ b/src/test/java/at/gv/egiz/moazs/SameThreadDeliveryPipelineTest.java @@ -1,5 +1,6 @@ package at.gv.egiz.moazs; +import at.gv.egiz.moazs.msg.MsgClient; import at.gv.egiz.moazs.pipeline.DeliveryPipeline; import at.gv.egiz.moazs.pipeline.SameThreadDeliveryPipeline; import at.gv.egiz.moazs.repository.DeliveryRepository; @@ -128,7 +129,7 @@ public class SameThreadDeliveryPipelineTest { when(tnvzClient.queryPerson(any(), any())).thenReturn(setupTnvzSuccess(acceptedTypes)); when(converter.convert(eq(mzsRequest) )).thenReturn(msgRequest); when(converter.convert(eq(mzsRequest), any())).thenReturn(msgRequest); - when(msgClient.send(msgRequest)).thenReturn(status); + when(msgClient.send(msgRequest, mzsRequest.getConfig())).thenReturn(status); return status; |