use of org.ehrbase.serialisation.attributes.FeederAuditAttributes 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());
}
Aggregations