package at.gv.egiz.moazs; 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 org.junit.Before; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.xml.bind.JAXBElement; import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.IOException; import static org.assertj.core.api.Assertions.assertThat; public class Mzs2MsgConverterTest { private final String basePath = "src/test/resources/at/gv/egiz/moazs/Mzs2MsgConverterTest/"; private final static Logger logger = LoggerFactory.getLogger(Mzs2MsgConverterTest.class); private Mzs2MsgConverter converter; private Marshaller mzsMarshaller; private Marshaller msgMarshaller; @Before public void setUp() { converter = new Mzs2MsgConverter(); mzsMarshaller = new Marshaller(true); msgMarshaller = new Marshaller(false); } @Test public void testCanConvertValidMzsRequestToMsgRequest() throws IOException { var fileName = basePath + "/validMzsDeliveryRequest.xml"; try (var inputStream = new BufferedInputStream(new FileInputStream(fileName))) { JAXBElement mzsRequest = mzsMarshaller.unmarshallXml(inputStream); var msgRequest = converter.convert(mzsRequest.getValue()); var jaxbMsgRequest = new ObjectFactory().createDeliveryRequest(msgRequest); String msgRequestXML = msgMarshaller.marshallXml(jaxbMsgRequest); logger.info(msgRequestXML); assertThat(msgRequestXML).contains("valid-delivery-request-id"); } } }