use of org.ehrbase.serialisation.xmlencoding.CanonicalXML in project openEHR_SDK by ehrbase.
the class DBEncodeTest method compositionEncodingNoContentXML.
@Test
public void compositionEncodingNoContentXML() throws Exception {
Composition composition = new CanonicalXML().unmarshal(IOUtils.toString(CompositionTestDataCanonicalXML.ALL_TYPES_NO_CONTENT.getStream(), UTF_8), Composition.class);
assertNotNull(composition);
CompositionSerializer compositionSerializerRawJson = new CompositionSerializer();
String db_encoded = compositionSerializerRawJson.dbEncode(composition);
assertNotNull(db_encoded);
String converted = new LightRawJsonEncoder(db_encoded).encodeCompositionAsString();
assertNotNull(converted);
// see if this can be interpreted by Archie
Composition object = new CanonicalJson().unmarshal(converted, Composition.class);
assertNotNull(object);
String interpreted = new CanonicalXML().marshal(object);
assertNotNull(interpreted);
}
use of org.ehrbase.serialisation.xmlencoding.CanonicalXML in project openEHR_SDK by ehrbase.
the class RawJsonTest method unmarshal.
@Test
public void unmarshal() throws IOException {
String value = IOUtils.toString(CompositionTestDataCanonicalXML.DIADEM.getStream(), UTF_8);
CanonicalXML canonicalXML = new CanonicalXML();
Composition composition = canonicalXML.unmarshal(value, Composition.class);
RawJson cut = new RawJson();
String marshal = cut.marshal(composition);
Composition actual = cut.unmarshal(marshal, Composition.class);
assertThat(actual).isNotNull();
assertThat(composition.getName().getValue()).isEqualTo("DiADeM Assessment");
}
use of org.ehrbase.serialisation.xmlencoding.CanonicalXML in project openEHR_SDK by ehrbase.
the class RawJsonTest method marshal.
@Test
public void marshal() throws IOException {
String value = IOUtils.toString(CompositionTestDataCanonicalXML.DIADEM.getStream(), UTF_8);
CanonicalXML canonicalXML = new CanonicalXML();
Composition composition = canonicalXML.unmarshal(value, Composition.class);
RawJson cut = new RawJson();
String marshal = cut.marshal(composition);
assertThat(marshal).isNotEmpty();
}
use of org.ehrbase.serialisation.xmlencoding.CanonicalXML in project openEHR_SDK by ehrbase.
the class RawJsonTest method unmarshal2.
@Test
public void unmarshal2() throws IOException {
String value = IOUtils.toString(CompositionTestDataCanonicalXML.ALL_TYPES_FIXED.getStream(), UTF_8);
CanonicalXML canonicalXML = new CanonicalXML();
Composition composition = canonicalXML.unmarshal(value, Composition.class);
RawJson cut = new RawJson();
String marshal = cut.marshal(composition);
Composition actual = cut.unmarshal(marshal, Composition.class);
assertThat(actual).isNotNull();
assertThat(composition.getName().getValue()).isEqualTo("Test all types");
}
use of org.ehrbase.serialisation.xmlencoding.CanonicalXML in project openEHR_SDK by ehrbase.
the class DBEncodeTest method testDBDecodeIssue350.
@Test
public void testDBDecodeIssue350() throws Exception {
String db_encoded = new String(Files.readAllBytes(Paths.get("src/test/resources/sample_data/bug350_missing_data.json")));
assertNotNull(db_encoded);
// see if this can be interpreted by Archie
Composition object = new RawJson().unmarshal(db_encoded, Composition.class);
assertEquals(8, ((Section) object.itemsAtPath("/content[openEHR-EHR-SECTION.respect_headings.v0]").get(0)).getItems().size());
String interpreted = new CanonicalXML().marshal(object);
assertNotNull(interpreted);
}
Aggregations