From 91e6adb606382f10985777d225e4f62f0b624ceb Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Thu, 18 Apr 2019 14:52:34 +0200 Subject: Mock Pipeline in App2MzsServiceTests - Reason: App2MzsServiceTests only run through the app2mzs front end without doing any pipeline work. --- .../java/at/gv/egiz/moazs/App2MzsServiceTest.java | 31 +++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'src/test') 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 { -- cgit v1.2.3