From 249f5e5947e3b5486e9644bc88a07edb8f3cb787 Mon Sep 17 00:00:00 2001 From: Tadgh Date: Tue, 21 Jul 2020 08:51:18 -0700 Subject: [PATCH] Add two new tests. Fix non-jupiter-tests --- .../fhir/jpa/empi/svc/EmpiBatchSvcImpl.java | 10 ++--- .../provider/EmpiProviderBatchR4Test.java | 37 +++++++++++++++++++ .../uhn/fhir/parser/ExtendedPatientTest.java | 6 +-- .../uhn/fhir/parser/ExtendedPatientTest.java | 8 ++-- 4 files changed, 49 insertions(+), 12 deletions(-) diff --git a/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/svc/EmpiBatchSvcImpl.java b/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/svc/EmpiBatchSvcImpl.java index 3d594ae553c..94d9f8d079c 100644 --- a/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/svc/EmpiBatchSvcImpl.java +++ b/hapi-fhir-jpaserver-empi/src/main/java/ca/uhn/fhir/jpa/empi/svc/EmpiBatchSvcImpl.java @@ -47,8 +47,8 @@ public class EmpiBatchSvcImpl implements IEmpiBatchService { @Transactional public int runEmpiOnAllTargetTypes(String theCriteria) { int submittedCount = 0; - submittedCount += runEmpiOnTargetType("Patient", theCriteria); - submittedCount += runEmpiOnTargetType("Practitioner", theCriteria); + submittedCount += runEmpiOnPatientType(theCriteria); + submittedCount += runEmpiOnPractitionerType(theCriteria); return submittedCount; } @@ -69,7 +69,6 @@ public class EmpiBatchSvcImpl implements IEmpiBatchService { while (query.hasNext()) { pidsToSubmit.add(query.next()); if (pidsToSubmit.size() == QUEUE_ADDING_PAGE_SIZE || !query.hasNext()) { - //TODO GGG ask ken how this works. total = loadResourcesAndSubmitToEmpi(total, mySearchBuilder, pidsToSubmit, resourceToBeSubmitted); resourceToBeSubmitted.clear(); } @@ -81,6 +80,7 @@ public class EmpiBatchSvcImpl implements IEmpiBatchService { } private int loadResourcesAndSubmitToEmpi(int theTotal, ISearchBuilder theMySearchBuilder, Collection thePidsToSubmit, List theResourceToBeSubmitted) { + //TODO GGG ask ken how this works. specifically includePids? theMySearchBuilder.loadResourcesByPid(thePidsToSubmit, thePidsToSubmit, theResourceToBeSubmitted, false, null); theResourceToBeSubmitted .forEach(resource -> myEmpiQueueSubmitterSvc.manuallySubmitResourceToEmpi(resource)); @@ -113,13 +113,13 @@ public class EmpiBatchSvcImpl implements IEmpiBatchService { @Override @Transactional public int runEmpiOnTargetPractitioner(IIdType theId) { - return runEmpiOnTarget(theId, "practitioner"); + return runEmpiOnTarget(theId, "Practitioner"); } @Override @Transactional public int runEmpiOnTargetPatient(IIdType theId) { - return runEmpiOnTarget(theId, "patient"); + return runEmpiOnTarget(theId, "Patient"); } private SearchParameterMap getSearchParameterMapFromCriteria(String theTargetType, String theCriteria) { diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderBatchR4Test.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderBatchR4Test.java index 8ae6884060d..710f8a1f6bb 100644 --- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderBatchR4Test.java +++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderBatchR4Test.java @@ -3,7 +3,9 @@ package ca.uhn.fhir.jpa.empi.provider; import ca.uhn.fhir.interceptor.api.IInterceptorService; import ca.uhn.fhir.interceptor.api.Pointcut; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; +import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.test.concurrency.PointcutLatch; +import org.hl7.fhir.r4.model.IdType; import org.hl7.fhir.r4.model.Person; import org.hl7.fhir.r4.model.Practitioner; import org.hl7.fhir.r4.model.StringType; @@ -54,6 +56,23 @@ public class EmpiProviderBatchR4Test extends BaseLinkR4Test { afterEmpiLatch.runWithExpectedCount(1, () -> myEmpiProviderR4.empiBatchPractitionerType(criteria, null)); assertLinkCount(1); } + @Test + public void testBatchRunOnSpecificPractitioner() { + assertLinkCount(2); + myEmpiProviderR4.clearEmpiLinks(null); + afterEmpiLatch.runWithExpectedCount(1, () -> myEmpiProviderR4.empiBatchPractitionerInstance(myPractitioner.getIdElement(), null)); + assertLinkCount(1); + } + + @Test + public void testBatchRunOnNonExistentSpecificPractitioner() { + assertLinkCount(2); + myEmpiProviderR4.clearEmpiLinks(null); + try { + myEmpiProviderR4.empiBatchPractitionerInstance(new IdType("Practitioner/999"), null); + fail(); + } catch (ResourceNotFoundException e){} + } @Test public void testBatchRunOnAllPatients() { @@ -64,6 +83,24 @@ public class EmpiProviderBatchR4Test extends BaseLinkR4Test { assertLinkCount(1); } + @Test + public void testBatchRunOnSpecificPatient() { + assertLinkCount(2); + myEmpiProviderR4.clearEmpiLinks(null); + afterEmpiLatch.runWithExpectedCount(1, () -> myEmpiProviderR4.empiBatchPatientInstance(myPatient.getIdElement(), null)); + assertLinkCount(1); + } + + @Test + public void testBatchRunOnNonExistentSpecificPatient() { + assertLinkCount(2); + myEmpiProviderR4.clearEmpiLinks(null); + try { + myEmpiProviderR4.empiBatchPatientInstance(new IdType("Patient/999"), null); + fail(); + } catch (ResourceNotFoundException e){} + } + @Test public void testBatchRunOnAllTypes() { assertLinkCount(2); diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/ExtendedPatientTest.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/ExtendedPatientTest.java index 844b9599183..0bc8e2bc535 100644 --- a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/ExtendedPatientTest.java +++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/ExtendedPatientTest.java @@ -6,10 +6,10 @@ import org.hl7.fhir.dstu3.model.CodeType; import org.hl7.fhir.dstu3.model.Patient; import org.hl7.fhir.dstu3.model.Reference; import org.hl7.fhir.instance.model.api.IBaseResource; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; public class ExtendedPatientTest { diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/parser/ExtendedPatientTest.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/parser/ExtendedPatientTest.java index 0f0c42e795e..40ed642ef7f 100644 --- a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/parser/ExtendedPatientTest.java +++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/parser/ExtendedPatientTest.java @@ -1,15 +1,15 @@ package ca.uhn.fhir.parser; import ca.uhn.fhir.context.FhirContext; +import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.CodeType; import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Reference; -import org.hl7.fhir.instance.model.api.IBaseResource; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; public class ExtendedPatientTest {