@Test public void testScanExtensionTypes() throws DataFormatException { ModelScanner scanner = new ModelScanner(ResourceWithExtensionsA.class); RuntimeResourceDefinition def = (RuntimeResourceDefinition) scanner.getClassToElementDefinitions().get(ResourceWithExtensionsA.class); assertEquals( RuntimeChildCompositeDatatypeDefinition.class, def.getChildByNameOrThrowDataFormatException("identifier").getClass()); RuntimeChildDeclaredExtensionDefinition ext = def.getDeclaredExtension("http://foo/#f1"); assertNotNull(ext); BaseRuntimeElementDefinition<?> valueString = ext.getChildByName("valueString"); assertNotNull(valueString); ext = def.getDeclaredExtension("http://foo/#f2"); assertNotNull(ext); valueString = ext.getChildByName("valueString"); assertNotNull(valueString); ext = def.getDeclaredExtension("http://bar/#b1"); assertNotNull(ext); RuntimeChildDeclaredExtensionDefinition childExt = ext.getChildExtensionForUrl("http://bar/#b1/1"); assertNotNull(childExt); BaseRuntimeElementDefinition<?> valueDate = childExt.getChildByName("valueDate"); assertNotNull(valueDate); childExt = ext.getChildExtensionForUrl("http://bar/#b1/2"); assertNotNull(childExt); childExt = childExt.getChildExtensionForUrl("http://bar/#b1/2/1"); assertNotNull(childExt); valueDate = childExt.getChildByName("valueDate"); assertNotNull(valueDate); }
@Test public void testExtendedClass() { FhirContext ctx = new FhirContext(); ctx.getResourceDefinition(MyPatient.class); RuntimeResourceDefinition patient = ctx.getResourceDefinition("Patient"); assertEquals(Patient.class, patient.getImplementingClass()); RuntimeResourceDefinition def = ctx.getResourceDefinition(MyPatient.class); RuntimeResourceDefinition baseDef = def.getBaseDefinition(); assertEquals(Patient.class, baseDef.getImplementingClass()); }