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");
}
Aggregations