use of com.nedap.archie.rm.composition.Composition 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 com.nedap.archie.rm.composition.Composition 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 com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class DBEncodeRoundTripTest method testAlternativeEventsRoundTrip.
@Test
@Ignore
public void testAlternativeEventsRoundTrip() throws IOException {
String value = new String(Files.readAllBytes(Paths.get("src/test/resources/sample_data/alternative_events_reduced_flat.json")));
RMDataFormat flatJson = new FlatJasonProvider(new TestDataTemplateProvider()).buildFlatJson(FlatFormat.SIM_SDT, "AlternativeEvents");
Composition composition = flatJson.unmarshal(value);
assertThat(composition).isNotNull();
CompositionSerializer compositionSerializerRawJson = new CompositionSerializer();
String db_encoded = compositionSerializerRawJson.dbEncode(composition);
assertNotNull(db_encoded);
String converted = new LightRawJsonEncoder(db_encoded).encodeCompositionAsString();
assertNotNull(converted);
Composition actual = new CanonicalJson().unmarshal(converted, Composition.class);
String actualFlat = flatJson.marshal(actual);
assertNotNull(actualFlat);
}
use of com.nedap.archie.rm.composition.Composition 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);
}
use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class DBEncodeTest method compositionEncodingEmptyProtocol.
@Test
public void compositionEncodingEmptyProtocol() throws Exception {
String value = IOUtils.toString(CompositionTestDataCanonicalJson.GECCO_PERSONENDATEN.getStream(), UTF_8);
CanonicalJson cut = new CanonicalJson();
Composition composition = cut.unmarshal(value, 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);
}
Aggregations