Search in sources :

Example 1 with XdsJaxbDataBinding

use of org.openehealth.ipf.commons.ihe.xds.core.XdsJaxbDataBinding in project ipf by oehf.

the class Ebrs30MarshalingTest method verifyExtraMetadataWithJaxbBinding.

@Test
public void verifyExtraMetadataWithJaxbBinding() throws Exception {
    var file = new File(getClass().getClassLoader().getResource("SubmitObjectsRequest_ebrs3_extra_metadata.xml").toURI());
    var unmarshaller = context.createUnmarshaller();
    unmarshaller.setListener(new XdsJaxbDataBinding().getUnmarshallerListener());
    var unmarshalled = unmarshaller.unmarshal(file);
    var original = (SubmitObjectsRequest) unmarshalled;
    int numberOfSlotsInFirstDoc = new EbXMLSubmitObjectsRequest30(original).getExtrinsicObjects().get(0).getSlots().size();
    var marshaller = context.createMarshaller();
    marshaller.setListener(new XdsJaxbDataBinding().getMarshallerListener());
    StringWriter writer = new StringWriter();
    marshaller.marshal(original, writer);
    var unmarshalledSecond = (SubmitObjectsRequest) unmarshaller.unmarshal(new StringReader(writer.toString()));
    int numberOfSlotsInSecondDoc = new EbXMLSubmitObjectsRequest30(unmarshalledSecond).getExtrinsicObjects().get(0).getSlots().size();
    assertEquals(numberOfSlotsInFirstDoc, numberOfSlotsInSecondDoc, "Number of slots after Marshalling and Unmarsshalling does not match");
}
Also used : StringWriter(java.io.StringWriter) XdsJaxbDataBinding(org.openehealth.ipf.commons.ihe.xds.core.XdsJaxbDataBinding) EbXMLSubmitObjectsRequest30(org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.EbXMLSubmitObjectsRequest30) StringReader(java.io.StringReader) File(java.io.File) SubmitObjectsRequest(org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.lcm.SubmitObjectsRequest) Test(org.junit.jupiter.api.Test)

Aggregations

File (java.io.File)1 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 Test (org.junit.jupiter.api.Test)1 XdsJaxbDataBinding (org.openehealth.ipf.commons.ihe.xds.core.XdsJaxbDataBinding)1 EbXMLSubmitObjectsRequest30 (org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.EbXMLSubmitObjectsRequest30)1 SubmitObjectsRequest (org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.lcm.SubmitObjectsRequest)1