diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java index a374f9738f9..84228f34703 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java @@ -1,5 +1,6 @@ package ca.uhn.fhir.jpa.dao; +import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -10,6 +11,8 @@ import java.util.*; import javax.persistence.EntityManager; +import ca.uhn.fhir.jpa.util.StopWatch; +import ca.uhn.fhir.model.dstu2.resource.Observation; import org.apache.commons.io.IOUtils; import org.hibernate.search.jpa.Search; import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; @@ -291,4 +294,17 @@ public abstract class BaseJpaTest { return retVal; } + public static void waitForSize(int theTarget, List theList) { + StopWatch sw = new StopWatch(); + while (theList.size() != theTarget && sw.getMillis() < 10000) { + try { + Thread.sleep(50); + } catch (InterruptedException theE) { + throw new Error(theE); + } + } + if (sw.getMillis() >= 10000) { + fail("Size " + theList.size() + " is != target " + theTarget); + } + } } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/RestHookTestDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/RestHookTestDstu2Test.java index 7d9ab13ce6e..f104fd06f85 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/RestHookTestDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/RestHookTestDstu2Test.java @@ -148,8 +148,8 @@ public class RestHookTestDstu2Test extends BaseResourceProviderDstu2Test { // Should see 1 subscription notification waitForQueueToDrain(); - assertEquals(1, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(1, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Subscription subscriptionTemp = ourClient.read(Subscription.class, subscription2.getId()); Assert.assertNotNull(subscriptionTemp); @@ -163,8 +163,8 @@ public class RestHookTestDstu2Test extends BaseResourceProviderDstu2Test { waitForQueueToDrain(); // Should see one subscription notification - assertEquals(3, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(3, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); // Delet one subscription ourClient.delete().resourceById(new IdDt("Subscription/" + subscription2.getId())).execute(); @@ -173,8 +173,8 @@ public class RestHookTestDstu2Test extends BaseResourceProviderDstu2Test { // Should see only one subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3 = ourClient.read(Observation.class, observationTemp3.getId()); CodeableConceptDt codeableConcept = new CodeableConceptDt(); @@ -186,8 +186,8 @@ public class RestHookTestDstu2Test extends BaseResourceProviderDstu2Test { // Should see no subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3a = ourClient.read(Observation.class, observationTemp3.getId()); @@ -200,8 +200,8 @@ public class RestHookTestDstu2Test extends BaseResourceProviderDstu2Test { // Should see only one subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(1, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(1, ourUpdatedObservations); Assert.assertFalse(subscription1.getId().equals(subscription2.getId())); Assert.assertFalse(observation1.getId().isEmpty()); @@ -223,8 +223,9 @@ public class RestHookTestDstu2Test extends BaseResourceProviderDstu2Test { // Should see 1 subscription notification waitForQueueToDrain(); - assertEquals(1, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(1, ourCreatedObservations); + waitForSize(1, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Subscription subscriptionTemp = ourClient.read(Subscription.class, subscription2.getId()); Assert.assertNotNull(subscriptionTemp); @@ -236,8 +237,8 @@ public class RestHookTestDstu2Test extends BaseResourceProviderDstu2Test { // Should see one subscription notification waitForQueueToDrain(); - assertEquals(3, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(3, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); ourClient.delete().resourceById(new IdDt("Subscription/" + subscription2.getId())).execute(); @@ -245,8 +246,8 @@ public class RestHookTestDstu2Test extends BaseResourceProviderDstu2Test { // Should see only one subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3 = ourClient.read(Observation.class, observationTemp3.getId()); CodeableConceptDt codeableConcept = new CodeableConceptDt(); @@ -258,8 +259,8 @@ public class RestHookTestDstu2Test extends BaseResourceProviderDstu2Test { // Should see no subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3a = ourClient.read(Observation.class, observationTemp3.getId()); @@ -272,8 +273,8 @@ public class RestHookTestDstu2Test extends BaseResourceProviderDstu2Test { // Should see only one subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(1, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(1, ourUpdatedObservations); Assert.assertFalse(subscription1.getId().equals(subscription2.getId())); Assert.assertFalse(observation1.getId().isEmpty()); @@ -281,12 +282,11 @@ public class RestHookTestDstu2Test extends BaseResourceProviderDstu2Test { } public static void waitForQueueToDrain(BaseSubscriptionInterceptor theRestHookSubscriptionInterceptor) throws InterruptedException { - Thread.sleep(500); - ourLog.info("QUEUE HAS {} ITEMS", ourRestHookSubscriptionInterceptor.getExecutorQueueForUnitTests().size()); - while (ourRestHookSubscriptionInterceptor.getExecutorQueueForUnitTests().size() > 0) { - Thread.sleep(500); + ourLog.info("QUEUE HAS {} ITEMS", theRestHookSubscriptionInterceptor.getExecutorQueueForUnitTests().size()); + while (theRestHookSubscriptionInterceptor.getExecutorQueueForUnitTests().size() > 0) { + Thread.sleep(50); } - ourLog.info("QUEUE HAS {} ITEMS", ourRestHookSubscriptionInterceptor.getExecutorQueueForUnitTests().size()); + ourLog.info("QUEUE HAS {} ITEMS", theRestHookSubscriptionInterceptor.getExecutorQueueForUnitTests().size()); } private void waitForQueueToDrain() throws InterruptedException { diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/RestHookTestDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/RestHookTestDstu3Test.java index b51a2a4f86e..cb236d5cd63 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/RestHookTestDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/RestHookTestDstu3Test.java @@ -145,8 +145,8 @@ public class RestHookTestDstu3Test extends BaseResourceProviderDstu3Test { // Should see 1 subscription notification waitForQueueToDrain(); - assertEquals(1, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(1, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); assertEquals(Constants.CT_FHIR_JSON_NEW, ourContentTypes.get(0)); } @@ -169,8 +169,8 @@ public class RestHookTestDstu3Test extends BaseResourceProviderDstu3Test { // Should see 1 subscription notification waitForQueueToDrain(); - assertEquals(1, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(1, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); assertEquals(Constants.CT_FHIR_JSON_NEW, ourContentTypes.get(0)); // Modify subscription 2 to also match @@ -185,8 +185,8 @@ public class RestHookTestDstu3Test extends BaseResourceProviderDstu3Test { // Should see one subscription notification waitForQueueToDrain(); - assertEquals(3, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(3, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); ourClient.delete().resourceById(new IdType("Subscription/" + subscription2.getId())).execute(); waitForQueueToDrain(); @@ -195,8 +195,8 @@ public class RestHookTestDstu3Test extends BaseResourceProviderDstu3Test { // Should see only one subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3 = ourClient.read(Observation.class, observationTemp3.getId()); CodeableConcept codeableConcept = new CodeableConcept(); @@ -208,8 +208,8 @@ public class RestHookTestDstu3Test extends BaseResourceProviderDstu3Test { // Should see no subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3a = ourClient.read(Observation.class, observationTemp3.getId()); @@ -222,8 +222,8 @@ public class RestHookTestDstu3Test extends BaseResourceProviderDstu3Test { // Should see only one subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(1, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(1, ourUpdatedObservations); Assert.assertFalse(subscription1.getId().equals(subscription2.getId())); Assert.assertFalse(observation1.getId().isEmpty()); @@ -245,8 +245,8 @@ public class RestHookTestDstu3Test extends BaseResourceProviderDstu3Test { // Should see 1 subscription notification waitForQueueToDrain(); - assertEquals(1, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(1, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); assertEquals(Constants.CT_FHIR_XML_NEW, ourContentTypes.get(0)); } @@ -265,8 +265,8 @@ public class RestHookTestDstu3Test extends BaseResourceProviderDstu3Test { // Should see 1 subscription notification waitForQueueToDrain(); - assertEquals(1, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(1, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); assertEquals(Constants.CT_FHIR_XML_NEW, ourContentTypes.get(0)); // Modify subscription 2 to also match @@ -281,8 +281,8 @@ public class RestHookTestDstu3Test extends BaseResourceProviderDstu3Test { // Should see two subscription notifications waitForQueueToDrain(); - assertEquals(3, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(3, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); ourClient.delete().resourceById(new IdType("Subscription/" + subscription2.getId())).execute(); waitForQueueToDrain(); @@ -292,8 +292,8 @@ public class RestHookTestDstu3Test extends BaseResourceProviderDstu3Test { // Should see only one subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3 = ourClient.read(Observation.class, observationTemp3.getId()); CodeableConcept codeableConcept = new CodeableConcept(); @@ -305,8 +305,8 @@ public class RestHookTestDstu3Test extends BaseResourceProviderDstu3Test { // Should see no subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3a = ourClient.read(Observation.class, observationTemp3.getId()); @@ -319,8 +319,8 @@ public class RestHookTestDstu3Test extends BaseResourceProviderDstu3Test { // Should see only one subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(1, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(1, ourUpdatedObservations); Assert.assertFalse(subscription1.getId().equals(subscription2.getId())); Assert.assertFalse(observation1.getId().isEmpty()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test.java index 42b7ef2a6b6..080b0acb9bf 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test.java @@ -132,8 +132,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test extends B // Should see 1 subscription notification waitForQueueToDrain(); - assertEquals(1, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(1, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Subscription subscriptionTemp = ourClient.read(Subscription.class, subscription2.getId()); Assert.assertNotNull(subscriptionTemp); @@ -146,8 +146,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test extends B // Should see two subscription notifications waitForQueueToDrain(); - assertEquals(3, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(3, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); ourClient.delete().resourceById(new IdDt("Subscription/"+ subscription2.getId())).execute(); @@ -155,8 +155,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test extends B // Should see only one subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3 = ourClient.read(Observation.class, observationTemp3.getId()); CodeableConceptDt codeableConcept = new CodeableConceptDt(); @@ -168,8 +168,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test extends B // Should see no subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3a = ourClient.read(Observation.class, observationTemp3.getId()); @@ -182,8 +182,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test extends B // Should see only one subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(1, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(1, ourUpdatedObservations); Assert.assertFalse(subscription1.getId().equals(subscription2.getId())); Assert.assertFalse(observation1.getId().isEmpty()); @@ -205,8 +205,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test extends B // Should see 1 subscription notification waitForQueueToDrain(); - assertEquals(1, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(1, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Subscription subscriptionTemp = ourClient.read(Subscription.class, subscription2.getId()); Assert.assertNotNull(subscriptionTemp); @@ -219,8 +219,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test extends B // Should see two subscription notifications waitForQueueToDrain(); - assertEquals(3, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(3, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); ourClient.delete().resourceById(new IdDt("Subscription/"+ subscription2.getId())).execute(); @@ -228,8 +228,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test extends B // Should see only one subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3 = ourClient.read(Observation.class, observationTemp3.getId()); CodeableConceptDt codeableConcept = new CodeableConceptDt(); @@ -241,8 +241,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test extends B // Should see no subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3a = ourClient.read(Observation.class, observationTemp3.getId()); @@ -255,8 +255,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test extends B // Should see only one subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(1, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(1, ourUpdatedObservations); Assert.assertFalse(subscription1.getId().equals(subscription2.getId())); Assert.assertFalse(observation1.getId().isEmpty()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/RestHookTestWithInterceptorRegisteredToDaoConfigDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/RestHookTestWithInterceptorRegisteredToDaoConfigDstu3Test.java index 514dd794074..08155fa6a2e 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/RestHookTestWithInterceptorRegisteredToDaoConfigDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/RestHookTestWithInterceptorRegisteredToDaoConfigDstu3Test.java @@ -121,8 +121,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu3Test extends B // Should see 1 subscription notification Thread.sleep(500); - assertEquals(1, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(1, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Subscription subscriptionTemp = ourClient.read(Subscription.class, subscription2.getId()); Assert.assertNotNull(subscriptionTemp); @@ -135,8 +135,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu3Test extends B // Should see two subscription notifications Thread.sleep(500); - assertEquals(3, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(3, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); ourClient.delete().resourceById(new IdDt("Subscription", subscription2.getId())).execute(); @@ -144,8 +144,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu3Test extends B // Should see only one subscription notification Thread.sleep(500); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3 = ourClient.read(Observation.class, observationTemp3.getId()); CodeableConcept codeableConcept = new CodeableConcept(); @@ -157,8 +157,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu3Test extends B // Should see no subscription notification Thread.sleep(500); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3a = ourClient.read(Observation.class, observationTemp3.getId()); @@ -171,8 +171,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu3Test extends B // Should see only one subscription notification Thread.sleep(500); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(1, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(1, ourUpdatedObservations); Assert.assertFalse(subscription1.getId().equals(subscription2.getId())); Assert.assertFalse(observation1.getId().isEmpty()); @@ -194,8 +194,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu3Test extends B // Should see 1 subscription notification waitForQueueToDrain(); - assertEquals(1, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(1, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Subscription subscriptionTemp = ourClient.read(Subscription.class, subscription2.getId()); Assert.assertNotNull(subscriptionTemp); @@ -208,8 +208,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu3Test extends B // Should see two subscription notifications waitForQueueToDrain(); - assertEquals(3, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(3, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); ourClient.delete().resourceById(new IdDt("Subscription", subscription2.getId())).execute(); @@ -217,8 +217,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu3Test extends B // Should see only one subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3 = ourClient.read(Observation.class, observationTemp3.getId()); CodeableConcept codeableConcept = new CodeableConcept(); @@ -230,8 +230,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu3Test extends B // Should see no subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3a = ourClient.read(Observation.class, observationTemp3.getId()); @@ -244,8 +244,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu3Test extends B // Should see only one subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(1, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(1, ourUpdatedObservations); Assert.assertFalse(subscription1.getId().equals(subscription2.getId())); Assert.assertFalse(observation1.getId().isEmpty()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/r4/RestHookTestR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/r4/RestHookTestR4Test.java index a3f3c274fc2..a8847426de0 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/r4/RestHookTestR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/r4/RestHookTestR4Test.java @@ -126,8 +126,8 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test { // Should see 1 subscription notification waitForQueueToDrain(); - assertEquals(1, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(1, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); assertEquals(Constants.CT_FHIR_JSON_NEW, ourContentTypes.get(0)); } @@ -146,8 +146,8 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test { // Should see 1 subscription notification waitForQueueToDrain(); - assertEquals(1, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(1, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); assertEquals(Constants.CT_FHIR_JSON_NEW, ourContentTypes.get(0)); Subscription subscriptionTemp = ourClient.read(Subscription.class, subscription2.getId()); @@ -161,8 +161,8 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test { waitForQueueToDrain(); // Should see two subscription notifications - assertEquals(3, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(3, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); ourClient.delete().resourceById(new IdType("Subscription/" + subscription2.getId())).execute(); waitForQueueToDrain(); @@ -171,8 +171,8 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test { waitForQueueToDrain(); // Should see only one subscription notification - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3 = ourClient.read(Observation.class, observationTemp3.getId()); CodeableConcept codeableConcept = new CodeableConcept(); @@ -184,8 +184,8 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test { // Should see no subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3a = ourClient.read(Observation.class, observationTemp3.getId()); @@ -198,8 +198,8 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test { // Should see only one subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(1, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(1, ourUpdatedObservations); Assert.assertFalse(subscription1.getId().equals(subscription2.getId())); Assert.assertFalse(observation1.getId().isEmpty()); @@ -221,8 +221,8 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test { // Should see 1 subscription notification waitForQueueToDrain(); - assertEquals(1, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(1, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); assertEquals(Constants.CT_FHIR_XML_NEW, ourContentTypes.get(0)); Subscription subscriptionTemp = ourClient.read(Subscription.class, subscription2.getId()); @@ -235,8 +235,8 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test { waitForQueueToDrain(); // Should see two subscription notifications - assertEquals(3, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(3, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); ourClient.delete().resourceById(new IdType("Subscription/" + subscription2.getId())).execute(); @@ -244,8 +244,8 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test { // Should see only one subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3 = ourClient.read(Observation.class, observationTemp3.getId()); CodeableConcept codeableConcept = new CodeableConcept(); @@ -257,8 +257,8 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test { // Should see no subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3a = ourClient.read(Observation.class, observationTemp3.getId()); @@ -271,8 +271,8 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test { // Should see only one subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(1, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(1, ourUpdatedObservations); Assert.assertFalse(subscription1.getId().equals(subscription2.getId())); Assert.assertFalse(observation1.getId().isEmpty()); @@ -294,8 +294,8 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test { // Should see 1 subscription notification waitForQueueToDrain(); - assertEquals(1, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(1, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); assertEquals(Constants.CT_FHIR_XML_NEW, ourContentTypes.get(0)); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/r4/RestHookTestWithInterceptorRegisteredToDaoConfigR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/r4/RestHookTestWithInterceptorRegisteredToDaoConfigR4Test.java index 677265d67c8..6f834191403 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/r4/RestHookTestWithInterceptorRegisteredToDaoConfigR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/r4/RestHookTestWithInterceptorRegisteredToDaoConfigR4Test.java @@ -126,8 +126,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigR4Test extends Base // Should see 1 subscription notification Thread.sleep(500); - assertEquals(1, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(1, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Subscription subscriptionTemp = ourClient.read(Subscription.class, subscription2.getId()); Assert.assertNotNull(subscriptionTemp); @@ -140,8 +140,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigR4Test extends Base // Should see two subscription notifications Thread.sleep(500); - assertEquals(3, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(3, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); ourClient.delete().resourceById(new IdDt("Subscription", subscription2.getId())).execute(); @@ -149,8 +149,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigR4Test extends Base // Should see only one subscription notification Thread.sleep(500); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3 = ourClient.read(Observation.class, observationTemp3.getId()); CodeableConcept codeableConcept = new CodeableConcept(); @@ -162,8 +162,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigR4Test extends Base // Should see no subscription notification Thread.sleep(500); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3a = ourClient.read(Observation.class, observationTemp3.getId()); @@ -176,8 +176,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigR4Test extends Base // Should see only one subscription notification Thread.sleep(500); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(1, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(1, ourUpdatedObservations); Assert.assertFalse(subscription1.getId().equals(subscription2.getId())); Assert.assertFalse(observation1.getId().isEmpty()); @@ -199,8 +199,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigR4Test extends Base // Should see 1 subscription notification waitForQueueToDrain(); - assertEquals(1, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(1, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Subscription subscriptionTemp = ourClient.read(Subscription.class, subscription2.getId()); Assert.assertNotNull(subscriptionTemp); @@ -213,8 +213,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigR4Test extends Base // Should see two subscription notifications waitForQueueToDrain(); - assertEquals(3, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(3, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); ourClient.delete().resourceById(new IdDt("Subscription", subscription2.getId())).execute(); @@ -222,8 +222,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigR4Test extends Base // Should see only one subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3 = ourClient.read(Observation.class, observationTemp3.getId()); CodeableConcept codeableConcept = new CodeableConcept(); @@ -235,8 +235,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigR4Test extends Base // Should see no subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(0, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(0, ourUpdatedObservations); Observation observation3a = ourClient.read(Observation.class, observationTemp3.getId()); @@ -249,8 +249,8 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigR4Test extends Base // Should see only one subscription notification waitForQueueToDrain(); - assertEquals(4, ourCreatedObservations.size()); - assertEquals(1, ourUpdatedObservations.size()); + waitForSize(4, ourCreatedObservations); + waitForSize(1, ourUpdatedObservations); Assert.assertFalse(subscription1.getId().equals(subscription2.getId())); Assert.assertFalse(observation1.getId().isEmpty());