Search in sources :

Example 1 with CanonicalXML

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);
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) CompositionTestDataCanonicalJson(org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson) LightRawJsonEncoder(org.ehrbase.serialisation.dbencoding.rawjson.LightRawJsonEncoder) CanonicalXML(org.ehrbase.serialisation.xmlencoding.CanonicalXML) CompositionTestDataCanonicalXML(org.ehrbase.test_data.composition.CompositionTestDataCanonicalXML) Test(org.junit.Test)

Example 2 with CanonicalXML

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");
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) CanonicalXML(org.ehrbase.serialisation.xmlencoding.CanonicalXML) CompositionTestDataCanonicalXML(org.ehrbase.test_data.composition.CompositionTestDataCanonicalXML) Test(org.junit.Test)

Example 3 with CanonicalXML

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();
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) CanonicalXML(org.ehrbase.serialisation.xmlencoding.CanonicalXML) CompositionTestDataCanonicalXML(org.ehrbase.test_data.composition.CompositionTestDataCanonicalXML) Test(org.junit.Test)

Example 4 with CanonicalXML

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");
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) CanonicalXML(org.ehrbase.serialisation.xmlencoding.CanonicalXML) CompositionTestDataCanonicalXML(org.ehrbase.test_data.composition.CompositionTestDataCanonicalXML) Test(org.junit.Test)

Example 5 with CanonicalXML

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);
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) CanonicalXML(org.ehrbase.serialisation.xmlencoding.CanonicalXML) CompositionTestDataCanonicalXML(org.ehrbase.test_data.composition.CompositionTestDataCanonicalXML) Section(com.nedap.archie.rm.composition.Section) Test(org.junit.Test)

Aggregations

CanonicalXML (org.ehrbase.serialisation.xmlencoding.CanonicalXML)16 Composition (com.nedap.archie.rm.composition.Composition)14 Test (org.junit.Test)14 CompositionTestDataCanonicalXML (org.ehrbase.test_data.composition.CompositionTestDataCanonicalXML)13 CanonicalJson (org.ehrbase.serialisation.jsonencoding.CanonicalJson)11 LightRawJsonEncoder (org.ehrbase.serialisation.dbencoding.rawjson.LightRawJsonEncoder)10 CompositionTestDataCanonicalJson (org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson)9 JsonElement (com.google.gson.JsonElement)3 ToXmlGenerator (com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator)1 AdminEntry (com.nedap.archie.rm.composition.AdminEntry)1 Section (com.nedap.archie.rm.composition.Section)1 DvInterval (com.nedap.archie.rm.datavalues.quantity.DvInterval)1 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)1 Folder (com.nedap.archie.rm.directory.Folder)1 QName (javax.xml.namespace.QName)1 FolderTestDataCanonicalXML (org.ehrbase.test_data.folder.FolderTestDataCanonicalXML)1 Ignore (org.junit.Ignore)1 Test (org.junit.jupiter.api.Test)1