Add a test
This commit is contained in:
parent
266384b536
commit
2543f27697
|
@ -2,10 +2,10 @@ package ca.uhn.fhir.jpa.provider.r4;
|
|||
|
||||
import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
|
||||
import ca.uhn.fhir.jpa.dao.data.IResourceTableDao;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
|
||||
import ca.uhn.fhir.jpa.entity.TermConcept;
|
||||
import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink.RelationshipTypeEnum;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.term.IHapiTerminologySvc;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
|
@ -16,6 +16,7 @@ import org.apache.commons.io.IOUtils;
|
|||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
@ -522,6 +523,52 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
|
|||
assertEquals("Yes", ((StringType) respParam.getParameter().get(2).getValue()).getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateCodeOperationOnInstanceWithIsAExpansion() throws IOException {
|
||||
CodeSystem cs = new CodeSystem();
|
||||
cs.setUrl("http://mycs");
|
||||
cs.setContent(CodeSystemContentMode.COMPLETE);
|
||||
cs.setHierarchyMeaning(CodeSystem.CodeSystemHierarchyMeaning.ISA);
|
||||
cs.setStatus(Enumerations.PublicationStatus.ACTIVE);
|
||||
ConceptDefinitionComponent parentA = cs.addConcept().setCode("ParentA").setDisplay("Parent A");
|
||||
parentA.addConcept().setCode("ChildAA").setDisplay("Child AA");
|
||||
myCodeSystemDao.create(cs);
|
||||
|
||||
ValueSet vs = new ValueSet();
|
||||
vs.setUrl("http://myvs");
|
||||
vs.getCompose()
|
||||
.addInclude()
|
||||
.setSystem("http://mycs")
|
||||
.addFilter()
|
||||
.setOp(FilterOperator.ISA)
|
||||
.setProperty("concept")
|
||||
.setValue("ParentA");
|
||||
IIdType vsId = myValueSetDao.create(vs).getId().toUnqualifiedVersionless();
|
||||
|
||||
HttpGet expandGet = new HttpGet(ourServerBase + "/ValueSet/" + vsId.getIdPart() + "/$expand?_pretty=true");
|
||||
try (CloseableHttpResponse status = ourHttpClient.execute(expandGet)) {
|
||||
String response = IOUtils.toString(status.getEntity().getContent(), Charsets.UTF_8);
|
||||
ourLog.info("Response: {}", response);
|
||||
}
|
||||
|
||||
HttpGet validateCodeGet = new HttpGet(ourServerBase + "/ValueSet/" + vsId.getIdPart() + "/$validate-code?code=ChildAA&_pretty=true");
|
||||
try (CloseableHttpResponse status = ourHttpClient.execute(validateCodeGet)) {
|
||||
String response = IOUtils.toString(status.getEntity().getContent(), Charsets.UTF_8);
|
||||
ourLog.info("Response: {}", response);
|
||||
Parameters output = myFhirCtx.newXmlParser().parseResource(Parameters.class, response);
|
||||
assertEquals(true, output.getParameterBool("result"));
|
||||
}
|
||||
|
||||
HttpGet validateCodeGet2 = new HttpGet(ourServerBase + "/ValueSet/" + vsId.getIdPart() + "/$validate-code?code=FOO&_pretty=true");
|
||||
try (CloseableHttpResponse status = ourHttpClient.execute(validateCodeGet2)) {
|
||||
String response = IOUtils.toString(status.getEntity().getContent(), Charsets.UTF_8);
|
||||
ourLog.info("Response: {}", response);
|
||||
Parameters output = myFhirCtx.newXmlParser().parseResource(Parameters.class, response);
|
||||
assertEquals(false, output.getParameterBool("result"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
|
@ -556,7 +603,7 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
|
|||
TermConcept parentB = new TermConcept(cs, "ParentB").setDisplay("Parent B");
|
||||
cs.getConcepts().add(parentB);
|
||||
|
||||
theTermSvc.storeNewCodeSystemVersion(table.getId(), URL_MY_CODE_SYSTEM,"SYSTEM NAME" , cs);
|
||||
theTermSvc.storeNewCodeSystemVersion(table.getId(), URL_MY_CODE_SYSTEM, "SYSTEM NAME", cs);
|
||||
return codeSystem;
|
||||
}
|
||||
|
||||
|
|
|
@ -350,7 +350,7 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
|
|||
|
||||
private void findResourceMethods(Object theProvider) {
|
||||
|
||||
ourLog.info("Scanning type for RESTful methods: {}", theProvider.getClass());
|
||||
ourLog.debug("Scanning type for RESTful methods: {}", theProvider.getClass());
|
||||
int count = 0;
|
||||
|
||||
Class<?> clazz = theProvider.getClass();
|
||||
|
@ -1430,7 +1430,7 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
|
|||
try {
|
||||
if (!myStarted) {
|
||||
for (Object provider : theProviders) {
|
||||
ourLog.info("Registration of provider [" + provider.getClass().getName() + "] will be delayed until FHIR server startup");
|
||||
ourLog.debug("Registration of provider [" + provider.getClass().getName() + "] will be delayed until FHIR server startup");
|
||||
if (provider instanceof IResourceProvider) {
|
||||
myResourceProviders.add((IResourceProvider) provider);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue