diff --git a/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/matcher/InMemoryResourceMatcherConfigurationR5Test.java b/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/matcher/InMemoryResourceMatcherConfigurationR5Test.java index 1bc0dd727fdb..011fa0b63ad7 100644 --- a/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/matcher/InMemoryResourceMatcherConfigurationR5Test.java +++ b/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/matcher/InMemoryResourceMatcherConfigurationR5Test.java @@ -8,6 +8,7 @@ import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamToken; import ca.uhn.fhir.jpa.model.entity.StorageSettings; import ca.uhn.fhir.jpa.searchparam.MatchUrlService; +import ca.uhn.fhir.jpa.searchparam.extractor.ISearchParamExtractor; import ca.uhn.fhir.jpa.searchparam.extractor.ResourceIndexedSearchParams; import ca.uhn.fhir.jpa.searchparam.extractor.SearchParamExtractorR5; import ca.uhn.fhir.jpa.searchparam.extractor.SearchParamExtractorService; @@ -123,7 +124,7 @@ PartitionSettings partitionSettings() { } @Bean - SearchParamExtractorR5 searchParamExtractorR5() { + ISearchParamExtractor searchParamExtractorR5() { return new SearchParamExtractorR5(); } diff --git a/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/registry/SearchParamRegistryImplTest.java b/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/registry/SearchParamRegistryImplTest.java index f379779f42dd..cd4783fda5a6 100644 --- a/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/registry/SearchParamRegistryImplTest.java +++ b/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/registry/SearchParamRegistryImplTest.java @@ -12,9 +12,12 @@ import ca.uhn.fhir.jpa.cache.ResourceChangeResult; import ca.uhn.fhir.jpa.cache.ResourceVersionMap; import ca.uhn.fhir.jpa.cache.config.RegisteredResourceListenerFactoryConfig; +import ca.uhn.fhir.jpa.model.config.PartitionSettings; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.model.entity.StorageSettings; import ca.uhn.fhir.jpa.searchparam.MatchUrlService; +import ca.uhn.fhir.jpa.searchparam.extractor.ISearchParamExtractor; +import ca.uhn.fhir.jpa.searchparam.extractor.SearchParamExtractorR4; import ca.uhn.fhir.jpa.searchparam.extractor.SearchParamExtractorService; import ca.uhn.fhir.jpa.searchparam.matcher.InMemoryMatchResult; import ca.uhn.fhir.jpa.searchparam.matcher.InMemoryResourceMatcher; @@ -375,6 +378,17 @@ private SearchParameter buildSearchParameter(Enumerations.PublicationStatus theS @Configuration @Import(RegisteredResourceListenerFactoryConfig.class) static class SpringConfig { + + @Bean + PartitionSettings partitionSettings() { + return new PartitionSettings(); + } + + @Bean + ISearchParamExtractor searchParamExtractorR5() { + return new SearchParamExtractorR4(); + } + @Bean FhirContext fhirContext() { return ourFhirContext; diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcherR3Test.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcherR3Test.java index 80057404860c..08b22b089e0e 100644 --- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcherR3Test.java +++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcherR3Test.java @@ -49,6 +49,11 @@ public class InMemorySubscriptionMatcherR3Test extends BaseSubscriptionDstu3Test @Autowired StorageSettings myStorageSettings; + private void assertSupported(IBaseResource resource, String criteria) { + assertTrue(mySearchParamMatcher.match(criteria, resource, null).supported()); + assertEquals(SubscriptionMatchingStrategy.IN_MEMORY, mySubscriptionStrategyEvaluator.determineStrategy(criteria)); + } + private void assertUnsupported(IBaseResource resource, String criteria) { assertFalse(mySearchParamMatcher.match(criteria, resource, null).supported()); assertEquals(SubscriptionMatchingStrategy.DATABASE, mySubscriptionStrategyEvaluator.determineStrategy(criteria)); @@ -185,17 +190,17 @@ public void testProcedureRequest() { } @Test - public void testObservationContextTypeUnsupported() { + public void testObservationContextTypeSupported() { String criteria = "Observation?code=17861-6&context.type=IHD"; { Observation obs = new Observation(); obs.getCode().addCoding().setCode("XXX"); - assertNotMatched(obs, criteria, SubscriptionMatchingStrategy.DATABASE); + assertNotMatched(obs, criteria, SubscriptionMatchingStrategy.IN_MEMORY); } { Observation obs = new Observation(); obs.getCode().addCoding().setCode("17861-6"); - assertUnsupported(obs, criteria); + assertSupported(obs, criteria); } } @@ -206,12 +211,12 @@ public void testObservationContextTypeUnsupportedReverse() { { Observation obs = new Observation(); obs.getCode().addCoding().setCode("XXX"); - assertNotMatched(obs, criteria, SubscriptionMatchingStrategy.DATABASE); + assertNotMatched(obs, criteria, SubscriptionMatchingStrategy.IN_MEMORY); } { Observation obs = new Observation(); obs.getCode().addCoding().setCode("17861-6"); - assertUnsupported(obs, criteria); + assertSupported(obs, criteria); } } @@ -299,12 +304,12 @@ public void testBloodTest() { { Observation obs = new Observation(); obs.getCode().addCoding().setCode("FR_Org1Blood2nd"); - assertUnsupported(obs, criteria); + assertSupported(obs, criteria); } { Observation obs = new Observation(); obs.getCode().addCoding().setCode("XXX"); - assertNotMatched(obs, criteria, SubscriptionMatchingStrategy.DATABASE); + assertNotMatched(obs, criteria, SubscriptionMatchingStrategy.IN_MEMORY); } } diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/SubscriptionStrategyEvaluatorTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/SubscriptionStrategyEvaluatorTest.java index 500613fdee22..8fc0833c8548 100644 --- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/SubscriptionStrategyEvaluatorTest.java +++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/SubscriptionStrategyEvaluatorTest.java @@ -24,7 +24,7 @@ public void testInMemory() { assertInMemory("ProcedureRequest?intent=original-order"); assertInMemory("MedicationRequest?intent=instance-order&category=outpatient&date==2018-10-19"); assertInMemory("MedicationRequest?intent=plan&category=outpatient&status=suspended,entered-in-error,cancelled,stopped"); - assertDatabase("Observation?code=FR_Org1Blood2nd,FR_Org1Blood3rd,FR_Org%201BldCult,FR_Org2Blood2nd,FR_Org2Blood3rd,FR_Org%202BldCult,FR_Org3Blood2nd,FR_Org3Blood3rd,FR_Org3BldCult,FR_Org4Blood2nd,FR_Org4Blood3rd,FR_Org4BldCult,FR_Org5Blood2nd,FR_Org5Blood3rd,FR_Org%205BldCult,FR_Org6Blood2nd,FR_Org6Blood3rd,FR_Org6BldCult,FR_Org7Blood2nd,FR_Org7Blood3rd,FR_Org7BldCult,FR_Org8Blood2nd,FR_Org8Blood3rd,FR_Org8BldCult,FR_Org9Blood2nd,FR_Org9Blood3rd,FR_Org9BldCult,FR_Bld2ndCulture,FR_Bld3rdCulture,FR_Blood%20Culture,FR_Com1Bld3rd,FR_Com1BldCult,FR_Com2Bld2nd,FR_Com2Bld3rd,FR_Com2BldCult,FR_CultureBld2nd,FR_CultureBld3rd,FR_CultureBldCul,FR_GmStainBldCul,FR_GramStain2Bld,FR_GramStain3Bld,FR_GramStNegBac&context.type=IHD"); + assertInMemory("Observation?code=FR_Org1Blood2nd,FR_Org1Blood3rd,FR_Org%201BldCult,FR_Org2Blood2nd,FR_Org2Blood3rd,FR_Org%202BldCult,FR_Org3Blood2nd,FR_Org3Blood3rd,FR_Org3BldCult,FR_Org4Blood2nd,FR_Org4Blood3rd,FR_Org4BldCult,FR_Org5Blood2nd,FR_Org5Blood3rd,FR_Org%205BldCult,FR_Org6Blood2nd,FR_Org6Blood3rd,FR_Org6BldCult,FR_Org7Blood2nd,FR_Org7Blood3rd,FR_Org7BldCult,FR_Org8Blood2nd,FR_Org8Blood3rd,FR_Org8BldCult,FR_Org9Blood2nd,FR_Org9Blood3rd,FR_Org9BldCult,FR_Bld2ndCulture,FR_Bld3rdCulture,FR_Blood%20Culture,FR_Com1Bld3rd,FR_Com1BldCult,FR_Com2Bld2nd,FR_Com2Bld3rd,FR_Com2BldCult,FR_CultureBld2nd,FR_CultureBld3rd,FR_CultureBldCul,FR_GmStainBldCul,FR_GramStain2Bld,FR_GramStain3Bld,FR_GramStNegBac&context.type=IHD"); assertInMemory("Procedure?category=Hemodialysis"); assertInMemory("Procedure?code=HD_Standard&status=completed&location=Lab123"); assertInMemory("Procedure?code=HD_Standard&status=completed"); @@ -33,8 +33,8 @@ public void testInMemory() { assertInMemory("Observation?code=111111111&_format=xml"); assertInMemory("Observation?code=SNOMED-CT|123&_format=xml"); - assertDatabase("Observation?code=17861-6&context.type=IHD"); - assertDatabase("Observation?context.type=IHD&code=17861-6"); + assertInMemory("Observation?code=17861-6&context.type=IHD"); + assertInMemory("Observation?context.type=IHD&code=17861-6"); try { mySubscriptionStrategyEvaluator.determineStrategy("Observation?codeee=SNOMED-CT|123&_format=xml"); diff --git a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestDstu3Test.java b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestDstu3Test.java index d51da5ada5c7..d5dd71538364 100644 --- a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestDstu3Test.java +++ b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestDstu3Test.java @@ -201,7 +201,7 @@ public void testDatabaseStrategyMeta() throws InterruptedException { Subscription subscription = createSubscription(databaseCriteria, null, ourNotificationListenerServer); List tag = subscription.getMeta().getTag(); assertEquals(HapiExtensions.EXT_SUBSCRIPTION_MATCHING_STRATEGY, tag.get(0).getSystem()); - assertEquals(SubscriptionMatchingStrategy.DATABASE.toString(), tag.get(0).getCode()); + assertEquals(SubscriptionMatchingStrategy.IN_MEMORY.toString(), tag.get(0).getCode()); } @Test @@ -607,8 +607,8 @@ public void testSubscriptionActivatesDatabaseTag() throws Exception { assertThat(tags).hasSize(1); Coding tag = tags.get(0); assertEquals(HapiExtensions.EXT_SUBSCRIPTION_MATCHING_STRATEGY, tag.getSystem()); - assertEquals(SubscriptionMatchingStrategy.DATABASE.toString(), tag.getCode()); - assertEquals("Database", tag.getDisplay()); + assertEquals(SubscriptionMatchingStrategy.IN_MEMORY.toString(), tag.getCode()); + assertEquals("In-memory", tag.getDisplay()); // Wait for subscription to be moved to active await().until(() -> Subscription.SubscriptionStatus.ACTIVE.equals(myClient.read().resource(Subscription.class).withId(subscriptionId.toUnqualifiedVersionless()).execute().getStatus())); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportTest.java index 880d2bc4491e..9f537f13c5c6 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportTest.java @@ -1183,19 +1183,16 @@ public void testValidateParameters_InvalidPostFetch_InvalidResourceType() { } @Test - public void testValidateParameters_InvalidPostFetch_UnsupportedParam() { + public void testValidateParameters_ValidPostFetch_SupportedParam() { // Setup final BulkExportJobParameters options = createOptionsWithPostFetchFilterUrl("Observation?subject.identifier=blah"); // Test try { startNewJob(options); - fail(); } catch (InvalidRequestException e) { - - // Verify - assertThat(e.getMessage()).contains("Chained parameters are not supported"); - + // Fail + fail(); } } diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcherR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcherR4Test.java index 549a820f3f47..e33c7148d658 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcherR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/subscription/module/matcher/InMemorySubscriptionMatcherR4Test.java @@ -144,6 +144,12 @@ private InMemoryMatchResult match(String criteria, Resource theResource) { return mySearchParamMatcher.match(criteria, theResource, null); } + private void assertSupported(Resource resource, SearchParameterMap theParams) { + InMemoryMatchResult result = match(resource, theParams); + assertTrue(result.supported()); + assertEquals(SubscriptionMatchingStrategy.IN_MEMORY, mySubscriptionStrategyEvaluator.determineStrategy(getCriteria(resource, theParams))); + } + private void assertUnsupported(Resource resource, SearchParameterMap theParams) { InMemoryMatchResult result = match(resource, theParams); assertFalse(result.supported()); @@ -155,7 +161,7 @@ private void assertUnsupported(Resource resource, SearchParameterMap theParams) */ @Test - public void testChainReferenceUnsupported() { + public void testChainReferenceSupported() { Encounter enc1 = new Encounter(); IIdType pid1 = new IdType("Patient", 1L); enc1.getSubject().setReference(pid1.getValue()); @@ -164,7 +170,7 @@ public void testChainReferenceUnsupported() { map = new SearchParameterMap(); map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject", "foo|bar").setChain("identifier")); - assertUnsupported(enc1, map); + assertSupported(enc1, map); MedicationAdministration ma = new MedicationAdministration(); IIdType mid1 = new IdType("Medication", 1L); @@ -172,7 +178,7 @@ public void testChainReferenceUnsupported() { map = new SearchParameterMap(); map.add(MedicationAdministration.SP_MEDICATION, new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam("code", "04823543")))); - assertUnsupported(ma, map); + assertSupported(ma, map); } @Test @@ -597,7 +603,7 @@ public void testSearchResourceLinkWithChainUnsupported() { obs02.setSubject(new Reference(patientId02)); SearchParameterMap params = new SearchParameterMap().add(Observation.SP_SUBJECT, new ReferenceParam(Patient.SP_IDENTIFIER, "urn:system|testSearchResourceLinkWithChain01")); - assertUnsupported(obs01, params); + assertSupported(obs01, params); } @Test