use of org.hl7.elm_modelinfo.r1.ModelInfo in project quality-measure-and-cohort-service by Alvearie.
the class ModelUtilsTest method testGetBaseTypeNameInvalidNamespacePrefix.
@Test
public void testGetBaseTypeNameInvalidNamespacePrefix() {
ModelInfo modelInfo = new ModelInfo();
modelInfo.setName("Dummy");
modelInfo.setVersion("2.1.3");
modelInfo.setUrl("urn:oid:Dummy");
ClassInfo typeInfo = new ClassInfo();
typeInfo.setName("MyType");
typeInfo.setBaseType("System.Child.BaseType");
IllegalArgumentException iex = assertThrows(IllegalArgumentException.class, () -> ModelUtils.getBaseTypeName(modelInfo, typeInfo));
assertTrue(iex.getMessage().contains("System.Child.BaseType"));
assertTrue(iex.getMessage().contains(modelInfo.getName()));
assertTrue(iex.getMessage(), iex.getMessage().contains(modelInfo.getVersion()));
}
use of org.hl7.elm_modelinfo.r1.ModelInfo in project quality-measure-and-cohort-service by Alvearie.
the class ModelUtilsTest method testGetBaseTypeWithoutBaseType.
@Test
public void testGetBaseTypeWithoutBaseType() {
ModelInfo modelInfo = new ModelInfo();
ClassInfo typeInfo = new ClassInfo();
typeInfo.setName("MyType");
assertNull(ModelUtils.getBaseTypeName(modelInfo, typeInfo));
}
use of org.hl7.elm_modelinfo.r1.ModelInfo in project quality-measure-and-cohort-service by Alvearie.
the class ModelUtilsTest method loadFromClasspath.
protected ModelInfo loadFromClasspath(String resourcePath) throws IOException {
ModelInfo modelInfo;
try (InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream(resourcePath)) {
assertNotNull("Classpath resource not found", is);
modelInfo = JAXB.unmarshal(is, ModelInfo.class);
}
return modelInfo;
}
use of org.hl7.elm_modelinfo.r1.ModelInfo in project quality-measure-and-cohort-service by Alvearie.
the class ModelUtilsTest method testFHIR401Model.
@Test
public void testFHIR401Model() throws Exception {
ModelInfo modelInfo = loadFromClasspath("org/hl7/fhir/fhir-modelinfo-4.0.1.xml");
Map<QName, TypeNode> typeMap = ModelUtils.buildTypeMap(modelInfo);
assertEquals(931, typeMap.size());
TypeNode node = typeMap.get(new QName(modelInfo.getUrl(), "MoneyQuantity"));
assertNotNull(node);
assertEquals("Missing parent type", 1, node.getParentTypes().size());
assertEquals("Quantity", node.getParentTypes().iterator().next().getTypeName().getLocalPart());
node = typeMap.get(new QName(modelInfo.getUrl(), "Quantity"));
assertNotNull(node);
assertEquals(6, node.getChildTypes().size());
assertEquals(1, node.getChildTypes().stream().filter(n -> n.getTypeName().getLocalPart().equals("MoneyQuantity")).collect(Collectors.counting()).longValue());
}
use of org.hl7.elm_modelinfo.r1.ModelInfo in project quality-measure-and-cohort-service by Alvearie.
the class ModelUtilsTest method testGetBaseTypeNameIncludedNamespacePrefixValid.
@Test
public void testGetBaseTypeNameIncludedNamespacePrefixValid() {
ModelSpecifier otherModel = new ModelSpecifier().withName("Other").withVersion("1.2.3").withUrl("urn:oid:Other");
ModelInfo modelInfo = new ModelInfo();
modelInfo.setName("Dummy");
modelInfo.setUrl("urn:oid:Dummy");
modelInfo.getRequiredModelInfo().add(otherModel);
ClassInfo typeInfo = new ClassInfo();
typeInfo.setName("MyType");
typeInfo.setBaseType("Other.BaseType");
QName qname = ModelUtils.getBaseTypeName(modelInfo, typeInfo);
assertEquals(new QName(otherModel.getUrl(), "BaseType"), qname);
}
Aggregations