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();
|
myVersion = FhirVersionEnum.DSTU2.getVersionImplementation();
|
||||||
} else if (FhirVersionEnum.DSTU2_HL7ORG.isPresentOnClasspath()) {
|
} else if (FhirVersionEnum.DSTU2_HL7ORG.isPresentOnClasspath()) {
|
||||||
myVersion = FhirVersionEnum.DSTU2_HL7ORG.getVersionImplementation();
|
myVersion = FhirVersionEnum.DSTU2_HL7ORG.getVersionImplementation();
|
||||||
|
} else if (FhirVersionEnum.DSTU3.isPresentOnClasspath()) {
|
||||||
|
myVersion = FhirVersionEnum.DSTU3.getVersionImplementation();
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException(getLocalizer().getMessage(FhirContext.class, "noStructures"));
|
throw new IllegalStateException(getLocalizer().getMessage(FhirContext.class, "noStructures"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,13 @@ import ca.uhn.fhir.util.TestUtil;
|
||||||
|
|
||||||
public class FhirContextDstu1Test {
|
public class FhirContextDstu1Test {
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Test
|
||||||
|
public void testAutoDetectVersion() {
|
||||||
|
FhirContext ctx = new FhirContext();
|
||||||
|
assertEquals(FhirVersionEnum.DSTU1, ctx.getVersion().getVersion());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIncrementalScan() {
|
public void testIncrementalScan() {
|
||||||
FhirContext ctx = FhirContext.forDstu1();
|
FhirContext ctx = FhirContext.forDstu1();
|
||||||
|
|
|
@ -7,6 +7,7 @@ import org.junit.Test;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.BaseRuntimeChildDatatypeDefinition;
|
import ca.uhn.fhir.context.BaseRuntimeChildDatatypeDefinition;
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||||
import ca.uhn.fhir.model.dstu2.valueset.AdministrativeGenderEnum;
|
import ca.uhn.fhir.model.dstu2.valueset.AdministrativeGenderEnum;
|
||||||
|
@ -30,6 +31,13 @@ public class FhirContextDstu2Test {
|
||||||
ctx.getResourceDefinition("InvalidResource");
|
ctx.getResourceDefinition("InvalidResource");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Test
|
||||||
|
public void testAutoDetectVersion() {
|
||||||
|
FhirContext ctx = new FhirContext();
|
||||||
|
assertEquals(FhirVersionEnum.DSTU2, ctx.getVersion().getVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testQueryBoundCode() {
|
public void testQueryBoundCode() {
|
||||||
|
|
|
@ -22,6 +22,13 @@ public class FhirContextDstu3Test {
|
||||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Test
|
||||||
|
public void testAutoDetectVersion() {
|
||||||
|
FhirContext ctx = new FhirContext();
|
||||||
|
assertEquals(FhirVersionEnum.DSTU3, ctx.getVersion().getVersion());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See #344
|
* 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