Forgot to unregister interceptor

This commit is contained in:
Tadgh 2020-07-17 13:18:27 -07:00
parent e540e4b0a2
commit fec50686ec
2 changed files with 13 additions and 5 deletions

View File

@ -7,6 +7,7 @@ import ca.uhn.test.concurrency.PointcutLatch;
import org.hl7.fhir.r4.model.Person; import org.hl7.fhir.r4.model.Person;
import org.hl7.fhir.r4.model.Practitioner; import org.hl7.fhir.r4.model.Practitioner;
import org.hl7.fhir.r4.model.StringType; import org.hl7.fhir.r4.model.StringType;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -35,9 +36,13 @@ public class EmpiProviderBatchR4Test extends BaseLinkR4Test {
myPractitionerId = new StringType(myPractitioner.getIdElement().getValue()); myPractitionerId = new StringType(myPractitioner.getIdElement().getValue());
myPractitionerPerson = getPersonFromTarget(myPractitioner); myPractitionerPerson = getPersonFromTarget(myPractitioner);
myPractitionerPersonId = new StringType(myPractitionerPerson.getIdElement().getValue()); myPractitionerPersonId = new StringType(myPractitionerPerson.getIdElement().getValue());
myInterceptorService.registerAnonymousInterceptor(Pointcut.EMPI_AFTER_PERSISTED_RESOURCE_CHECKED, afterEmpiLatch); myInterceptorService.registerAnonymousInterceptor(Pointcut.EMPI_AFTER_PERSISTED_RESOURCE_CHECKED, afterEmpiLatch);
afterEmpiLatch.clear(); }
@AfterEach
public void after() {
super.after();
myInterceptorService.unregisterInterceptor(afterEmpiLatch);
} }
@Test @Test
@ -54,10 +59,11 @@ public class EmpiProviderBatchR4Test extends BaseLinkR4Test {
} }
@Test @Test
public void testBatchRunOnAllPatients() throws InterruptedException { public void testBatchRunOnAllPatients() {
assertLinkCount(2); assertLinkCount(2);
StringType patientType = new StringType("Patient"); StringType patientType = new StringType("Patient");
StringType criteria = null; StringType criteria = null;
myEmpiProviderR4.clearEmpiLinks(null);
afterEmpiLatch.runWithExpectedCount(1, () -> { afterEmpiLatch.runWithExpectedCount(1, () -> {
myEmpiProviderR4.batchRunEmpi(patientType, criteria, null); myEmpiProviderR4.batchRunEmpi(patientType, criteria, null);
}); });
@ -65,7 +71,8 @@ public class EmpiProviderBatchR4Test extends BaseLinkR4Test {
} }
@Test @Test
public void testBatchRunOnInvalidType() throws InterruptedException { public void testBatchRunOnInvalidType() {
assertLinkCount(2);
StringType observationType= new StringType("Observation"); StringType observationType= new StringType("Observation");
StringType criteria = null; StringType criteria = null;
myEmpiProviderR4.clearEmpiLinks(null); myEmpiProviderR4.clearEmpiLinks(null);
@ -78,7 +85,7 @@ public class EmpiProviderBatchR4Test extends BaseLinkR4Test {
} }
@Test @Test
public void testBatchRunOnAllTypes() throws InterruptedException { public void testBatchRunOnAllTypes() {
assertLinkCount(2); assertLinkCount(2);
StringType patientType = new StringType("Patient"); StringType patientType = new StringType("Patient");
StringType criteria = null; StringType criteria = null;

View File

@ -68,6 +68,7 @@ public class PointcutLatch implements IAnonymousInterceptor, IPointcutLatch {
} }
public void runWithExpectedCount(int theExpectedCount, Runnable r) { public void runWithExpectedCount(int theExpectedCount, Runnable r) {
this.clear();
this.setExpectedCount(theExpectedCount); this.setExpectedCount(theExpectedCount);
r.run(); r.run();
try { try {