Added invalid test cases for DSTU3

This commit is contained in:
Frank Tao 2020-09-22 20:51:20 -04:00
parent b6d86dc5f2
commit e6a669444d
2 changed files with 16 additions and 10 deletions

View File

@ -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());
}

View File

@ -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());
}
}
}