aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/at/gv/egiz/moazs/Mzs2MsgConverterTest.java67
-rw-r--r--src/test/resources/at/gv/egiz/moazs/Mzs2MsgConverterTest/mzsDeliveryRequestWithoutSenderID.xml42
-rw-r--r--src/test/resources/at/gv/egiz/moazs/Mzs2MsgConverterTest/validMzsDeliveryRequest.xml49
3 files changed, 158 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());
+
+ }
+
+ }
+}
diff --git a/src/test/resources/at/gv/egiz/moazs/Mzs2MsgConverterTest/mzsDeliveryRequestWithoutSenderID.xml b/src/test/resources/at/gv/egiz/moazs/Mzs2MsgConverterTest/mzsDeliveryRequestWithoutSenderID.xml
new file mode 100644
index 0000000..6006388
--- /dev/null
+++ b/src/test/resources/at/gv/egiz/moazs/Mzs2MsgConverterTest/mzsDeliveryRequestWithoutSenderID.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<mzs:DeliveryRequest
+ xmlns:mzs="http://reference.e-government.gv.at/namespace/zustellung/mzs/app2mzs#"
+ xmlns:p="http://reference.e-government.gv.at/namespace/zustellung/mzs/persondata#"
+ xmlns:msg="http://reference.e-government.gv.at/namespace/zustellung/msg/phase2/20181206#">
+ <mzs:Sender>
+ <mzs:WebserviceURL>https://authority.gv.at/delivery_notification</mzs:WebserviceURL>
+ </mzs:Sender>
+ <mzs:Receiver>
+ <p:PhysicalPerson>
+ <p:Name>
+ <p:GivenName>Maxi</p:GivenName>
+ <p:FamilyName>Mustermann1</p:FamilyName>
+ </p:Name>
+ <p:DateOfBirth>1984-01-24</p:DateOfBirth>
+ </p:PhysicalPerson>
+ <p:PostalAddress>
+ <p:CountryCode>AT</p:CountryCode>
+ <p:PostalCode>1010</p:PostalCode>
+ <p:Municipality>Wien</p:Municipality>
+ <p:DeliveryAddress>
+ <p:StreetName>Muststrasse</p:StreetName>
+ <p:BuildingNumber>10</p:BuildingNumber>
+ </p:DeliveryAddress>
+ </p:PostalAddress>
+ </mzs:Receiver>
+ <msg:MetaData>
+ <msg:AppDeliveryID>valid-delivery-request-id</msg:AppDeliveryID>
+ <msg:Subject>WichtigeMitteilung</msg:Subject>
+ <msg:DeliveryQuality>RSa</msg:DeliveryQuality>
+ </msg:MetaData>
+ <mzs:Payload>
+ <mzs:DocumentReference>https://authority.gv.at/files/73bdf969781ba41fa07df1ff8439cf685c0db1c3</mzs:DocumentReference>
+ <mzs:FileName>brief.xml</mzs:FileName>
+ <mzs:MIMEType>text/xml</mzs:MIMEType>
+ <msg:CheckSum>
+ <msg:AlgorithmID>SHA1</msg:AlgorithmID>
+ <msg:Value>9b972c70fdaf5e1b26b3387c87b0ffb72e5940b6</msg:Value>
+ </msg:CheckSum>
+ <mzs:Size>123401</mzs:Size>
+ </mzs:Payload>
+</mzs:DeliveryRequest>
diff --git a/src/test/resources/at/gv/egiz/moazs/Mzs2MsgConverterTest/validMzsDeliveryRequest.xml b/src/test/resources/at/gv/egiz/moazs/Mzs2MsgConverterTest/validMzsDeliveryRequest.xml
new file mode 100644
index 0000000..7b67662
--- /dev/null
+++ b/src/test/resources/at/gv/egiz/moazs/Mzs2MsgConverterTest/validMzsDeliveryRequest.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<mzs:DeliveryRequest
+ xmlns:mzs="http://reference.e-government.gv.at/namespace/zustellung/mzs/app2mzs#"
+ xmlns:p="http://reference.e-government.gv.at/namespace/zustellung/mzs/persondata#"
+ xmlns:msg="http://reference.e-government.gv.at/namespace/zustellung/msg/phase2/20181206#">
+ <mzs:Sender>
+ <p:CorporateBody>
+ <p:Identification>
+ <p:Value>kkvj693+tw99uW8UPuEK9en1LzZItkylPajkUUyJJDWQB78VGPkAuhCEk+TD12yQDD/WRglsf+JfQpjubIs/4l/ptluJ9teF3nwkNlu5Dm7mIjzgW1qxrDyomCmPvVxTWOCBuMUbOWRZBhOq+KvDQAu9Vv9KnqSfjYeDZrpHYu4=</p:Value>
+ <p:Type>urn:publicid:gv:at:cemtoken</p:Type>
+ </p:Identification>
+ <p:FullName>Bundesministerium für Testzwecke</p:FullName>
+ </p:CorporateBody>
+ <mzs:WebserviceURL>https://authority.gv.at/delivery_notification</mzs:WebserviceURL>
+ </mzs:Sender>
+ <mzs:Receiver>
+ <p:PhysicalPerson>
+ <p:Name>
+ <p:GivenName>Maxi</p:GivenName>
+ <p:FamilyName>Mustermann1</p:FamilyName>
+ </p:Name>
+ <p:DateOfBirth>1984-01-24</p:DateOfBirth>
+ </p:PhysicalPerson>
+ <p:PostalAddress>
+ <p:CountryCode>AT</p:CountryCode>
+ <p:PostalCode>1010</p:PostalCode>
+ <p:Municipality>Wien</p:Municipality>
+ <p:DeliveryAddress>
+ <p:StreetName>Muststrasse</p:StreetName>
+ <p:BuildingNumber>10</p:BuildingNumber>
+ </p:DeliveryAddress>
+ </p:PostalAddress>
+ </mzs:Receiver>
+ <msg:MetaData>
+ <msg:AppDeliveryID>valid-delivery-request-id</msg:AppDeliveryID>
+ <msg:Subject>WichtigeMitteilung</msg:Subject>
+ <msg:DeliveryQuality>RSa</msg:DeliveryQuality>
+ </msg:MetaData>
+ <mzs:Payload>
+ <mzs:DocumentReference>https://authority.gv.at/files/73bdf969781ba41fa07df1ff8439cf685c0db1c3</mzs:DocumentReference>
+ <mzs:FileName>brief.xml</mzs:FileName>
+ <mzs:MIMEType>text/xml</mzs:MIMEType>
+ <msg:CheckSum>
+ <msg:AlgorithmID>SHA1</msg:AlgorithmID>
+ <msg:Value>9b972c70fdaf5e1b26b3387c87b0ffb72e5940b6</msg:Value>
+ </msg:CheckSum>
+ <mzs:Size>123401</mzs:Size>
+ </mzs:Payload>
+</mzs:DeliveryRequest>