Fix #495 - Auto-detect DSTU3 mode when those resources are on classpath
This commit is contained in:
parent
ba896e2553
commit
bf35f7e4b2
|
@ -188,6 +188,8 @@ public class FhirContext {
|
|||
myVersion = FhirVersionEnum.DSTU2.getVersionImplementation();
|
||||
} else if (FhirVersionEnum.DSTU2_HL7ORG.isPresentOnClasspath()) {
|
||||
myVersion = FhirVersionEnum.DSTU2_HL7ORG.getVersionImplementation();
|
||||
} else if (FhirVersionEnum.DSTU3.isPresentOnClasspath()) {
|
||||
myVersion = FhirVersionEnum.DSTU3.getVersionImplementation();
|
||||
} else {
|
||||
throw new IllegalStateException(getLocalizer().getMessage(FhirContext.class, "noStructures"));
|
||||
}
|
||||
|
|
|
@ -13,6 +13,13 @@ import ca.uhn.fhir.util.TestUtil;
|
|||
|
||||
public class FhirContextDstu1Test {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testAutoDetectVersion() {
|
||||
FhirContext ctx = new FhirContext();
|
||||
assertEquals(FhirVersionEnum.DSTU1, ctx.getVersion().getVersion());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncrementalScan() {
|
||||
FhirContext ctx = FhirContext.forDstu1();
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.junit.Test;
|
|||
|
||||
import ca.uhn.fhir.context.BaseRuntimeChildDatatypeDefinition;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.AdministrativeGenderEnum;
|
||||
|
@ -30,7 +31,14 @@ public class FhirContextDstu2Test {
|
|||
ctx.getResourceDefinition("InvalidResource");
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testAutoDetectVersion() {
|
||||
FhirContext ctx = new FhirContext();
|
||||
assertEquals(FhirVersionEnum.DSTU2, ctx.getVersion().getVersion());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testQueryBoundCode() {
|
||||
RuntimeResourceDefinition patientType = ourCtx.getResourceDefinition(Patient.class);
|
||||
|
|
|
@ -22,6 +22,13 @@ public class FhirContextDstu3Test {
|
|||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testAutoDetectVersion() {
|
||||
FhirContext ctx = new FhirContext();
|
||||
assertEquals(FhirVersionEnum.DSTU3, ctx.getVersion().getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* See #344
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package ca.uhn.fhir.context;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class FhirContextDstu2Hl7OrgTest {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testAutoDetectVersion() {
|
||||
FhirContext ctx = new FhirContext();
|
||||
assertEquals(FhirVersionEnum.DSTU2_HL7ORG, ctx.getVersion().getVersion());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue