Merge branch 'subscription_cleanup' of github.com:jamesagnew/hapi-fhir into subscription_cleanup

This commit is contained in:
jamesagnew 2018-08-11 13:47:05 -04:00
commit e10d47ecc5
6 changed files with 57 additions and 7 deletions

View File

@ -177,10 +177,13 @@ public class SubscriptionActivatingSubscriber {
}
private void registerSubscriptionUnlessAlreadyRegistered(IBaseResource theSubscription) {
if (!mySubscriptionInterceptor.hasSubscription(theSubscription.getIdElement())) {
if (mySubscriptionInterceptor.hasSubscription(theSubscription.getIdElement())) {
ourLog.info("Updating already-registered active subscription {}", theSubscription.getIdElement().toUnqualified().getValue());
mySubscriptionInterceptor.unregisterSubscription(theSubscription.getIdElement());
} else {
ourLog.info("Registering active subscription {}", theSubscription.getIdElement().toUnqualified().getValue());
mySubscriptionInterceptor.registerSubscription(theSubscription.getIdElement(), theSubscription);
}
mySubscriptionInterceptor.registerSubscription(theSubscription.getIdElement(), theSubscription);
}
@VisibleForTesting

View File

@ -105,7 +105,7 @@ public class TestR4Config extends BaseJavaConfigR4 {
DataSource dataSource = ProxyDataSourceBuilder
.create(retVal)
.logQueryBySlf4j(SLF4JLogLevel.INFO, "SQL")
// .logQueryBySlf4j(SLF4JLogLevel.INFO, "SQL")
.logSlowQueryBySlf4j(10, TimeUnit.SECONDS)
.countQuery(new ThreadQueryCountHolder())
.build();

View File

@ -355,6 +355,53 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test {
Assert.assertFalse(observation2.getId().isEmpty());
}
@Test
public void testUpdateSubscriptionToMatchLater() throws Exception {
String payload = "application/xml";
String code = "1000000050";
String criteriaBad = "Observation?code=SNOMED-CT|" + code + "111&_format=xml";
ourLog.info("** About to create non-matching subscription");
Subscription subscription2 = createSubscription(criteriaBad, payload, ourListenerServerBase);
ourLog.info("** About to send observation that wont match");
Observation observation1 = sendObservation(code, "SNOMED-CT");
// Criteria didn't match, shouldn't see any updates
waitForQueueToDrain();
Thread.sleep(1000);
assertEquals(0, ourUpdatedObservations.size());
Subscription subscriptionTemp = myClient.read().resource(Subscription.class).withId(subscription2.getId()).execute();
Assert.assertNotNull(subscriptionTemp);
String criteriaGood = "Observation?code=SNOMED-CT|" + code + "&_format=xml";
subscriptionTemp.setCriteria(criteriaGood);
ourLog.info("** About to update subscription");
myClient.update().resource(subscriptionTemp).withId(subscriptionTemp.getIdElement()).execute();
waitForQueueToDrain();
ourLog.info("** About to send Observation 2");
Observation observation2 = sendObservation(code, "SNOMED-CT");
waitForQueueToDrain();
// Should see a subscription notification this time
waitForSize(0, ourCreatedObservations);
waitForSize(1, ourUpdatedObservations);
myClient.delete().resourceById(new IdType("Subscription/" + subscription2.getId())).execute();
Observation observationTemp3 = sendObservation(code, "SNOMED-CT");
// No more matches
Thread.sleep(1000);
assertEquals(1, ourUpdatedObservations.size());
}
@Test
public void testRestHookSubscriptionApplicationXmlJson() throws Exception {
String payload = "application/fhir+xml";

View File

@ -17,8 +17,8 @@
<properties>
<features.file>features.xml</features.file>
<pax-logging-version>1.8.6</pax-logging-version>
<felix-framework-version>3.2.2</felix-framework-version>
<pax-logging-version>1.10.1</pax-logging-version>
<felix-framework-version>6.0.0</felix-framework-version>
</properties>
<dependencies>

View File

@ -33,7 +33,7 @@
</description>
<properties>
<pax.exam.version>4.9.1</pax.exam.version>
<pax.exam.version>4.12.0</pax.exam.version>
</properties>
<dependencies>

View File

@ -489,7 +489,7 @@
<!-- Dependency Versions -->
<activation_api_version>1.2.0</activation_api_version>
<apache_karaf_version>4.1.4</apache_karaf_version>
<apache_karaf_version>4.2.0</apache_karaf_version>
<aries_spifly_version>1.0.10</aries_spifly_version>
<caffeine_version>2.6.2</caffeine_version>
<commons_codec_version>1.11</commons_codec_version>