diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyService.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyService.java index cfea4d2ac89..41170364e85 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyService.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyService.java @@ -335,14 +335,6 @@ public class CommonCodeSystemsTerminologyService implements IValidationSupport { public static String getCodeSystemUrl(@Nonnull IBaseResource theCodeSystem) { String url; switch (theCodeSystem.getStructureFhirVersionEnum()) { - case DSTU2_HL7ORG: { - url = ((CodeSystem) theCodeSystem).getUrl(); - break; - } - case DSTU3: { - url = ((org.hl7.fhir.dstu3.model.CodeSystem) theCodeSystem).getUrl(); - break; - } case R4: { url = ((org.hl7.fhir.r4.model.CodeSystem) theCodeSystem).getUrl(); break; @@ -351,8 +343,7 @@ public class CommonCodeSystemsTerminologyService implements IValidationSupport { url = ((org.hl7.fhir.r5.model.CodeSystem) theCodeSystem).getUrl(); break; } - case DSTU2: - case DSTU2_1: + case DSTU3: default: throw new IllegalArgumentException("Can not handle version: " + theCodeSystem.getStructureFhirVersionEnum()); } diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyServiceTest.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyServiceTest.java index 1be573dd025..b3cb3984ee9 100644 --- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyServiceTest.java +++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyServiceTest.java @@ -5,6 +5,8 @@ import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.context.support.ConceptValidationOptions; import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.ValidationSupportContext; +import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; + import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r4.model.CodeSystem; import org.hl7.fhir.r4.model.ValueSet; @@ -13,6 +15,9 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.fail; + +import javax.annotation.Nonnull; public class CommonCodeSystemsTerminologyServiceTest { @@ -114,4 +119,14 @@ public class CommonCodeSystemsTerminologyServiceTest { assertEquals(null, cs); } + @Test + public void testFetchCodeSystemUrlDstu3() { + try { + CommonCodeSystemsTerminologyService.getCodeSystemUrl(new org.hl7.fhir.dstu3.model.CodeSystem()); + + fail(); + } catch (IllegalArgumentException e) { + assertEquals("Can not handle version: DSTU3", e.getMessage()); + } + } }