Terser should create correct Enumeration on create
This commit is contained in:
parent
0d4e12fe58
commit
f74eba5397
|
@ -454,7 +454,14 @@ public class FhirTerser {
|
||||||
List<? extends IBase> values = nextDef.getAccessor().getValues(theCurrentObj);
|
List<? extends IBase> values = nextDef.getAccessor().getValues(theCurrentObj);
|
||||||
|
|
||||||
if (values.isEmpty() && theCreate) {
|
if (values.isEmpty() && theCreate) {
|
||||||
IBase value = nextDef.getChildByName(name).newInstance();
|
BaseRuntimeElementDefinition<?> childByName = nextDef.getChildByName(name);
|
||||||
|
Object arg = nextDef.getInstanceConstructorArguments();
|
||||||
|
IBase value;
|
||||||
|
if (arg != null) {
|
||||||
|
value = childByName.newInstance(arg);
|
||||||
|
} else {
|
||||||
|
value = childByName.newInstance();
|
||||||
|
}
|
||||||
nextDef.getMutator().addValue(theCurrentObj, value);
|
nextDef.getMutator().addValue(theCurrentObj, value);
|
||||||
List<IBase> list = new ArrayList<>();
|
List<IBase> list = new ArrayList<>();
|
||||||
list.add(value);
|
list.add(value);
|
||||||
|
|
|
@ -8,6 +8,7 @@ import ca.uhn.fhir.parser.DataFormatException;
|
||||||
import org.hamcrest.Matchers;
|
import org.hamcrest.Matchers;
|
||||||
import org.hl7.fhir.instance.model.api.*;
|
import org.hl7.fhir.instance.model.api.*;
|
||||||
import org.hl7.fhir.r4.model.*;
|
import org.hl7.fhir.r4.model.*;
|
||||||
|
import org.hl7.fhir.r4.model.Enumeration;
|
||||||
import org.hl7.fhir.r4.model.Patient.LinkType;
|
import org.hl7.fhir.r4.model.Patient.LinkType;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
@ -31,6 +32,15 @@ public class FhirTerserR4Test {
|
||||||
private static final Logger ourLog = LoggerFactory.getLogger(FhirTerserR4Test.class);
|
private static final Logger ourLog = LoggerFactory.getLogger(FhirTerserR4Test.class);
|
||||||
private static FhirContext ourCtx = FhirContext.forR4();
|
private static FhirContext ourCtx = FhirContext.forR4();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetValuesCreateEnumeration_SetsEnumFactory() {
|
||||||
|
|
||||||
|
Patient patient = new Patient();
|
||||||
|
|
||||||
|
Enumeration<?> enumeration = (Enumeration<?>) ourCtx.newTerser().getValues(patient, "Patient.gender", Enumeration.class, true).get(0);
|
||||||
|
assertNotNull(enumeration.getEnumFactory());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testClear() {
|
public void testClear() {
|
||||||
Bundle input = new Bundle();
|
Bundle input = new Bundle();
|
||||||
|
|
Loading…
Reference in New Issue