diff options
-rw-r--r-- | src/main/java/at/gv/egiz/moazs/scheme/Mzs2MsgConverter.java | 9 | ||||
-rw-r--r-- | src/test/java/at/gv/egiz/moazs/Mzs2MsgConverterTest.java | 35 |
2 files changed, 41 insertions, 3 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/scheme/Mzs2MsgConverter.java b/src/main/java/at/gv/egiz/moazs/scheme/Mzs2MsgConverter.java index 522bb1d..b3ad044 100644 --- a/src/main/java/at/gv/egiz/moazs/scheme/Mzs2MsgConverter.java +++ b/src/main/java/at/gv/egiz/moazs/scheme/Mzs2MsgConverter.java @@ -71,7 +71,7 @@ public class Mzs2MsgConverter { public DeliveryRequestType convert(at.gv.zustellung.app2mzs.xsd.DeliveryRequestType mzsRequest, IdentificationType identification) { return setupBuilder(mzsRequest) - .withReceiver(convert(mzsRequest.getReceiver(), identification)) + .withReceiver(convertAndRepaceCombinationSequenceWithIdentification(mzsRequest.getReceiver(), identification)) .build(); } @@ -147,10 +147,13 @@ public class Mzs2MsgConverter { return setupReceiverBuilder(receiver).build(); } - private at.gv.zustellung.msg.xsd.Receiver convert(at.gv.zustellung.app2mzs.xsd.DeliveryRequestType.Receiver receiver, - IdentificationType identificationType) { + private at.gv.zustellung.msg.xsd.Receiver convertAndRepaceCombinationSequenceWithIdentification(at.gv.zustellung.app2mzs.xsd.DeliveryRequestType.Receiver receiver, + IdentificationType identificationType) { return setupReceiverBuilder(receiver) .withIdentification(identificationType) + .withPerson(null) + .withAustrianAddressesOnly(null) + .withAddress(null) .build(); } diff --git a/src/test/java/at/gv/egiz/moazs/Mzs2MsgConverterTest.java b/src/test/java/at/gv/egiz/moazs/Mzs2MsgConverterTest.java index 77654de..c6146a5 100644 --- a/src/test/java/at/gv/egiz/moazs/Mzs2MsgConverterTest.java +++ b/src/test/java/at/gv/egiz/moazs/Mzs2MsgConverterTest.java @@ -25,6 +25,7 @@ import at.gv.egiz.moazs.scheme.Marshaller; import at.gv.egiz.moazs.scheme.Mzs2MsgConverter; import at.gv.zustellung.app2mzs.xsd.DeliveryRequestType; import at.gv.zustellung.msg.xsd.ObjectFactory; +import at.gv.zustellung.msg.xsd.persondata.IdentificationType; import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; @@ -35,6 +36,8 @@ import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.IOException; +import static at.gv.zustellung.msg.xsd.persondata.IdentificationType.Value.valueBuilder; +import static at.gv.zustellung.msg.xsd.persondata.IdentificationType.identificationTypeBuilder; import static org.assertj.core.api.Assertions.assertThat; /** @@ -80,4 +83,36 @@ public class Mzs2MsgConverterTest { } } + + @Test + public void testCanConvertValidMzsRequestToMsgRequestWithIdentificationFromTNVZ() throws IOException { + + var fileName = basePath + "/validMzsDeliveryRequest.xml"; + + var idFromTNVZ = identificationTypeBuilder() + .withType("some-id-type") + .withValue(valueBuilder().withValue("some-id-value").build()) + .build(); + + try (var inputStream = new BufferedInputStream(new FileInputStream(fileName))) { + + JAXBElement<DeliveryRequestType> mzsRequest = mzsMarshaller.unmarshallXml(inputStream); + + var msgRequest = converter.convert(mzsRequest.getValue(), idFromTNVZ); + + var jaxbMsgRequest = new ObjectFactory().createDeliveryRequest(msgRequest); + + String msgRequestXML = msgMarshaller.marshallXml(jaxbMsgRequest); + + logger.info(msgRequestXML); + + assertThat(msgRequestXML) + .contains("<AppDeliveryID>valid-delivery-request-id</AppDeliveryID>") + .contains("some-id-type") + .contains("some-id-value") + .doesNotContain("Mustermann1") + .doesNotContain("Maxi"); + } + + } } |