aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/at
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-05-08 09:41:37 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-05-08 09:41:37 +0200
commit1aaec2e6127b9b2261a97749daa15c23f0af7be1 (patch)
tree1f52ca9d17ae9ff7853a7fbbafa3c179ec022081 /src/test/java/at
parentfefde1ad7592412007b9efed2b62cb403d3f6cac (diff)
downloadmoa-zs-1aaec2e6127b9b2261a97749daa15c23f0af7be1.tar.gz
moa-zs-1aaec2e6127b9b2261a97749daa15c23f0af7be1.tar.bz2
moa-zs-1aaec2e6127b9b2261a97749daa15c23f0af7be1.zip
Implement Pipeline Flow and mzs2msg Conversion
- Implement and test conversion from mzs:DeliveryRequest to msg:DeliveryRequest with the "convert-pojos-by-hand"-strategy. Reason: The chosen strategy benefits from JAXB's strong typing, which is useful in this scenario: Differences between msg and mzs are nuanced and easy to overlook. The chosen strategy is, unfortunately, verbose and could become expensive to maintain. - Update SameThreadDeliveryPipeline: Integrate tnvz query, conversion, and msg query. - Add MsgClient stub. tnvz: - Change TnvzClient stub interface. - Implement mimetype mismatch check from tnvz Response. - Put p:Identification from tnvz response into msg:DeliveryRequest. MZS Schema changes: - Replace DeliveryRequest/Sender/Person with CorporateBody (because thats the only sender that is allowed by zusemsg) and add a SenderProfile choice. - Add ID Attribute to DeliveryRequest/Sender because msg/DeliveryRequest/Sender/AbstractSenderPersonType also has an id attribute. - Remove PersonDataType because it's dead code.
Diffstat (limited to 'src/test/java/at')
-rw-r--r--src/test/java/at/gv/egiz/moazs/Mzs2MsgConverterTest.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/test/java/at/gv/egiz/moazs/Mzs2MsgConverterTest.java b/src/test/java/at/gv/egiz/moazs/Mzs2MsgConverterTest.java
new file mode 100644
index 0000000..0c092aa
--- /dev/null
+++ b/src/test/java/at/gv/egiz/moazs/Mzs2MsgConverterTest.java
@@ -0,0 +1,67 @@
+package at.gv.egiz.moazs;
+
+import at.gv.zustellung.app2mzs.xsd.DeliveryRequestType;
+import at.gv.zustellung.msg.xsd.ObjectFactory;
+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.test.context.junit4.SpringRunner;
+
+import javax.xml.bind.JAXBElement;
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class Mzs2MsgConverterTest {
+
+ private final String basePath = "src/test/resources/at/gv/egiz/moazs/Mzs2MsgConverterTest/";
+
+ private final static Logger logger = LoggerFactory.getLogger(Mzs2MsgConverterTest.class);
+
+ @Autowired
+ private Mzs2MsgConverter converter;
+
+ @Autowired
+ private Marshaller marshaller;
+
+ @Test
+ public void testCanConvertValidMzsRequestToMsgRequest() throws IOException {
+
+ var fileName = basePath + "/validMzsDeliveryRequest.xml";
+
+ try (var inputStream = new BufferedInputStream(new FileInputStream(fileName))) {
+
+ JAXBElement<DeliveryRequestType> mzsRequest = marshaller.unmarshallXml(inputStream);
+
+ var msgRequest = converter.convert(mzsRequest.getValue());
+
+ var jaxbMsgRequest = new ObjectFactory().createDeliveryRequest(msgRequest);
+
+ String msgRequestXML = marshaller.marshallXml(jaxbMsgRequest);
+
+ logger.info("msg request: {}", msgRequestXML);
+
+ }
+
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testNoSenderID() throws IOException {
+
+ var fileName = basePath + "/mzsDeliveryRequestWithoutSenderID.xml";
+
+ try (var inputStream = new BufferedInputStream(new FileInputStream(fileName))) {
+
+ JAXBElement<DeliveryRequestType> mzsRequest = marshaller.unmarshallXml(inputStream);
+
+ converter.convert(mzsRequest.getValue());
+
+ }
+
+ }
+}