Search in sources :

Example 1 with ObjectFactory

use of no.difi.meldingsutveksling.noarkexchange.schema.ObjectFactory in project efm-integrasjonspunkt by felleslosninger.

the class WebsakPutMessageRequestMapperTest method tryMapper.

@Test
public void tryMapper() throws JAXBException, XMLStreamException {
    PutMessageRequestType putMessageRequestType = testData.loadFromClasspath("ephorte/PutMessageMessage.xml");
    JAXBContext ctx2 = JAXBContext.newInstance(PutMessageRequestType.class);
    Marshaller marshaller = ctx2.createMarshaller();
    ByteArrayOutputStream bos = new ByteArrayOutputStream(4096);
    marshaller.marshal(new ObjectFactory().createPutMessageRequest(putMessageRequestType), bos);
    byte[] bytes = bos.toByteArray();
    JAXBContext ctx = JAXBContext.newInstance(no.difi.meldingsutveksling.noarkexchange.websak.schema.PutMessageRequestType.class);
    Unmarshaller unmarshaller = ctx.createUnmarshaller();
    StreamSource source = new StreamSource(new ByteArrayInputStream(bytes));
    no.difi.meldingsutveksling.noarkexchange.websak.schema.PutMessageRequestType value = unmarshaller.unmarshal(source, no.difi.meldingsutveksling.noarkexchange.websak.schema.PutMessageRequestType.class).getValue();
    System.out.println(value.getPayload());
}
Also used : StreamSource(javax.xml.transform.stream.StreamSource) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PutMessageRequestType(no.difi.meldingsutveksling.noarkexchange.schema.PutMessageRequestType) ObjectFactory(no.difi.meldingsutveksling.noarkexchange.schema.ObjectFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) Test(org.junit.jupiter.api.Test)

Example 2 with ObjectFactory

use of no.difi.meldingsutveksling.noarkexchange.schema.ObjectFactory in project efm-integrasjonspunkt by felleslosninger.

the class P360PutMessageRequestMapperTest method mapFromEphortePutMessageToP360PutMessage.

@Disabled("Work in progress")
@Test
public void mapFromEphortePutMessageToP360PutMessage() throws JAXBException, XMLStreamException {
    PutMessageRequestType putMessageRequestType = testData.loadFromClasspath("ephorte/PutMessageMessage.xml");
    PutMessageRequestMapper mapper = new PutMessageRequestMapper();
    no.difi.meldingsutveksling.noarkexchange.p360.schema.PutMessageRequestType p360Request = mapper.mapFrom(putMessageRequestType).getValue();
    assertFalse(PayloadUtil.isEmpty(p360Request.getPayload()));
    // assertTrue(p360Request.getPayload().contains("Melding"));
    JAXBContext ctx2 = JAXBContext.newInstance(PutMessageRequestType.class);
    Marshaller marshaller = ctx2.createMarshaller();
    StringWriter writer = new StringWriter();
    marshaller.marshal(new ObjectFactory().createPutMessageRequest(putMessageRequestType), writer);
    String xml = writer.toString();
    JAXBContext ctx = JAXBContext.newInstance(no.difi.meldingsutveksling.noarkexchange.p360.schema.PutMessageRequestType.class);
    Unmarshaller unmarshaller = ctx.createUnmarshaller();
    // System.out.println(xml);
    no.difi.meldingsutveksling.noarkexchange.p360.schema.PutMessageRequestType p360result = unmarshaller.unmarshal(new StringSource(xml), no.difi.meldingsutveksling.noarkexchange.p360.schema.PutMessageRequestType.class).getValue();
    System.out.println(p360result.getPayload());
}
Also used : PutMessageRequestMapper(no.difi.meldingsutveksling.noarkexchange.p360.PutMessageRequestMapper) PutMessageRequestType(no.difi.meldingsutveksling.noarkexchange.schema.PutMessageRequestType) StringWriter(java.io.StringWriter) ObjectFactory(no.difi.meldingsutveksling.noarkexchange.schema.ObjectFactory) StringSource(org.springframework.xml.transform.StringSource) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 3 with ObjectFactory

use of no.difi.meldingsutveksling.noarkexchange.schema.ObjectFactory in project efm-integrasjonspunkt by felleslosninger.

the class WebsakPutMessageRequestMapperTest method mapFromEphortePutMessageToWebsakPutMessage.

