use of com.nedap.archie.rm.datastructures.ItemSingle in project openEHR_SDK by ehrbase.
the class FeederAuditDetailsAttributesTest method toMap.
@Test
public void toMap() throws Exception {
String value = IOUtils.toString(CompositionTestDataCanonicalJson.FEEDER_AUDIT_DETAILS.getStream(), UTF_8);
CanonicalJson cut = new CanonicalJson();
Composition composition = cut.unmarshal(value, Composition.class);
assertNotNull(composition);
assertNotNull(composition.getFeederAudit().getFeederSystemAudit().getOtherDetails());
// with real data
FeederAuditDetailsAttributes attributes = new FeederAuditDetailsAttributes(composition.getFeederAudit().getFeederSystemAudit());
Map<String, Object> map = attributes.toMap();
assertNotNull(map);
assertNotNull(map.get("other_details[openEHR-EHR-ITEM_TREE.generic.v1]"));
// valid fabricated data without brackets
FeederAuditDetails details = new FeederAuditDetails();
ItemSingle single = new ItemSingle("test", new DvCodedText("text", new CodePhrase("string")), new Element("node", new DvText("name"), null));
details.setOtherDetails(single);
details.setSystemId("system");
attributes = new FeederAuditDetailsAttributes(details);
map = attributes.toMap();
assertNotNull(map.get("other_details[test]"));
// valid fabricated data with brackets
details = new FeederAuditDetails();
single = new ItemSingle("[test]", new DvCodedText("text", new CodePhrase("string")), new Element("node", new DvText("name"), null));
details.setOtherDetails(single);
details.setSystemId("system");
attributes = new FeederAuditDetailsAttributes(details);
map = attributes.toMap();
assertNotNull(map.get("other_details[test]"));
// invalid data with one [
details = new FeederAuditDetails();
single = new ItemSingle("[test", new DvCodedText("text", new CodePhrase("string")), new Element("node", new DvText("name"), null));
details.setOtherDetails(single);
details.setSystemId("system");
attributes = new FeederAuditDetailsAttributes(details);
assertThrows(IllegalArgumentException.class, attributes::toMap);
// invalid data with one ]
details = new FeederAuditDetails();
single = new ItemSingle("test]", new DvCodedText("text", new CodePhrase("string")), new Element("node", new DvText("name"), null));
details.setOtherDetails(single);
details.setSystemId("system");
attributes = new FeederAuditDetailsAttributes(details);
assertThrows(IllegalArgumentException.class, attributes::toMap);
}
Aggregations