diff options
author | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-04-18 14:52:34 +0200 |
---|---|---|
committer | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-04-18 14:52:34 +0200 |
commit | 91e6adb606382f10985777d225e4f62f0b624ceb (patch) | |
tree | b14cd7037097f82451a929e00da71c161ad2dde9 | |
parent | aed1250912476f47fd772b0cedd20c850cdcff6e (diff) | |
download | moa-zs-91e6adb606382f10985777d225e4f62f0b624ceb.tar.gz moa-zs-91e6adb606382f10985777d225e4f62f0b624ceb.tar.bz2 moa-zs-91e6adb606382f10985777d225e4f62f0b624ceb.zip |
Mock Pipeline in App2MzsServiceTests
- Reason: App2MzsServiceTests only run through the app2mzs front end
without doing any pipeline work.
-rw-r--r-- | src/main/java/at/gv/egiz/moazs/pipeline/SameThreadDeliveryPipeline.java | 13 | ||||
-rw-r--r-- | src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java | 31 |
2 files changed, 31 insertions, 13 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/pipeline/SameThreadDeliveryPipeline.java b/src/main/java/at/gv/egiz/moazs/pipeline/SameThreadDeliveryPipeline.java index 3652662..20252ff 100644 --- a/src/main/java/at/gv/egiz/moazs/pipeline/SameThreadDeliveryPipeline.java +++ b/src/main/java/at/gv/egiz/moazs/pipeline/SameThreadDeliveryPipeline.java @@ -1,8 +1,6 @@ package at.gv.egiz.moazs.pipeline; -import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.DeliveryRequestStatusType; -import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.ObjectFactory; import at.gv.e_government.reference.namespace.zustellung.mzs.app2mzs_.DeliveryRequestType; import at.gv.egiz.moazs.repository.DeliveryRepository; import org.springframework.beans.factory.annotation.Autowired; @@ -32,18 +30,9 @@ public class SameThreadDeliveryPipeline implements DeliveryPipeline { "Request with appDeliveryId = {} does not exist.", appDeliveryId)); } - //do some logic. + //do business logic //store response to repository - repository.add(generateBogusStatus(appDeliveryId)); } - private DeliveryRequestStatusType generateBogusStatus(String appDeliveryId) { - final var factory = new ObjectFactory(); - final var status = factory.createDeliveryRequestStatusType(); - final var success = factory.createDeliveryRequestStatusTypeSuccess(); - success.setAppDeliveryID(appDeliveryId); - status.setSuccess(success); - return status; - } } diff --git a/src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java b/src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java index 78dafdc..01b7745 100644 --- a/src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java +++ b/src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java @@ -1,11 +1,18 @@ package at.gv.egiz.moazs; +import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.ObjectFactory; +import at.gv.egiz.moazs.pipeline.DeliveryPipeline; +import at.gv.egiz.moazs.repository.DeliveryRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Primary; import org.springframework.test.context.junit4.SpringRunner; import java.io.IOException; @@ -27,7 +34,29 @@ public class App2MzsServiceTest { private final String basePath = "src/test/resources/at/gv/egiz/moazs/App2MzsServiceTest/"; - Logger logger = LoggerFactory.getLogger(App2MzsServiceTest.class); + private final static Logger logger = LoggerFactory.getLogger(App2MzsServiceTest.class); + + @TestConfiguration + public static class TestConfig { + + @Autowired + private DeliveryRepository repository; + + private final ObjectFactory factory = new ObjectFactory(); + + @Bean + @Primary + public DeliveryPipeline deliveryPipelineThatAlwaysSucceeds() { + return appDeliveryId -> { + var status = factory.createDeliveryRequestStatusType(); + var success = factory.createDeliveryRequestStatusTypeSuccess(); + success.setAppDeliveryID(appDeliveryId); + status.setSuccess(success); + repository.add(status); + }; + } + } + @Test public void acceptValidDeliveryRequest() throws IOException, InterruptedException { |