use of com.nedap.archie.rm.datavalues.DvText in project openEHR_SDK by ehrbase.
the class CanonicalXMLTest method marshalInline.
@Test
public void marshalInline() {
Folder folder = new Folder();
folder.setName(new DvText("folder name"));
folder.addItem(new PartyRef());
CanonicalXML canonicalXML = new CanonicalXML();
String inline = canonicalXML.marshalInline(folder, new QName(null, "folder"));
System.out.println(inline);
}
use of com.nedap.archie.rm.datavalues.DvText 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);
}
use of com.nedap.archie.rm.datavalues.DvText in project openEHR_SDK by ehrbase.
the class CanonicalJsonMarshallingTest method MarshalEmptyDvText.
@Test
public void MarshalEmptyDvText() {
DvText dvText = new DvText("");
CanonicalJson cut = new CanonicalJson();
String actual = cut.marshal(dvText);
assertThat(actual).isEqualToIgnoringWhitespace("{\n" + " \"_type\" : \"DV_TEXT\",\n" + " \"value\" : \"\"\n" + "}");
}
use of com.nedap.archie.rm.datavalues.DvText in project openEHR_SDK by ehrbase.
the class LinksEncodingTest method testFromDbTwoLinks.
public void testFromDbTwoLinks() {
LinksEncoding encoding = new LinksEncoding();
Link link = new Link(new DvText("something"), new DvText("something else"), new DvEHRURI("ehr://target"));
List<Link> list = Collections.singletonList(link);
String encoded = encoding.toDB(list);
assertNotNull(encoded);
Link link2 = new Link(new DvText("something2"), new DvText("something else2"), new DvEHRURI("ehr://target2"));
List<Link> list2 = new ArrayList<Link>();
list2.add(link);
list2.add(link2);
String encoded2 = encoding.toDB(list2);
List<Link> result2 = encoding.fromDB(encoded2);
assertEquals(list2, result2);
}
use of com.nedap.archie.rm.datavalues.DvText in project openEHR_SDK by ehrbase.
the class DefaultRestFolderDAO method setName.
@Override
public void setName(String name) {
directoryEndpoint.syncFromDb();
getFolder().setName(new DvText(name));
directoryEndpoint.saveToDb();
}
Aggregations