use of ca.uhn.fhir.context.RuntimeChildChoiceDefinition in project pathling by aehrc.
the class R4DatatypeMappingsTest method testCorrectChoicesOnOpenElementType.
@Test
public void testCorrectChoicesOnOpenElementType() {
ElementCtx<Object, Object> ex = ElementCtx.forExtension(fhirContext);
RuntimeChildExtension extension = (RuntimeChildExtension) ex.childDefinition();
RuntimeCompositeDatatypeDefinition extensionChild = (RuntimeCompositeDatatypeDefinition) extension.getChildByName("extension");
// This is how we can access the 'value' child od RuntimeChildExtension.
RuntimeChildChoiceDefinition openTypeElement = (RuntimeChildChoiceDefinition) extensionChild.getChildByName("value[x]");
final Set<String> actualOpenElementUniqueChildNames = JavaConverters.seqAsJavaList(dataTypeMappings.getValidChoiceTypes(openTypeElement)).stream().map(openTypeElement::getChildNameByDatatype).collect(Collectors.toUnmodifiableSet());
final Set<String> expectedOpenElementTypes = ALLOWED_R4_OPEN_ELEMENT_TYPES.stream().map(typeName -> "value" + StringUtils.capitalize(typeName)).collect(Collectors.toUnmodifiableSet());
assertEquals(expectedOpenElementTypes, actualOpenElementUniqueChildNames);
}
Aggregations