public void setUp() { string adl = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\adl-parser\src\test\resources\adl-test-car.paths.test.adl"); se.acode.openehr.parser.ADLParser parser = new se.acode.openehr.parser.ADLParser(adl); org.openehr.am.archetype.Archetype archetype = parser.parse(); Assert.IsNotNull(archetype); CComplexObject definition = archetype.getDefinition(); }
public void testParseCommentWithSlashCharAfterSlot() { string adl = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\adl-parser\src\test\resources\openEHR-EHR-CLUSTER.auscultation.v1.adl"); se.acode.openehr.parser.ADLParser parser = new se.acode.openehr.parser.ADLParser(adl); org.openehr.am.archetype.Archetype archetype = parser.parse(); Assert.IsNotNull(archetype); }
public void testParseCommentWithSlashChar() { string adl = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\adl-parser\src\test\resources\adl-test-entry.structure_test2.test.adl"); se.acode.openehr.parser.ADLParser parser = new se.acode.openehr.parser.ADLParser(adl); org.openehr.am.archetype.Archetype archetype = parser.parse(); Assert.IsNotNull(archetype); }
public void TestMethod1() { string adl = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\adl-parser\src\test\resources\adl-test-composition.dv_coded_text.test.adl"); se.acode.openehr.parser.ADLParser parser = new se.acode.openehr.parser.ADLParser(adl); org.openehr.am.archetype.Archetype archetype = parser.parse(); Assert.IsNotNull(archetype); org.openehr.am.archetype.constraintmodel.ArchetypeConstraint node = archetype.node("/category/defining_code"); //assertTrue("CCodePhrase expected, but got " + node.getClass(), // node instanceof CCodePhrase); Assert.IsInstanceOfType(node, typeof(CCodePhrase)); CCodePhrase ccp = (CCodePhrase)node; Assert.AreEqual(ccp.getTerminologyId().toString(), "openehr", "terminologyId wrong"); Assert.AreEqual(ccp.getCodeList().get(0), "431", "codeString wrong"); }
public void testPath() { string adl = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\adl-parser\src\test\resources\adl-test-car.paths.test.adl"); se.acode.openehr.parser.ADLParser parser = new se.acode.openehr.parser.ADLParser(adl); org.openehr.am.archetype.Archetype archetype = parser.parse(); Assert.IsNotNull(archetype); CComplexObject definition = archetype.getDefinition(); // root path CAR Assert.AreEqual("/", definition.path()); // wheels attribute CAttribute wheels = (CAttribute)definition.getAttributes().get(0); Assert.AreEqual("/wheels", wheels.path()); // first WHEEL node CObject firstWheel = (CObject)wheels.getChildren().get(0); Assert.AreEqual("/wheels[at0001]", firstWheel.path()); // description and parts of first WHEEL CComplexObject firstWheelObj = (CComplexObject)firstWheel; CAttribute description = (CAttribute)firstWheelObj.getAttributes().get(0); Assert.AreEqual("/wheels[at0001]/description", description.path()); CAttribute parts = (CAttribute)firstWheelObj.getAttributes().get(1); Assert.AreEqual("/wheels[at0001]/parts", parts.path()); // WHEEL_PART node CObject wheelParts = (CObject)parts.getChildren().get(0); Assert.AreEqual("/wheels[at0001]/parts[at0002]", wheelParts.path()); // something and something_else of WHEEL_PART node //CComplexObject wheelPartsObj = (CComplexObject)wheelParts; //Assert.AreEqual("something of WHEEL_PART", // "/wheels[at0001]/parts[at0002]/something", // wheelPartsObj.getAttributes().get(0).path()); //Assert.AreEqual("something_else of WHEEL_PART", // "/wheels[at0001]/parts[at0002]/something_else", // wheelPartsObj.getAttributes().get(1).path()); }
public void testTranslationDetails() { string adl = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\adl-parser\src\test\resources\adl-test-entry.testtranslations.test.adl"); se.acode.openehr.parser.ADLParser parser = new se.acode.openehr.parser.ADLParser(adl); org.openehr.am.archetype.Archetype archetype = parser.parse(); Assert.IsNotNull(archetype); java.util.Map translations = archetype.getTranslations(); TranslationDetails transDet = (TranslationDetails)translations.get("de"); Assert.AreEqual("test Accreditation!", transDet.getAccreditation()); Assert.AreEqual("test organisation", transDet.getAuthor().get("organisation")); TranslationDetails transDet2 = (TranslationDetails)translations.get("es"); Assert.AreEqual(null, transDet2.getAccreditation()); Assert.AreEqual(null, transDet2.getAuthor().get("organisation")); }
public void testMultiLanguageConstraintDefinitions() { string adl = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\adl-parser\src\test\resources\adl-test-entry.multi_language.test.adl"); se.acode.openehr.parser.ADLParser parser = new se.acode.openehr.parser.ADLParser(adl); org.openehr.am.archetype.Archetype archetype = parser.parse(); Assert.IsNotNull(archetype); //List<OntologyDefinitions> list = //archetype.getOntology().getConstraintDefinitionsList(); Assert.AreEqual(2, archetype.getOntology().getConstraintDefinitionsList().size()); OntologyDefinitions defs = (OntologyDefinitions)archetype.getOntology().getConstraintDefinitionsList().get(0); Assert.AreEqual("en", defs.getLanguage()); defs = (OntologyDefinitions)archetype.getOntology().getConstraintDefinitionsList().get(1); Assert.AreEqual("sv", defs.getLanguage()); }
public void testCheckInternalReferences() { string adl = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\adl-parser\src\test\resources\adl-test-car.use_node.test.adl"); se.acode.openehr.parser.ADLParser parser = new se.acode.openehr.parser.ADLParser(adl); org.openehr.am.archetype.Archetype archetype = parser.parse(); se.acode.openehr.parser.ArchetypeValidator validator = new se.acode.openehr.parser.ArchetypeValidator(archetype); java.util.Map expected = new java.util.HashMap(); // wrong target path expected.put("/wheels[at0005]/parts", "/engine[at0001]/parts[at0002]"); // wrong type expected.put("/wheels[at0006]/parts", "/wheels[at0001]/parts[at0002]"); //Assert.AreEqual(expected, validator.checkInternalReferences()); }
public void testNodeAtPath() { string adl = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\adl-parser\src\test\resources\adl-test-car.paths.test.adl"); se.acode.openehr.parser.ADLParser parser = new se.acode.openehr.parser.ADLParser(adl); org.openehr.am.archetype.Archetype archetype = parser.parse(); Assert.IsNotNull(archetype); CComplexObject definition = archetype.getDefinition(); String[] paths = { "/", "/wheels[at0001]", "/wheels[at0001]/description", "/wheels[at0001]/parts[at0002]", "/wheels[at0001]/parts[at0002]/something", "/wheels[at0001]/parts[at0002]/something_else", "/wheels[at0003]", "/wheels[at0003]/description", "/wheels[at0004]", "/wheels[at0004]/description", "/wheels[at0005]", "/wheels[at0005]/description" }; CAttribute wheels = (CAttribute)definition.getAttributes().get(0); CComplexObject wheel1 = ((CComplexObject)wheels.getChildren().get(0)); CComplexObject wheel2 = ((CComplexObject)wheels.getChildren().get(1)); CComplexObject wheel3 = ((CComplexObject)wheels.getChildren().get(2)); CComplexObject wheel4 = ((CComplexObject)wheels.getChildren().get(3)); CAttribute w = (CAttribute)wheel1.getAttributes().get(1); CComplexObject parts = (CComplexObject)w.getChildren().get(0); CAttribute pt = (CAttribute)parts.getAttributes().get(0); CPrimitiveObject pts = (CPrimitiveObject)pt.getChildren().get(0); CAttribute pt2 = (CAttribute)parts.getAttributes().get(1); CPrimitiveObject pts2 = (CPrimitiveObject)pt2.getChildren().get(0); CAttribute h1 = (CAttribute)wheel1.getAttributes().get(0); CPrimitiveObject p1 = (CPrimitiveObject)h1.getChildren().get(0); CAttribute h2 = (CAttribute)wheel2.getAttributes().get(0); CPrimitiveObject p2 = (CPrimitiveObject)h2.getChildren().get(0); CAttribute h3 = (CAttribute)wheel3.getAttributes().get(0); CPrimitiveObject p3 = (CPrimitiveObject)h3.getChildren().get(0); CAttribute h4 = (CAttribute)wheel4.getAttributes().get(0); CPrimitiveObject p4 = (CPrimitiveObject)h4.getChildren().get(0); CObject[] nodes = { definition, wheel1, p1, parts, pts, pts2, wheel2, p2, wheel3, p3, wheel4, p4, }; for (int i = 0; i < paths.Length; i++) { Assert.AreEqual(nodes[i], archetype.node(paths[i])); } }