use of com.nedap.archie.rm.datastructures.ItemTree in project openEHR_SDK by ehrbase.
the class DBEncodeTest method compositionEncodingFeederAuditDetails.
@Test
public void compositionEncodingFeederAuditDetails() throws Exception {
String value = IOUtils.toString(CompositionTestDataCanonicalJson.FEEDER_AUDIT_DETAILS.getStream(), UTF_8);
CanonicalJson cut = new CanonicalJson();
Composition composition = cut.unmarshal(value, Composition.class);
// check compo
assertNotNull(composition);
assertNotNull(composition.getFeederAudit().getFeederSystemAudit());
// other details
assertNotNull(composition.getFeederAudit().getFeederSystemAudit().getOtherDetails());
assertEquals("family group", composition.getFeederAudit().getFeederSystemAudit().getOtherDetails().getName().getValue());
assertTrue(composition.getFeederAudit().getFeederSystemAudit().getOtherDetails() instanceof ItemTree);
assertEquals(1, composition.getFeederAudit().getFeederSystemAudit().getOtherDetails().getItems().size());
assertTrue(composition.getFeederAudit().getFeederSystemAudit().getOtherDetails().getItems().get(0) instanceof Element);
assertTrue(((Element) composition.getFeederAudit().getFeederSystemAudit().getOtherDetails().getItems().get(0)).getValue() instanceof DvIdentifier);
// version id
assertNotNull(composition.getFeederAudit().getFeederSystemAudit().getVersionId());
assertEquals("final", composition.getFeederAudit().getFeederSystemAudit().getVersionId());
// DB encode other details
CompositionSerializer compositionSerializerRawJson = new CompositionSerializer();
String dbEncoded = compositionSerializerRawJson.dbEncode(composition.getFeederAudit().getFeederSystemAudit().getOtherDetails());
assertNotNull(dbEncoded);
// Convert encoded string into map to write to DB
Map<String, Object> asMap = new LightRawJsonEncoder(dbEncoded).encodeOtherDetailsAsMap();
assertNotNull(asMap);
assertEquals(4, asMap.size());
assertNotNull(asMap.get("/items[at0001]"));
// Attribute mapping and correct archetype node id path in naming
Map<String, Object> map = new FeederAuditAttributes(composition.getFeederAudit()).toMap();
assertNotNull(map);
assertNotNull(map.get("feeder_system_audit"));
Map<String, Object> feederMap = (Map) map.get("feeder_system_audit");
assertNotNull(feederMap);
assertNotNull(feederMap.get("other_details[openEHR-EHR-ITEM_TREE.generic.v1]"));
assertEquals(4, ((Map<String, Object>) feederMap.get("other_details[openEHR-EHR-ITEM_TREE.generic.v1]")).size());
}
use of com.nedap.archie.rm.datastructures.ItemTree in project openEHR_SDK by ehrbase.
the class RawJsonTest method testUnmarshalItemStructure.
@Test
public void testUnmarshalItemStructure() throws IOException {
String value = IOUtils.toString(ItemStruktureTestDataCanonicalJson.SIMPLE_EHR_OTHER_Details.getStream(), UTF_8);
CanonicalJson canonicalJson = new CanonicalJson();
ItemTree itemTree = canonicalJson.unmarshal(value, ItemTree.class);
RawJson cut = new RawJson();
String marshal = cut.marshal(itemTree);
ItemTree actual = cut.unmarshal(marshal, ItemTree.class);
assertThat(actual).isNotNull();
assertThat(actual.getItems()).size().isEqualTo(3);
}
use of com.nedap.archie.rm.datastructures.ItemTree in project openEHR_SDK by ehrbase.
the class CanonicalJsonMarshallingTest method UnmarshalItemTree.
@Test
public void UnmarshalItemTree() throws IOException {
String value = new String(Files.readAllBytes(Paths.get("src/test/resources/sample_data/item_tree_with_multimedia.json")));
CanonicalJson cut = new CanonicalJson();
ItemTree itemTree = cut.unmarshal(value, ItemTree.class);
assertNotNull(itemTree);
}
use of com.nedap.archie.rm.datastructures.ItemTree in project openEHR_SDK by ehrbase.
the class CanonicalJsonMarshallingTest method MarshalEmptyContent.
@Test
public void MarshalEmptyContent() {
ItemTree itemTree = new ItemTree();
itemTree.setNameAsString("test");
CanonicalJson cut = new CanonicalJson();
String actual = cut.marshal(itemTree);
assertThat(actual).isEqualToIgnoringWhitespace("{\n" + " \"_type\" : \"ITEM_TREE\",\n" + " \"name\" : {\n" + " \"_type\" : \"DV_TEXT\",\n" + " \"value\" : \"test\"\n" + " }\n" + "}");
}
use of com.nedap.archie.rm.datastructures.ItemTree in project openEHR_SDK by ehrbase.
the class ItemStructureVisitorTest method ehrVisitorTest.
@Test
public void ehrVisitorTest() throws Throwable {
String value = IOUtils.toString(ItemStruktureTestDataCanonicalJson.SIMPLE_EHR_OTHER_Details.getStream(), UTF_8);
RMJacksonConfiguration configuration = new RMJacksonConfiguration();
configuration.setTypePropertyName("_type");
ObjectMapper objectMapper = JacksonUtil.getObjectMapper(configuration);
ItemTree otherDetails = objectMapper.readValue(value, ItemTree.class);
EhrStatus ehrStatus = new EhrStatus("ehr_status", new DvText("ehr_status"), new PartySelf(new PartyRef()), true, true, otherDetails);
itemStructureVisitor.validate(ehrStatus);
assertEquals(3, itemStructureVisitor.getElementOccurrences());
}
Aggregations