@Test()
public void mapFromEphortePutMessageToWebsakPutMessage() throws JAXBException, XMLStreamException {
    PutMessageRequestType putMessageRequestType = testData.loadFromClasspath("ephorte/PutMessageMessage.xml");
    PutMessageRequestMapper mapper = new PutMessageRequestMapper();
    no.difi.meldingsutveksling.noarkexchange.websak.schema.PutMessageRequestType websakRequest = mapper.mapFrom(putMessageRequestType).getValue();
    assertFalse(PayloadUtil.isEmpty(websakRequest.getPayload()));
    JAXBContext ctx2 = JAXBContext.newInstance(PutMessageRequestType.class);
    Marshaller marshaller = ctx2.createMarshaller();
    StringWriter writer = new StringWriter();
    marshaller.marshal(new ObjectFactory().createPutMessageRequest(putMessageRequestType), writer);
    String xml = writer.toString();
    JAXBContext ctx = JAXBContext.newInstance(no.difi.meldingsutveksling.noarkexchange.websak.schema.PutMessageRequestType.class);
    Unmarshaller unmarshaller = ctx.createUnmarshaller();
    no.difi.meldingsutveksling.noarkexchange.websak.schema.PutMessageRequestType websakResult = unmarshaller.unmarshal(new StringSource(xml), no.difi.meldingsutveksling.noarkexchange.websak.schema.PutMessageRequestType.class).getValue();
    System.out.println(websakResult.getPayload());
}
Also used : PutMessageRequestMapper(no.difi.meldingsutveksling.noarkexchange.websak.PutMessageRequestMapper) PutMessageRequestType(no.difi.meldingsutveksling.noarkexchange.schema.PutMessageRequestType) StringWriter(java.io.StringWriter) ObjectFactory(no.difi.meldingsutveksling.noarkexchange.schema.ObjectFactory) StringSource(org.springframework.xml.transform.StringSource) Test(org.junit.jupiter.api.Test)

Example 4 with ObjectFactory

use of no.difi.meldingsutveksling.noarkexchange.schema.ObjectFactory in project efm-integrasjonspunkt by felleslosninger.

the class P360PutMessageRequestMapperTest method tryMapper.

@Test
public void tryMapper() throws JAXBException, XMLStreamException {
    PutMessageRequestType putMessageRequestType = testData.loadFromClasspath("ephorte/PutMessageMessage.xml");
    JAXBContext ctx2 = JAXBContext.newInstance(PutMessageRequestType.class);
    Marshaller marshaller = ctx2.createMarshaller();
    ByteArrayOutputStream bos = new ByteArrayOutputStream(4096);
    marshaller.marshal(new ObjectFactory().createPutMessageRequest(putMessageRequestType), bos);
    byte[] bytes = bos.toByteArray();
    JAXBContext ctx = JAXBContext.newInstance(no.difi.meldingsutveksling.noarkexchange.p360.schema.PutMessageRequestType.class);
    Unmarshaller unmarshaller = ctx.createUnmarshaller();
    StreamSource source = new StreamSource(new ByteArrayInputStream(bytes));
    no.difi.meldingsutveksling.noarkexchange.p360.schema.PutMessageRequestType value = unmarshaller.unmarshal(source, no.difi.meldingsutveksling.noarkexchange.p360.schema.PutMessageRequestType.class).getValue();
    System.out.println(value.getPayload());
}
Also used : StreamSource(javax.xml.transform.stream.StreamSource) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PutMessageRequestType(no.difi.meldingsutveksling.noarkexchange.schema.PutMessageRequestType) ObjectFactory(no.difi.meldingsutveksling.noarkexchange.schema.ObjectFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) Test(org.junit.jupiter.api.Test)

Aggregations

ObjectFactory (no.difi.meldingsutveksling.noarkexchange.schema.ObjectFactory)4 PutMessageRequestType (no.difi.meldingsutveksling.noarkexchange.schema.PutMessageRequestType)4 Test (org.junit.jupiter.api.Test)4 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 StringWriter (java.io.StringWriter)2 StreamSource (javax.xml.transform.stream.StreamSource)2 StringSource (org.springframework.xml.transform.StringSource)2 PutMessageRequestMapper (no.difi.meldingsutveksling.noarkexchange.p360.PutMessageRequestMapper)1 PutMessageRequestMapper (no.difi.meldingsutveksling.noarkexchange.websak.PutMessageRequestMapper)1 Disabled (org.junit.jupiter.api.Disabled)1