From 631391819b8f67305c37ef163cc1f033c3486d5a Mon Sep 17 00:00:00 2001 From: Ken Stevens Date: Wed, 16 Feb 2022 20:44:03 -0500 Subject: [PATCH] remove hapi jpa spring config hierarchy (#3390) * initial refactor to remove hapi jpa spring config hierarchy * fix poms * fix batch config * dependency rearrangement arising from further testing * fix searchDao bean name * fixed dstu2 tests * consolidate validation config * dstu2 validation regression (man dstu2 support is expensive) * fix test (with WIP comment) * restore poms * fix demo projects * fix build * bumping version * rename generated config class --- hapi-deployable-pom/pom.xml | 2 +- hapi-fhir-android/pom.xml | 2 +- hapi-fhir-base/pom.xml | 2 +- .../fhir/rest/api/IResourceSupportedSvc.java | 5 + hapi-fhir-batch/pom.xml | 2 +- hapi-fhir-bom/pom.xml | 4 +- hapi-fhir-checkstyle/pom.xml | 2 +- hapi-fhir-cli/hapi-fhir-cli-api/pom.xml | 2 +- hapi-fhir-cli/hapi-fhir-cli-app/pom.xml | 2 +- hapi-fhir-cli/hapi-fhir-cli-jpaserver/pom.xml | 2 +- .../uhn/fhir/jpa/demo/FhirServerConfig.java | 20 +- .../fhir/jpa/demo/FhirServerConfigDstu3.java | 21 +- .../uhn/fhir/jpa/demo/FhirServerConfigR4.java | 19 +- .../ca/uhn/fhir/jpa/demo/JpaServerDemo.java | 12 +- hapi-fhir-cli/pom.xml | 2 +- hapi-fhir-client-okhttp/pom.xml | 2 +- hapi-fhir-client/pom.xml | 2 +- hapi-fhir-converter/pom.xml | 2 +- hapi-fhir-dist/pom.xml | 2 +- hapi-fhir-docs/pom.xml | 2 +- hapi-fhir-jacoco/pom.xml | 2 +- hapi-fhir-jaxrsserver-base/pom.xml | 2 +- hapi-fhir-jpa/pom.xml | 2 +- hapi-fhir-jpaserver-base/pom.xml | 16 +- .../uhn/fhir/jpa/batch/BatchJobsConfig.java | 34 ++- .../fhir/jpa/config/BaseConfigDstu3Plus.java | 126 --------- .../uhn/fhir/jpa/config/BaseDstu2Config.java | 155 ----------- .../fhir/jpa/config/BatchJobRegisterer.java | 1 - .../jpa/config/BeanPostProcessorConfig.java | 20 ++ .../jpa/config/FhirContextDstu2Config.java | 13 + .../config/HapiFhirHibernateJpaDialect.java | 2 +- .../ca/uhn/fhir/jpa/config/HapiJpaConfig.java | 62 +++++ .../config/HibernatePropertiesProvider.java | 2 +- .../{BaseConfig.java => JpaConfig.java} | 150 +---------- .../uhn/fhir/jpa/config/JpaDstu2Config.java | 67 +++++ .../jpa/config/SharedConfigDstu3Plus.java | 57 ++++ .../jpa/config/ValidationSupportConfig.java | 67 +++++ .../config/dstu3/FhirContextDstu3Config.java | 20 ++ ...seDstu3Config.java => JpaDstu3Config.java} | 67 ++--- .../jpa/config/r4/FhirContextR4Config.java | 20 ++ .../{BaseR4Config.java => JpaR4Config.java} | 144 +++++------ .../jpa/config/r5/FhirContextR5Config.java | 20 ++ .../{BaseR5Config.java => JpaR5Config.java} | 68 ++--- .../util/HapiEntityManagerFactoryUtil.java | 28 ++ .../config/util/ResourceCountCacheUtil.java | 14 + .../util/ValidationSupportConfigUtil.java | 16 ++ .../fhir/jpa/dao/BaseHapiFhirSystemDao.java | 11 +- .../jpa/dao/FhirResourceDaoValueSetDstu2.java | 19 +- .../fhir/jpa/dao/HistoryBuilderFactory.java | 4 +- .../fhir/jpa/dao/SearchBuilderFactory.java | 4 +- .../provider/ValueSetOperationProvider.java | 4 +- .../BaseJpaResourceProviderCodeSystemR4.java | 6 +- .../PersistedJpaBundleProviderFactory.java | 8 +- .../uhn/fhir/jpa/term/TermReadSvcDstu2.java | 2 +- .../jpa/bulk/BulkDataExportSvcImplR4Test.java | 2 +- .../bulk/imprt/svc/BulkDataImportR4Test.java | 4 +- .../uhn/fhir/jpa/config/TestDstu2Config.java | 20 +- .../uhn/fhir/jpa/config/TestDstu3Config.java | 26 +- .../TestHibernateSearchAddInConfig.java | 10 +- .../ca/uhn/fhir/jpa/config/TestR4Config.java | 38 ++- .../ca/uhn/fhir/jpa/config/TestR5Config.java | 26 +- .../java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java | 10 +- .../jpa/dao/dstu2/BaseJpaDstu2SystemTest.java | 4 +- .../fhir/jpa/dao/dstu2/BaseJpaDstu2Test.java | 12 +- .../FhirResourceDaoDstu2SearchNoFtTest.java | 47 +++- .../dao/dstu2/FhirResourceDaoDstu2Test.java | 18 +- .../FhirResourceDaoDstu2ValidateTest.java | 22 +- .../FhirResourceDaoValueSetDstu2Test.java | 10 +- .../jpa/dao/dstu2/FhirSystemDaoDstu2Test.java | 67 ++--- .../jpa/dao/dstu3/BaseJpaDstu3SystemTest.java | 2 +- .../fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java | 12 +- .../FhirResourceDaoCustomTypeDstu3Test.java | 6 +- .../FhirResourceDaoDocumentDstu3Test.java | 4 +- .../FhirResourceDaoDstu3CodeSystemTest.java | 2 +- .../FhirResourceDaoDstu3ConceptMapTest.java | 4 +- .../FhirResourceDaoDstu3ContainedTest.java | 2 +- ...esourceDaoDstu3PhoneticSearchNoFtTest.java | 4 +- ...ceDaoDstu3SearchCustomSearchParamTest.java | 31 ++- ...hirResourceDaoDstu3SearchDistanceTest.java | 8 +- .../FhirResourceDaoDstu3SearchNoFtTest.java | 12 +- ...sourceDaoDstu3StructureDefinitionTest.java | 4 +- .../FhirResourceDaoDstu3TerminologyTest.java | 8 +- .../dao/dstu3/FhirResourceDaoDstu3Test.java | 21 +- .../FhirResourceDaoDstu3ValidateTest.java | 80 +++--- .../FhirResourceDaoDstu3ValueSetTest.java | 10 +- .../jpa/dao/dstu3/FhirSystemDaoDstu3Test.java | 124 ++++----- .../jpa/dao/expunge/DeleteExpungeDaoTest.java | 2 +- .../fhir/jpa/dao/r4/BaseJpaR4SystemTest.java | 2 +- .../ca/uhn/fhir/jpa/dao/r4/BaseJpaR4Test.java | 24 +- .../fhir/jpa/dao/r4/BaseR4SearchLastN.java | 2 +- .../fhir/jpa/dao/r4/ChainingR4SearchTest.java | 2 +- ...irResourceDaoCreatePlaceholdersR4Test.java | 55 ++-- .../r4/FhirResourceDaoCustomTypeR4Test.java | 6 +- .../dao/r4/FhirResourceDaoDocumentR4Test.java | 4 +- .../r4/FhirResourceDaoR4CodeSystemTest.java | 2 +- ...FhirResourceDaoR4ComboUniqueParamTest.java | 8 +- .../r4/FhirResourceDaoR4ConceptMapTest.java | 42 +-- .../FhirResourceDaoR4ConcurrentWriteTest.java | 28 +- .../r4/FhirResourceDaoR4ContainedTest.java | 17 +- .../dao/r4/FhirResourceDaoR4CreateTest.java | 29 +-- .../dao/r4/FhirResourceDaoR4DeleteTest.java | 9 +- .../r4/FhirResourceDaoR4InterceptorTest.java | 6 +- ...rResourceDaoR4LegacySearchBuilderTest.java | 42 +-- ...rceDaoR4LuceneDisabledStandardQueries.java | 2 +- .../jpa/dao/r4/FhirResourceDaoR4MetaTest.java | 41 ++- .../r4/FhirResourceDaoR4QueryCountTest.java | 95 ++++--- ...ourceDaoR4SearchCustomSearchParamTest.java | 18 +- .../FhirResourceDaoR4SearchDistanceTest.java | 16 +- .../r4/FhirResourceDaoR4SearchNoFtTest.java | 48 ++-- .../FhirResourceDaoR4SearchNoHashesTest.java | 10 +- .../FhirResourceDaoR4SearchOptimizedTest.java | 2 +- .../r4/FhirResourceDaoR4SearchSqlTest.java | 4 +- ...esourceDaoR4SearchWithElasticSearchIT.java | 2 +- ...urceDaoR4SearchWithLuceneDisabledTest.java | 6 +- ...rResourceDaoR4StructureDefinitionTest.java | 12 +- .../jpa/dao/r4/FhirResourceDaoR4TagsTest.java | 10 +- ...sourceDaoR4TerminologyElasticsearchIT.java | 2 +- .../r4/FhirResourceDaoR4TerminologyTest.java | 8 +- .../jpa/dao/r4/FhirResourceDaoR4Test.java | 36 ++- .../dao/r4/FhirResourceDaoR4ValidateTest.java | 132 +++++----- .../dao/r4/FhirResourceDaoR4ValueSetTest.java | 6 +- ...irResourceDaoR4VersionedReferenceTest.java | 72 +++--- .../dao/r4/FhirResourceDaoSearchListTest.java | 2 +- .../fhir/jpa/dao/r4/FhirSystemDaoR4Test.java | 152 +++++------ .../uhn/fhir/jpa/dao/r4/JpaHistoryR4Test.java | 2 +- .../jpa/dao/r4/PartitioningSqlR4Test.java | 12 +- .../uhn/fhir/jpa/dao/r4/SyntheaPerfTest.java | 10 +- .../uhn/fhir/jpa/dao/r4/TestContextLoads.java | 14 + .../ca/uhn/fhir/jpa/dao/r5/BaseJpaR5Test.java | 6 - .../fhir/jpa/delete/job/ReindexJobTest.java | 2 +- .../CascadingDeleteInterceptorTest.java | 6 +- .../PatientIdPartitionInterceptorTest.java | 6 +- ...sitoryValidatingInterceptorHttpR4Test.java | 4 +- ...RepositoryValidatingInterceptorR4Test.java | 8 +- ...tionMessageSuppressingInterceptorTest.java | 10 +- .../jpa/packages/JpaPackageCacheTest.java | 4 +- .../uhn/fhir/jpa/packages/NpmDstu3Test.java | 2 +- .../ca/uhn/fhir/jpa/packages/NpmR4Test.java | 10 +- .../BaseResourceProviderDstu2Test.java | 13 +- .../provider/ResourceProviderDstu2Test.java | 200 +++++++------- .../ResourceProviderDstu2ValueSetTest.java | 18 +- .../jpa/provider/SubscriptionsDstu2Test.java | 8 +- .../jpa/provider/SystemProviderDstu2Test.java | 4 +- ...temProviderTransactionSearchDstu2Test.java | 12 +- .../dstu3/BaseResourceProviderDstu3Test.java | 16 +- .../dstu3/CompositionDocumentDstu3Test.java | 8 +- .../dstu3/PatientEverythingDstu3Test.java | 6 +- ...rceProviderCustomSearchParamDstu3Test.java | 8 +- .../ResourceProviderDstu3CodeSystemTest.java | 14 +- ...eProviderDstu3CodeSystemVersionedTest.java | 68 ++--- .../ResourceProviderDstu3ConceptMapTest.java | 65 +++-- .../dstu3/ResourceProviderDstu3Test.java | 169 ++++++------ .../ResourceProviderDstu3ValueSetTest.java | 56 ++-- ...rceProviderDstu3ValueSetVersionedTest.java | 132 +++++----- .../ResourceProviderExpungeDstu3Test.java | 2 +- ...ceProviderR3CodeSystemDesignationTest.java | 20 +- .../jpa/provider/dstu3/ServerDstu3Test.java | 2 +- .../dstu3/SubscriptionsDstu3Test.java | 4 +- ...temProviderTransactionSearchDstu3Test.java | 14 +- .../r4/AuthorizationInterceptorJpaR4Test.java | 20 +- ...zationInterceptorMultitenantJpaR4Test.java | 4 +- ...BaseMultitenantResourceProviderR4Test.java | 2 +- .../r4/BaseResourceProviderR4Test.java | 18 +- .../r4/BinaryAccessProviderR4Test.java | 26 +- .../r4/BinaryStorageInterceptorR4Test.java | 25 +- .../r4/CompositionDocumentR4Test.java | 19 +- ...sentInterceptorResourceProviderR4Test.java | 40 +-- .../jpa/provider/r4/DiffProviderR4Test.java | 14 +- .../fhir/jpa/provider/r4/ExpungeR4Test.java | 2 +- .../r4/MultitenantBatchOperationR4Test.java | 17 +- .../jpa/provider/r4/PatchProviderR4Test.java | 26 +- .../provider/r4/PatientEverythingR4Test.java | 33 ++- .../r4/PatientMemberMatchOperationR4Test.java | 18 +- .../r4/ResourceProviderConcurrencyR4Test.java | 6 +- ...sourceProviderCustomSearchParamR4Test.java | 8 +- .../r4/ResourceProviderExpungeR4Test.java | 8 +- .../r4/ResourceProviderHasParamR4Test.java | 59 +++-- .../r4/ResourceProviderInterceptorR4Test.java | 8 +- ...ceProviderQuestionnaireResponseR4Test.java | 60 +++-- .../r4/ResourceProviderR4BundleTest.java | 33 ++- .../r4/ResourceProviderR4CacheTest.java | 5 +- ...ceProviderR4CodeSystemDesignationTest.java | 28 +- .../r4/ResourceProviderR4CodeSystemTest.java | 70 ++--- ...urceProviderR4CodeSystemVersionedTest.java | 68 ++--- .../r4/ResourceProviderR4ConceptMapTest.java | 195 +++++++------- .../r4/ResourceProviderR4ElasticTest.java | 5 +- ...sourceProviderR4RemoteTerminologyTest.java | 10 +- ...ResourceProviderR4SearchContainedTest.java | 82 +++--- ...urceProviderR4StructureDefinitionTest.java | 4 +- .../provider/r4/ResourceProviderR4Test.java | 244 +++++++++--------- ...eProviderR4ValueSetLuceneDisabledTest.java | 2 +- ...rceProviderR4ValueSetNoVerCSNoVerTest.java | 92 +++---- ...ourceProviderR4ValueSetVerCSNoVerTest.java | 60 ++--- ...esourceProviderR4ValueSetVerCSVerTest.java | 151 ++++++----- .../ResourceProviderSearchModifierR4Test.java | 27 +- ...rCapabilityStatementProviderJpaR4Test.java | 7 +- .../fhir/jpa/provider/r4/ServerR4Test.java | 6 +- .../r4/StaleSearchDeletingSvcR4Test.java | 2 +- .../jpa/provider/r4/SubscriptionsR4Test.java | 5 +- .../jpa/provider/r4/SystemProviderR4Test.java | 18 +- ...SystemProviderTransactionSearchR4Test.java | 14 +- .../r4/TerminologyUploaderProviderR4Test.java | 24 +- .../PagingMultinodeProviderDstu3Test.java | 2 +- .../TokenAutocompleteElasticsearchIT.java | 2 +- .../r4/PagingMultinodeProviderR4Test.java | 21 +- .../ResourceReindexingSvcImplTest.java | 10 +- .../jpa/searchparam/MatchUrlServiceTest.java | 2 +- .../stresstest/GiantTransactionPerfTest.java | 31 +-- .../fhir/jpa/stresstest/StressTestR4Test.java | 15 +- .../subscription/BaseSubscriptionsR4Test.java | 2 +- .../resthook/RestHookTestDstu3Test.java | 4 +- .../resthook/RestHookTestR4Test.java | 4 +- .../term/TermConceptMappingSvcImplTest.java | 46 ++-- ...minologyLoaderSvcIntegrationDstu3Test.java | 20 +- .../jpa/term/TerminologySvcDeltaR4Test.java | 6 +- ...erminologySvcImplCurrentVersionR4Test.java | 6 +- .../jpa/term/TerminologySvcImplDstu3Test.java | 2 +- .../jpa/term/TerminologySvcImplR4Test.java | 20 +- .../ValueSetExpansionR4ElasticsearchIT.java | 2 +- .../jpa/term/ValueSetExpansionR4Test.java | 126 ++++----- .../util/jsonpatch/JsonPatchUtilsTest.java | 2 +- hapi-fhir-jpaserver-cql/pom.xml | 10 +- .../ca/uhn/fhir/cql/BaseCqlDstu3Test.java | 15 +- .../java/ca/uhn/fhir/cql/BaseCqlR4Test.java | 18 +- .../common/helper/TranslatorHelperTest.java | 3 +- .../common/provider/CqlProviderTestBase.java | 4 +- .../ca/uhn/fhir/cql/r4/CqlProviderR4Test.java | 1 - hapi-fhir-jpaserver-mdm/pom.xml | 10 +- .../ca/uhn/fhir/jpa/mdm/BaseMdmR4Test.java | 7 +- .../uhn/fhir/jpa/mdm/svc/MdmLinkSvcTest.java | 3 + hapi-fhir-jpaserver-model/pom.xml | 2 +- hapi-fhir-jpaserver-searchparam/pom.xml | 2 +- .../ResourceChangeListenerCacheFactory.java | 2 +- .../ResourceChangeListenerRegistryImpl.java | 25 +- .../searchparam/config/SearchParamConfig.java | 13 +- .../matcher/InMemoryResourceMatcher.java | 6 +- .../registry/SearchParamRegistryImpl.java | 10 +- .../ResourceChangeListenerCacheTest.java | 4 +- ...esourceChangeListenerRegistryImplTest.java | 9 +- .../registry/SearchParamRegistryImplTest.java | 5 +- hapi-fhir-jpaserver-subscription/pom.xml | 2 +- .../config/WebsocketDispatcherConfig.java | 3 +- hapi-fhir-jpaserver-test-utilities/pom.xml | 2 +- .../ca/uhn/fhir/jpa/config/TestJpaConfig.java | 67 ----- .../fhir/jpa/config/TestJpaDstu3Config.java | 141 ---------- .../uhn/fhir/jpa/config/TestJpaR4Config.java | 147 ----------- .../uhn/fhir/jpa/test/BaseJpaDstu3Test.java | 28 -- .../ca/uhn/fhir/jpa/test/BaseJpaR4Test.java | 28 -- .../ca/uhn/fhir/jpa/test/BaseJpaTest.java | 107 -------- hapi-fhir-jpaserver-uhnfhirtest/pom.xml | 2 +- .../uhn/fhirtest/config/TestDstu2Config.java | 25 +- .../uhn/fhirtest/config/TestDstu3Config.java | 39 ++- .../ca/uhn/fhirtest/config/TestR4Config.java | 31 +-- .../ca/uhn/fhirtest/config/TestR5Config.java | 38 ++- hapi-fhir-server-mdm/pom.xml | 2 +- hapi-fhir-server-openapi/pom.xml | 2 +- hapi-fhir-server/pom.xml | 2 +- .../pom.xml | 2 +- .../autoconfigure/FhirAutoConfiguration.java | 22 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../hapi-fhir-spring-boot-samples/pom.xml | 2 +- .../hapi-fhir-spring-boot-starter/pom.xml | 2 +- hapi-fhir-spring-boot/pom.xml | 2 +- hapi-fhir-sql-migrate/pom.xml | 2 +- hapi-fhir-storage/pom.xml | 2 +- .../DaoRegistryResourceSupportedSvc.java | 17 ++ hapi-fhir-structures-dstu2.1/pom.xml | 2 +- hapi-fhir-structures-dstu2/pom.xml | 2 +- hapi-fhir-structures-dstu3/pom.xml | 2 +- hapi-fhir-structures-hl7org-dstu2/pom.xml | 2 +- hapi-fhir-structures-r4/pom.xml | 2 +- hapi-fhir-structures-r5/pom.xml | 2 +- hapi-fhir-test-utilities/pom.xml | 2 +- hapi-fhir-testpage-overlay/pom.xml | 2 +- .../pom.xml | 2 +- hapi-fhir-validation-resources-dstu2/pom.xml | 2 +- hapi-fhir-validation-resources-dstu3/pom.xml | 2 +- hapi-fhir-validation-resources-r4/pom.xml | 2 +- hapi-fhir-validation-resources-r5/pom.xml | 2 +- hapi-fhir-validation/pom.xml | 2 +- hapi-tinder-plugin/pom.xml | 16 +- .../fhir/tinder/TinderJpaRestServerMojo.java | 4 +- .../resources/vm/jpa_spring_beans_java.vm | 21 +- hapi-tinder-test/pom.xml | 2 +- pom.xml | 4 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- 290 files changed, 3134 insertions(+), 3590 deletions(-) create mode 100644 hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/IResourceSupportedSvc.java delete mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfigDstu3Plus.java delete mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseDstu2Config.java create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BeanPostProcessorConfig.java create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/FhirContextDstu2Config.java create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HapiJpaConfig.java rename hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/{BaseConfig.java => JpaConfig.java} (85%) create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/JpaDstu2Config.java create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/SharedConfigDstu3Plus.java create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/ValidationSupportConfig.java create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/dstu3/FhirContextDstu3Config.java rename hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/dstu3/{BaseDstu3Config.java => JpaDstu3Config.java} (65%) create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r4/FhirContextR4Config.java rename hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r4/{BaseR4Config.java => JpaR4Config.java} (63%) create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r5/FhirContextR5Config.java rename hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r5/{BaseR5Config.java => JpaR5Config.java} (63%) create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/util/HapiEntityManagerFactoryUtil.java create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/util/ResourceCountCacheUtil.java create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/util/ValidationSupportConfigUtil.java create mode 100644 hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/TestContextLoads.java delete mode 100644 hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/config/TestJpaConfig.java delete mode 100644 hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/config/TestJpaDstu3Config.java delete mode 100644 hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/config/TestJpaR4Config.java delete mode 100644 hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaDstu3Test.java delete mode 100644 hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaR4Test.java delete mode 100644 hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaTest.java create mode 100644 hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/provider/DaoRegistryResourceSupportedSvc.java diff --git a/hapi-deployable-pom/pom.xml b/hapi-deployable-pom/pom.xml index 10b2e10688a..0cd8d3c5eb1 100644 --- a/hapi-deployable-pom/pom.xml +++ b/hapi-deployable-pom/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-android/pom.xml b/hapi-fhir-android/pom.xml index 08b43342eaa..c39afdf270f 100644 --- a/hapi-fhir-android/pom.xml +++ b/hapi-fhir-android/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-base/pom.xml b/hapi-fhir-base/pom.xml index 98674c0b2b0..2330170d4e1 100644 --- a/hapi-fhir-base/pom.xml +++ b/hapi-fhir-base/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/IResourceSupportedSvc.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/IResourceSupportedSvc.java new file mode 100644 index 00000000000..e5d95d6caa2 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/IResourceSupportedSvc.java @@ -0,0 +1,5 @@ +package ca.uhn.fhir.rest.api; + +public interface IResourceSupportedSvc { + boolean isSupported(String theResourceName); +} diff --git a/hapi-fhir-batch/pom.xml b/hapi-fhir-batch/pom.xml index ce02f2f33c0..6868cfc7994 100644 --- a/hapi-fhir-batch/pom.xml +++ b/hapi-fhir-batch/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-bom/pom.xml b/hapi-fhir-bom/pom.xml index f7569c889de..5677d158b45 100644 --- a/hapi-fhir-bom/pom.xml +++ b/hapi-fhir-bom/pom.xml @@ -3,14 +3,14 @@ 4.0.0 ca.uhn.hapi.fhir hapi-fhir-bom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT pom HAPI FHIR BOM ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-checkstyle/pom.xml b/hapi-fhir-checkstyle/pom.xml index 06bac605854..017c261f3e6 100644 --- a/hapi-fhir-checkstyle/pom.xml +++ b/hapi-fhir-checkstyle/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml b/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml index d940421ee50..bc2b7ab38a3 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml +++ b/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml b/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml index 0494f01f6cd..26cd926fa6e 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml +++ b/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-fhir-cli - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/pom.xml b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/pom.xml index f2399ca4eb9..9237aa85afb 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/pom.xml +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../../hapi-deployable-pom diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfig.java b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfig.java index 4e1d6486bcf..c12049821bc 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfig.java +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfig.java @@ -20,14 +20,15 @@ package ca.uhn.fhir.jpa.demo; * #L% */ +import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.jpa.config.BaseJavaConfigDstu2; +import ca.uhn.fhir.jpa.config.HapiJpaConfig; +import ca.uhn.fhir.jpa.config.JpaDstu2Config; +import ca.uhn.fhir.jpa.config.util.HapiEntityManagerFactoryUtil; import ca.uhn.fhir.jpa.util.SubscriptionsRequireManualActivationInterceptorDstu2; import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor; import ca.uhn.fhir.rest.server.interceptor.LoggingInterceptor; import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor; -import org.apache.commons.lang3.time.DateUtils; -import org.springframework.beans.factory.annotation.Autowire; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; @@ -45,8 +46,8 @@ import java.util.Properties; @Configuration @EnableTransactionManagement() -@Import(CommonConfig.class) -public class FhirServerConfig extends BaseJavaConfigDstu2 { +@Import({CommonConfig.class, JpaDstu2Config.class, HapiJpaConfig.class}) +public class FhirServerConfig { @Autowired private DataSource myDataSource; @@ -64,10 +65,9 @@ public class FhirServerConfig extends BaseJavaConfigDstu2 { return retVal; } - @Override @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory) { - LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory(theConfigurableListableBeanFactory); + public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory, FhirContext theFhirContext) { + LocalContainerEntityManagerFactoryBean retVal = HapiEntityManagerFactoryUtil.newEntityManagerFactory(theConfigurableListableBeanFactory, theFhirContext); retVal.setPersistenceUnitName("HAPI_PU"); retVal.setDataSource(myDataSource); retVal.setJpaProperties(myJpaProperties); @@ -92,13 +92,13 @@ public class FhirServerConfig extends BaseJavaConfigDstu2 { * This interceptor adds some pretty syntax highlighting in responses when a browser is detected * @return */ - @Bean(autowire = Autowire.BY_TYPE) + @Bean public ResponseHighlighterInterceptor responseHighlighterInterceptor() { ResponseHighlighterInterceptor retVal = new ResponseHighlighterInterceptor(); return retVal; } - @Bean(autowire = Autowire.BY_TYPE) + @Bean public IServerInterceptor subscriptionSecurityInterceptor() { SubscriptionsRequireManualActivationInterceptorDstu2 retVal = new SubscriptionsRequireManualActivationInterceptorDstu2(); return retVal; diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfigDstu3.java b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfigDstu3.java index c1ccad61963..723c71b502f 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfigDstu3.java +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfigDstu3.java @@ -20,14 +20,14 @@ package ca.uhn.fhir.jpa.demo; * #L% */ -import ca.uhn.fhir.jpa.binstore.DatabaseBlobBinaryStorageSvcImpl; -import ca.uhn.fhir.jpa.binstore.IBinaryStorageSvc; -import ca.uhn.fhir.jpa.config.BaseJavaConfigDstu3; +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.jpa.config.HapiJpaConfig; +import ca.uhn.fhir.jpa.config.dstu3.JpaDstu3Config; +import ca.uhn.fhir.jpa.config.util.HapiEntityManagerFactoryUtil; import ca.uhn.fhir.jpa.util.SubscriptionsRequireManualActivationInterceptorDstu3; import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor; import ca.uhn.fhir.rest.server.interceptor.LoggingInterceptor; import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor; -import org.springframework.beans.factory.annotation.Autowire; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; @@ -52,8 +52,8 @@ import java.util.Properties; */ @Configuration @EnableTransactionManagement() -@Import(CommonConfig.class) -public class FhirServerConfigDstu3 extends BaseJavaConfigDstu3 { +@Import({CommonConfig.class, JpaDstu3Config.class, HapiJpaConfig.class,}) +public class FhirServerConfigDstu3 { @Autowired private DataSource myDataSource; @@ -61,10 +61,9 @@ public class FhirServerConfigDstu3 extends BaseJavaConfigDstu3 { @Qualifier("jpaProperties") private Properties myJpaProperties; - @Override @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory) { - LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory(theConfigurableListableBeanFactory); + public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory, FhirContext theFhirContext) { + LocalContainerEntityManagerFactoryBean retVal = HapiEntityManagerFactoryUtil.newEntityManagerFactory(theConfigurableListableBeanFactory, theFhirContext); retVal.setPersistenceUnitName("HAPI_PU"); retVal.setDataSource(myDataSource); retVal.setJpaProperties(myJpaProperties); @@ -89,13 +88,13 @@ public class FhirServerConfigDstu3 extends BaseJavaConfigDstu3 { * This interceptor adds some pretty syntax highlighting in responses when a browser is detected * @return */ - @Bean(autowire = Autowire.BY_TYPE) + @Bean public ResponseHighlighterInterceptor responseHighlighterInterceptor() { ResponseHighlighterInterceptor retVal = new ResponseHighlighterInterceptor(); return retVal; } - @Bean(autowire = Autowire.BY_TYPE) + @Bean public IServerInterceptor subscriptionSecurityInterceptor() { SubscriptionsRequireManualActivationInterceptorDstu3 retVal = new SubscriptionsRequireManualActivationInterceptorDstu3(); return retVal; diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfigR4.java b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfigR4.java index c6642ec8a32..ccf365677c4 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfigR4.java +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfigR4.java @@ -20,12 +20,14 @@ package ca.uhn.fhir.jpa.demo; * #L% */ -import ca.uhn.fhir.jpa.config.BaseJavaConfigR4; +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.jpa.config.HapiJpaConfig; +import ca.uhn.fhir.jpa.config.r4.JpaR4Config; +import ca.uhn.fhir.jpa.config.util.HapiEntityManagerFactoryUtil; import ca.uhn.fhir.jpa.util.SubscriptionsRequireManualActivationInterceptorR4; import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor; import ca.uhn.fhir.rest.server.interceptor.LoggingInterceptor; import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor; -import org.springframework.beans.factory.annotation.Autowire; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; @@ -50,8 +52,8 @@ import java.util.Properties; */ @Configuration @EnableTransactionManagement() -@Import(CommonConfig.class) -public class FhirServerConfigR4 extends BaseJavaConfigR4 { +@Import({CommonConfig.class, JpaR4Config.class, HapiJpaConfig.class}) +public class FhirServerConfigR4 { @Autowired private DataSource myDataSource; @@ -59,10 +61,9 @@ public class FhirServerConfigR4 extends BaseJavaConfigR4 { @Qualifier("jpaProperties") private Properties myJpaProperties; - @Override @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory) { - LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory(theConfigurableListableBeanFactory); + public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory, FhirContext theFhirContext) { + LocalContainerEntityManagerFactoryBean retVal = HapiEntityManagerFactoryUtil.newEntityManagerFactory(theConfigurableListableBeanFactory, theFhirContext); retVal.setPersistenceUnitName("HAPI_PU"); retVal.setDataSource(myDataSource); retVal.setJpaProperties(myJpaProperties); @@ -87,13 +88,13 @@ public class FhirServerConfigR4 extends BaseJavaConfigR4 { * This interceptor adds some pretty syntax highlighting in responses when a browser is detected * @return */ - @Bean(autowire = Autowire.BY_TYPE) + @Bean public ResponseHighlighterInterceptor responseHighlighterInterceptor() { ResponseHighlighterInterceptor retVal = new ResponseHighlighterInterceptor(); return retVal; } - @Bean(autowire = Autowire.BY_TYPE) + @Bean public IServerInterceptor subscriptionSecurityInterceptor() { SubscriptionsRequireManualActivationInterceptorR4 retVal = new SubscriptionsRequireManualActivationInterceptorR4(); return retVal; diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/JpaServerDemo.java b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/JpaServerDemo.java index 5fde99ce549..7b979cea416 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/JpaServerDemo.java +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/JpaServerDemo.java @@ -20,25 +20,24 @@ package ca.uhn.fhir.jpa.demo; * #L% */ -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.context.support.IValidationSupport; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; import ca.uhn.fhir.jpa.binstore.BinaryAccessProvider; -import ca.uhn.fhir.jpa.config.BaseConfig; +import ca.uhn.fhir.jpa.config.JpaConfig; import ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor; +import ca.uhn.fhir.jpa.provider.JpaCapabilityStatementProvider; import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu2; import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2; import ca.uhn.fhir.jpa.provider.TerminologyUploaderProvider; import ca.uhn.fhir.jpa.provider.dstu3.JpaConformanceProviderDstu3; import ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3; -import ca.uhn.fhir.jpa.provider.JpaCapabilityStatementProvider; import ca.uhn.fhir.jpa.provider.r4.JpaSystemProviderR4; -import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import ca.uhn.fhir.model.dstu2.composite.MetaDt; import ca.uhn.fhir.model.dstu2.resource.Bundle; import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator; @@ -47,8 +46,9 @@ import ca.uhn.fhir.rest.server.ETagSupportEnum; import ca.uhn.fhir.rest.server.FifoMemoryPagingProvider; import ca.uhn.fhir.rest.server.RestfulServer; import ca.uhn.fhir.rest.server.interceptor.CorsInterceptor; -import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory; import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor; +import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory; +import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import org.springframework.web.context.ContextLoaderListener; import org.springframework.web.context.WebApplicationContext; @@ -109,7 +109,7 @@ public class JpaServerDemo extends RestfulServer { } else if (fhirVersion == FhirVersionEnum.R4) { systemProvider.add(myAppCtx.getBean("mySystemProviderR4", JpaSystemProviderR4.class)); systemProvider.add(myAppCtx.getBean(TerminologyUploaderProvider.class)); - systemProvider.add(myAppCtx.getBean(BaseConfig.GRAPHQL_PROVIDER_NAME)); + systemProvider.add(myAppCtx.getBean(JpaConfig.GRAPHQL_PROVIDER_NAME)); } else { throw new IllegalStateException(Msg.code(1533)); } diff --git a/hapi-fhir-cli/pom.xml b/hapi-fhir-cli/pom.xml index 4fb978dac34..d83770fa17d 100644 --- a/hapi-fhir-cli/pom.xml +++ b/hapi-fhir-cli/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-client-okhttp/pom.xml b/hapi-fhir-client-okhttp/pom.xml index 356cbc9377a..cafea33f8ea 100644 --- a/hapi-fhir-client-okhttp/pom.xml +++ b/hapi-fhir-client-okhttp/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-client/pom.xml b/hapi-fhir-client/pom.xml index 798ff2a4cc3..1d64dd597e2 100644 --- a/hapi-fhir-client/pom.xml +++ b/hapi-fhir-client/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-converter/pom.xml b/hapi-fhir-converter/pom.xml index e8616b0bb80..73d5054daa1 100644 --- a/hapi-fhir-converter/pom.xml +++ b/hapi-fhir-converter/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-dist/pom.xml b/hapi-fhir-dist/pom.xml index c5b94bf3ba0..37c7b72b2e1 100644 --- a/hapi-fhir-dist/pom.xml +++ b/hapi-fhir-dist/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-docs/pom.xml b/hapi-fhir-docs/pom.xml index fdf28fb715c..2bb780a286e 100644 --- a/hapi-fhir-docs/pom.xml +++ b/hapi-fhir-docs/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jacoco/pom.xml b/hapi-fhir-jacoco/pom.xml index d65f2b53137..71718fba819 100644 --- a/hapi-fhir-jacoco/pom.xml +++ b/hapi-fhir-jacoco/pom.xml @@ -11,7 +11,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jaxrsserver-base/pom.xml b/hapi-fhir-jaxrsserver-base/pom.xml index d0183fbab68..8bfc0e7e981 100644 --- a/hapi-fhir-jaxrsserver-base/pom.xml +++ b/hapi-fhir-jaxrsserver-base/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpa/pom.xml b/hapi-fhir-jpa/pom.xml index dc347c9e49e..b014ba81ab3 100644 --- a/hapi-fhir-jpa/pom.xml +++ b/hapi-fhir-jpa/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml 4.0.0 diff --git a/hapi-fhir-jpaserver-base/pom.xml b/hapi-fhir-jpaserver-base/pom.xml index 2c9568fc46e..9d9cbdf11bc 100644 --- a/hapi-fhir-jpaserver-base/pom.xml +++ b/hapi-fhir-jpaserver-base/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml @@ -556,6 +556,18 @@ + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + + test-jar + + + + org.apache.maven.plugins maven-failsafe-plugin @@ -761,7 +773,7 @@ - + ${project.basedir}/src/main/resources diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch/BatchJobsConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch/BatchJobsConfig.java index 471f24865d2..b8d6d17ad01 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch/BatchJobsConfig.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch/BatchJobsConfig.java @@ -20,19 +20,29 @@ package ca.uhn.fhir.jpa.batch; * #L% */ +import ca.uhn.fhir.jpa.batch.api.IBatchJobSubmitter; import ca.uhn.fhir.jpa.batch.mdm.job.MdmClearJobConfig; +import ca.uhn.fhir.jpa.batch.svc.BatchJobSubmitterImpl; import ca.uhn.fhir.jpa.bulk.export.job.BulkExportJobConfig; import ca.uhn.fhir.jpa.bulk.imprt.job.BulkImportJobConfig; +import ca.uhn.fhir.jpa.config.BatchJobRegisterer; import ca.uhn.fhir.jpa.delete.job.DeleteExpungeJobConfig; import ca.uhn.fhir.jpa.reindex.job.ReindexEverythingJobConfig; import ca.uhn.fhir.jpa.reindex.job.ReindexJobConfig; import ca.uhn.fhir.jpa.term.job.TermCodeSystemDeleteJobConfig; import ca.uhn.fhir.jpa.term.job.TermCodeSystemVersionDeleteJobConfig; +import org.springframework.batch.core.configuration.JobRegistry; +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.explore.JobExplorer; +import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.launch.support.SimpleJobOperator; +import org.springframework.batch.core.repository.JobRepository; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @Configuration -//When you define a new batch job, add it here. +@EnableBatchProcessing @Import({ CommonBatchJobConfig.class, BulkExportJobConfig.class, @@ -43,6 +53,28 @@ import org.springframework.context.annotation.Import; MdmClearJobConfig.class, TermCodeSystemDeleteJobConfig.class, TermCodeSystemVersionDeleteJobConfig.class + // When you define a new batch job, add it here. }) public class BatchJobsConfig { + @Bean + public IBatchJobSubmitter batchJobSubmitter() { + return new BatchJobSubmitterImpl(); + } + + @Bean + public BatchJobRegisterer batchJobRegisterer() { + return new BatchJobRegisterer(); + } + + @Bean + public SimpleJobOperator jobOperator(JobExplorer theJobExplorer, JobRepository theJobRepository, JobRegistry theJobRegistry, JobLauncher theJobLauncher) { + SimpleJobOperator jobOperator = new SimpleJobOperator(); + + jobOperator.setJobExplorer(theJobExplorer); + jobOperator.setJobRepository(theJobRepository); + jobOperator.setJobRegistry(theJobRegistry); + jobOperator.setJobLauncher(theJobLauncher); + + return jobOperator; + } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfigDstu3Plus.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfigDstu3Plus.java deleted file mode 100644 index ae97aa81f11..00000000000 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfigDstu3Plus.java +++ /dev/null @@ -1,126 +0,0 @@ -package ca.uhn.fhir.jpa.config; - -/*- - * #%L - * HAPI FHIR JPA Server - * %% - * Copyright (C) 2014 - 2022 Smile CDR, Inc. - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - -import ca.uhn.fhir.context.support.DefaultProfileValidationSupport; -import ca.uhn.fhir.context.support.IValidationSupport; -import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.jpa.dao.JpaPersistedResourceValidationSupport; -import ca.uhn.fhir.jpa.dao.ObservationLastNIndexPersistSvc; -import ca.uhn.fhir.jpa.term.TermCodeSystemStorageSvcImpl; -import ca.uhn.fhir.jpa.term.TermDeferredStorageSvcImpl; -import ca.uhn.fhir.jpa.term.TermReindexingSvcImpl; -import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc; -import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc; -import ca.uhn.fhir.jpa.term.api.ITermReadSvc; -import ca.uhn.fhir.jpa.term.api.ITermReindexingSvc; -import ca.uhn.fhir.jpa.term.api.ITermVersionAdapterSvc; -import ca.uhn.fhir.jpa.validation.JpaValidationSupportChain; -import ca.uhn.fhir.jpa.validation.ValidatorPolicyAdvisor; -import ca.uhn.fhir.jpa.validation.ValidatorResourceFetcher; -import ca.uhn.fhir.validation.IInstanceValidatorModule; -import org.hl7.fhir.common.hapi.validation.support.CachingValidationSupport; -import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator; -import org.hl7.fhir.r5.utils.validation.constants.BestPracticeWarningLevel; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Lazy; -import org.springframework.context.annotation.Primary; - -@Configuration -public abstract class BaseConfigDstu3Plus extends BaseConfig { - - @Bean - public ITermCodeSystemStorageSvc termCodeSystemStorageSvc() { - return new TermCodeSystemStorageSvcImpl(); - } - - @Bean - public ITermDeferredStorageSvc termDeferredStorageSvc() { - return new TermDeferredStorageSvcImpl(); - } - - @Bean - public ITermReindexingSvc termReindexingSvc() { - return new TermReindexingSvcImpl(); - } - - @Bean - public abstract ITermVersionAdapterSvc terminologyVersionAdapterSvc(); - - @Bean(name = "myDefaultProfileValidationSupport") - public DefaultProfileValidationSupport defaultProfileValidationSupport(DaoConfig theDaoConfig) { - return new DefaultProfileValidationSupport(fhirContext()); - } - - @Bean(name = JPA_VALIDATION_SUPPORT_CHAIN) - public JpaValidationSupportChain jpaValidationSupportChain() { - return new JpaValidationSupportChain(fhirContext()); - } - - @Bean(name = JPA_VALIDATION_SUPPORT) - public IValidationSupport jpaValidationSupport() { - return new JpaPersistedResourceValidationSupport(fhirContext()); - } - - @Primary - @Bean - public IValidationSupport validationSupportChain() { - // Short timeout for code translation because TermConceptMappingSvcImpl has its own caching - CachingValidationSupport.CacheTimeouts cacheTimeouts = CachingValidationSupport.CacheTimeouts.defaultValues() - .setTranslateCodeMillis(1000); - - return new CachingValidationSupport(jpaValidationSupportChain(), cacheTimeouts); - } - - @Bean(name = "myInstanceValidator") - @Lazy - public IInstanceValidatorModule instanceValidator() { - FhirInstanceValidator val = new FhirInstanceValidator(validationSupportChain()); - val.setValidatorResourceFetcher(jpaValidatorResourceFetcher()); - val.setValidatorPolicyAdvisor(jpaValidatorPolicyAdvisor()); - val.setBestPracticeWarningLevel(BestPracticeWarningLevel.Warning); - val.setValidationSupport(validationSupportChain()); - return val; - } - - @Bean - @Lazy - public ValidatorResourceFetcher jpaValidatorResourceFetcher() { - return new ValidatorResourceFetcher(); - } - - @Bean - @Lazy - public ValidatorPolicyAdvisor jpaValidatorPolicyAdvisor() { - return new ValidatorPolicyAdvisor(); - } - - @Bean - public abstract ITermReadSvc terminologyService(); - - @Bean - public ObservationLastNIndexPersistSvc baseObservationLastNIndexpersistSvc() { - return new ObservationLastNIndexPersistSvc(); - } - - -} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseDstu2Config.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseDstu2Config.java deleted file mode 100644 index e74c759cc63..00000000000 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseDstu2Config.java +++ /dev/null @@ -1,155 +0,0 @@ -package ca.uhn.fhir.jpa.config; - -import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.support.DefaultProfileValidationSupport; -import ca.uhn.fhir.context.support.IValidationSupport; -import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; -import ca.uhn.fhir.jpa.dao.FulltextSearchSvcImpl; -import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc; -import ca.uhn.fhir.jpa.dao.ITransactionProcessorVersionAdapter; -import ca.uhn.fhir.jpa.dao.JpaPersistedResourceValidationSupport; -import ca.uhn.fhir.jpa.dao.TransactionProcessorVersionAdapterDstu2; -import ca.uhn.fhir.jpa.term.TermReadSvcDstu2; -import ca.uhn.fhir.jpa.term.api.ITermReadSvc; -import ca.uhn.fhir.jpa.util.ResourceCountCache; -import ca.uhn.fhir.model.dstu2.composite.MetaDt; -import ca.uhn.fhir.model.dstu2.resource.Bundle; -import ca.uhn.fhir.validation.IInstanceValidatorModule; -import org.apache.commons.lang3.time.DateUtils; -import org.hl7.fhir.common.hapi.validation.support.CachingValidationSupport; -import org.hl7.fhir.common.hapi.validation.support.CommonCodeSystemsTerminologyService; -import org.hl7.fhir.common.hapi.validation.support.InMemoryTerminologyServerValidationSupport; -import org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain; -import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator; -import org.hl7.fhir.common.hapi.validation.validator.HapiToHl7OrgDstu2ValidatingSupportWrapper; -import org.hl7.fhir.r5.utils.validation.constants.BestPracticeWarningLevel; -import org.springframework.beans.factory.annotation.Autowire; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Lazy; -import org.springframework.context.annotation.Primary; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -/* - * #%L - * HAPI FHIR JPA Server - * %% - * Copyright (C) 2014 - 2022 Smile CDR, Inc. - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - -@Configuration -@EnableTransactionManagement -public class BaseDstu2Config extends BaseConfig { - - private static FhirContext ourFhirContextDstu2; - private static FhirContext ourFhirContextDstu2Hl7Org; - - @Bean - @Primary - public FhirContext defaultFhirContext() { - return fhirContextDstu2(); - } - - @Override - public FhirContext fhirContext() { - return fhirContextDstu2(); - } - - @Bean(name = "myFhirContextDstu2") - @Lazy - public FhirContext fhirContextDstu2() { - if (ourFhirContextDstu2 == null) { - ourFhirContextDstu2 = FhirContext.forDstu2(); - } - return ourFhirContextDstu2; - } - - @Bean(name = "myFhirContextDstu2Hl7Org") - @Lazy - public FhirContext fhirContextDstu2Hl7Org() { - if (ourFhirContextDstu2Hl7Org == null) { - ourFhirContextDstu2Hl7Org = FhirContext.forDstu2Hl7Org(); - } - return ourFhirContextDstu2Hl7Org; - } - - @Bean(name = "myInstanceValidator") - @Lazy - public IInstanceValidatorModule instanceValidator(ValidationSupportChain theValidationSupportChain) { - CachingValidationSupport cachingValidationSupport = new CachingValidationSupport(new HapiToHl7OrgDstu2ValidatingSupportWrapper(theValidationSupportChain)); - FhirInstanceValidator retVal = new FhirInstanceValidator(cachingValidationSupport); - retVal.setBestPracticeWarningLevel(BestPracticeWarningLevel.Warning); - return retVal; - } - - @Bean - public ITransactionProcessorVersionAdapter transactionProcessorVersionFacade() { - return new TransactionProcessorVersionAdapterDstu2(); - } - - - @Bean(name = "myDefaultProfileValidationSupport") - public DefaultProfileValidationSupport defaultProfileValidationSupport() { - return new DefaultProfileValidationSupport(fhirContext()); - } - - @Bean(name = JPA_VALIDATION_SUPPORT_CHAIN) - public ValidationSupportChain validationSupportChain(DefaultProfileValidationSupport theDefaultProfileValidationSupport) { - InMemoryTerminologyServerValidationSupport inMemoryTerminologyServer = new InMemoryTerminologyServerValidationSupport(fhirContextDstu2()); - IValidationSupport jpaValidationSupport = jpaValidationSupportDstu2(); - CommonCodeSystemsTerminologyService commonCodeSystemsTermSvc = new CommonCodeSystemsTerminologyService(fhirContext()); - return new ValidationSupportChain(theDefaultProfileValidationSupport, jpaValidationSupport, inMemoryTerminologyServer, commonCodeSystemsTermSvc); - } - - @Primary - @Bean(name = JPA_VALIDATION_SUPPORT) - public IValidationSupport jpaValidationSupportDstu2() { - return new JpaPersistedResourceValidationSupport(fhirContextDstu2()); - } - - @Bean(name = "myResourceCountsCache") - public ResourceCountCache resourceCountsCache() { - ResourceCountCache retVal = new ResourceCountCache(() -> systemDaoDstu2().getResourceCounts()); - retVal.setCacheMillis(4 * DateUtils.MILLIS_PER_HOUR); - return retVal; - } - - @Bean(autowire = Autowire.BY_TYPE) - public IFulltextSearchSvc searchDao() { - FulltextSearchSvcImpl searchDao = new FulltextSearchSvcImpl(); - return searchDao; - } - - @Bean(name = "mySystemDaoDstu2", autowire = Autowire.BY_NAME) - public IFhirSystemDao systemDaoDstu2() { - ca.uhn.fhir.jpa.dao.FhirSystemDaoDstu2 retVal = new ca.uhn.fhir.jpa.dao.FhirSystemDaoDstu2(); - return retVal; - } - - @Bean(name = "mySystemProviderDstu2") - public ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2 systemProviderDstu2() { - ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2 retVal = new ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2(); - retVal.setDao(systemDaoDstu2()); - retVal.setContext(fhirContextDstu2()); - return retVal; - } - - @Bean(autowire = Autowire.BY_TYPE) - public ITermReadSvc terminologyService() { - return new TermReadSvcDstu2(); - } - -} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BatchJobRegisterer.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BatchJobRegisterer.java index bec02113051..e571f6bd1ee 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BatchJobRegisterer.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BatchJobRegisterer.java @@ -24,7 +24,6 @@ import org.springframework.batch.core.Job; import org.springframework.batch.core.configuration.DuplicateJobException; import org.springframework.batch.core.configuration.JobFactory; import org.springframework.batch.core.configuration.JobRegistry; -import org.springframework.batch.core.configuration.support.ApplicationContextJobFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BeanPostProcessorConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BeanPostProcessorConfig.java new file mode 100644 index 00000000000..6417a353d59 --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BeanPostProcessorConfig.java @@ -0,0 +1,20 @@ +package ca.uhn.fhir.jpa.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; + +@Configuration +// TODO KHS do we even need this class? +// TODO KHS find out why this Spring Config produces the message and if there's anything we can do about it: +// o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker [PostProcessorRegistrationDelegate.java:376] +// Bean 'ca.uhn.fhir.jpa.config.BeanPostProcessorConfig' +// of type [ca.uhn.fhir.jpa.config.BeanPostProcessorConfig$$EnhancerBySpringCGLIB$$8d867950] +// is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) +public class BeanPostProcessorConfig { + @Bean + public PersistenceExceptionTranslationPostProcessor persistenceExceptionTranslationPostProcessor() { + return new PersistenceExceptionTranslationPostProcessor(); + } + +} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/FhirContextDstu2Config.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/FhirContextDstu2Config.java new file mode 100644 index 00000000000..56bfe9b1679 --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/FhirContextDstu2Config.java @@ -0,0 +1,13 @@ +package ca.uhn.fhir.jpa.config; + +import ca.uhn.fhir.context.FhirContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Primary; + +public class FhirContextDstu2Config { + @Primary + @Bean(name = "primaryFhirContext") + public FhirContext fhirContextDstu2() { + return FhirContext.forDstu2(); + } +} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HapiFhirHibernateJpaDialect.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HapiFhirHibernateJpaDialect.java index a7dbe7156cf..82d42929310 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HapiFhirHibernateJpaDialect.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HapiFhirHibernateJpaDialect.java @@ -20,8 +20,8 @@ package ca.uhn.fhir.jpa.config; * #L% */ -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.i18n.HapiLocalizer; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.model.entity.ForcedId; import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable; import ca.uhn.fhir.jpa.model.entity.ResourceIndexedComboStringUnique; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HapiJpaConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HapiJpaConfig.java new file mode 100644 index 00000000000..98d87f3b0cb --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HapiJpaConfig.java @@ -0,0 +1,62 @@ +package ca.uhn.fhir.jpa.config; + +import ca.uhn.fhir.jpa.api.IDaoRegistry; +import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; +import ca.uhn.fhir.jpa.batch.config.NonPersistedBatchConfigurer; +import ca.uhn.fhir.jpa.config.util.ResourceCountCacheUtil; +import ca.uhn.fhir.jpa.config.util.ValidationSupportConfigUtil; +import ca.uhn.fhir.jpa.dao.FulltextSearchSvcImpl; +import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc; +import ca.uhn.fhir.jpa.provider.DaoRegistryResourceSupportedSvc; +import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; +import ca.uhn.fhir.jpa.search.IStaleSearchDeletingSvc; +import ca.uhn.fhir.jpa.search.StaleSearchDeletingSvcImpl; +import ca.uhn.fhir.jpa.util.ResourceCountCache; +import ca.uhn.fhir.jpa.validation.JpaValidationSupportChain; +import ca.uhn.fhir.rest.api.IResourceSupportedSvc; +import org.hl7.fhir.common.hapi.validation.support.CachingValidationSupport; +import org.springframework.batch.core.configuration.annotation.BatchConfigurer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; +import org.springframework.context.annotation.Primary; + +@Configuration +@Import({JpaConfig.class}) +public class HapiJpaConfig { + @Bean + public IFulltextSearchSvc fullTextSearchSvc() { + return new FulltextSearchSvcImpl(); + } + + @Bean + public IStaleSearchDeletingSvc staleSearchDeletingSvc() { + return new StaleSearchDeletingSvcImpl(); + } + + @Primary + @Bean + public CachingValidationSupport validationSupportChain(JpaValidationSupportChain theJpaValidationSupportChain) { + return ValidationSupportConfigUtil.newCachingValidationSupport(theJpaValidationSupportChain); + } + + @Bean + public BatchConfigurer batchConfigurer() { + return new NonPersistedBatchConfigurer(); + } + + @Bean + public DatabaseBackedPagingProvider databaseBackedPagingProvider() { + return new DatabaseBackedPagingProvider(); + } + + @Bean + public IResourceSupportedSvc resourceSupportedSvc(IDaoRegistry theDaoRegistry) { + return new DaoRegistryResourceSupportedSvc(theDaoRegistry); + } + + @Bean(name = "myResourceCountsCache") + public ResourceCountCache resourceCountsCache(IFhirSystemDao theSystemDao) { + return ResourceCountCacheUtil.newResourceCountCache(theSystemDao); + } +} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HibernatePropertiesProvider.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HibernatePropertiesProvider.java index a93bf4fea9b..d9127ee9466 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HibernatePropertiesProvider.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HibernatePropertiesProvider.java @@ -21,8 +21,8 @@ package ca.uhn.fhir.jpa.config; */ import ca.uhn.fhir.util.ReflectionUtil; -import org.apache.commons.lang3.StringUtils; import com.google.common.annotations.VisibleForTesting; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.Validate; import org.hibernate.dialect.Dialect; import org.hibernate.search.engine.cfg.BackendSettings; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/JpaConfig.java similarity index 85% rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java rename to hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/JpaConfig.java index 006199603f5..38d2da8dd65 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/JpaConfig.java @@ -2,7 +2,6 @@ package ca.uhn.fhir.jpa.config; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.support.IValidationSupport; -import ca.uhn.fhir.i18n.HapiLocalizer; import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster; import ca.uhn.fhir.interceptor.api.IInterceptorService; import ca.uhn.fhir.interceptor.executor.InterceptorService; @@ -12,13 +11,10 @@ import ca.uhn.fhir.jpa.api.dao.IDao; import ca.uhn.fhir.jpa.api.model.ExpungeOptions; import ca.uhn.fhir.jpa.api.svc.ISearchCoordinatorSvc; import ca.uhn.fhir.jpa.batch.BatchJobsConfig; -import ca.uhn.fhir.jpa.batch.api.IBatchJobSubmitter; import ca.uhn.fhir.jpa.batch.config.BatchConstants; -import ca.uhn.fhir.jpa.batch.config.NonPersistedBatchConfigurer; import ca.uhn.fhir.jpa.batch.job.PartitionedUrlValidator; import ca.uhn.fhir.jpa.batch.mdm.MdmClearJobSubmitterImpl; import ca.uhn.fhir.jpa.batch.reader.BatchResourceSearcher; -import ca.uhn.fhir.jpa.batch.svc.BatchJobSubmitterImpl; import ca.uhn.fhir.jpa.binstore.BinaryAccessProvider; import ca.uhn.fhir.jpa.binstore.BinaryStorageInterceptor; import ca.uhn.fhir.jpa.bulk.export.api.IBulkDataExportSvc; @@ -88,13 +84,10 @@ import ca.uhn.fhir.jpa.provider.r4.MemberMatcherR4Helper; import ca.uhn.fhir.jpa.reindex.ReindexJobSubmitterImpl; import ca.uhn.fhir.jpa.sched.AutowiringSpringBeanJobFactory; import ca.uhn.fhir.jpa.sched.HapiSchedulerServiceImpl; -import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; -import ca.uhn.fhir.jpa.search.IStaleSearchDeletingSvc; import ca.uhn.fhir.jpa.search.PersistedJpaBundleProvider; import ca.uhn.fhir.jpa.search.PersistedJpaBundleProviderFactory; import ca.uhn.fhir.jpa.search.PersistedJpaSearchFirstPageBundleProvider; import ca.uhn.fhir.jpa.search.SearchCoordinatorSvcImpl; -import ca.uhn.fhir.jpa.search.StaleSearchDeletingSvcImpl; import ca.uhn.fhir.jpa.search.builder.QueryStack; import ca.uhn.fhir.jpa.search.builder.SearchBuilder; import ca.uhn.fhir.jpa.search.builder.predicate.ComboNonUniqueSearchParameterPredicateBuilder; @@ -148,20 +141,10 @@ import ca.uhn.fhir.rest.server.interceptor.partition.RequestTenantPartitionInter import ca.uhn.fhir.rest.server.provider.DeleteExpungeProvider; import ca.uhn.fhir.rest.server.provider.ReindexProvider; import ca.uhn.fhir.util.ThreadPoolUtil; -import org.hibernate.jpa.HibernatePersistenceProvider; import org.hl7.fhir.common.hapi.validation.support.UnknownCodeSystemWarningValidationSupport; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.utilities.graphql.IGraphQLStorageServices; import org.hl7.fhir.utilities.npm.PackageClient; -import org.springframework.batch.core.configuration.JobRegistry; -import org.springframework.batch.core.configuration.annotation.BatchConfigurer; -import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; -import org.springframework.batch.core.explore.JobExplorer; -import org.springframework.batch.core.launch.JobLauncher; -import org.springframework.batch.core.launch.support.SimpleJobOperator; -import org.springframework.batch.core.repository.JobRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -169,18 +152,14 @@ import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Scope; -import org.springframework.core.env.Environment; import org.springframework.core.task.AsyncTaskExecutor; import org.springframework.core.task.TaskExecutor; -import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.scheduling.TaskScheduler; import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler; import org.springframework.scheduling.concurrent.ScheduledExecutorFactoryBean; import javax.annotation.Nullable; -import javax.annotation.PostConstruct; import java.util.Date; /* @@ -203,15 +182,15 @@ import java.util.Date; * #L% */ - @Configuration -@EnableJpaRepositories(basePackages = "ca.uhn.fhir.jpa.dao.data", enableDefaultTransactions=true) +@EnableJpaRepositories(basePackages = "ca.uhn.fhir.jpa.dao.data") @Import({ - SearchParamConfig.class, BatchJobsConfig.class + BeanPostProcessorConfig.class, + BatchJobsConfig.class, + SearchParamConfig.class, + ValidationSupportConfig.class }) -@EnableBatchProcessing -public abstract class BaseConfig { - +public class JpaConfig { public static final String JPA_VALIDATION_SUPPORT_CHAIN = "myJpaValidationSupportChain"; public static final String JPA_VALIDATION_SUPPORT = "myJpaValidationSupport"; public static final String TASK_EXECUTOR_NAME = "hapiJpaTaskExecutor"; @@ -222,100 +201,24 @@ public abstract class BaseConfig { public static final String SEARCH_BUILDER = "SearchBuilder"; public static final String HISTORY_BUILDER = "HistoryBuilder"; private static final String HAPI_DEFAULT_SCHEDULER_GROUP = "HAPI"; - @Autowired - protected Environment myEnv; - - @Autowired - private DaoRegistry myDaoRegistry; - private Integer searchCoordCorePoolSize = 20; - private Integer searchCoordMaxPoolSize = 100; - private Integer searchCoordQueueCapacity = 200; - - @Autowired - private JobLauncher myJobLauncher; - - /** - * Subclasses may override this method to provide settings such as search coordinator pool sizes. - */ - @PostConstruct - public void initSettings() { - } - - public void setSearchCoordCorePoolSize(Integer searchCoordCorePoolSize) { - this.searchCoordCorePoolSize = searchCoordCorePoolSize; - } - - public void setSearchCoordMaxPoolSize(Integer searchCoordMaxPoolSize) { - this.searchCoordMaxPoolSize = searchCoordMaxPoolSize; - } - - public void setSearchCoordQueueCapacity(Integer searchCoordQueueCapacity) { - this.searchCoordQueueCapacity = searchCoordQueueCapacity; - } - - @Bean - public BatchConfigurer batchConfigurer() { - return new NonPersistedBatchConfigurer(); - } @Bean("myDaoRegistry") public DaoRegistry daoRegistry() { return new DaoRegistry(); } - @Bean - public DatabaseBackedPagingProvider databaseBackedPagingProvider() { - return new DatabaseBackedPagingProvider(); - } - - @Bean - public IBatchJobSubmitter batchJobSubmitter() { - return new BatchJobSubmitterImpl(); - } - - @Bean - public BatchJobRegisterer batchJobRegisterer() { - return new BatchJobRegisterer(); - } - @Lazy @Bean public CascadingDeleteInterceptor cascadingDeleteInterceptor(FhirContext theFhirContext, DaoRegistry theDaoRegistry, IInterceptorBroadcaster theInterceptorBroadcaster) { return new CascadingDeleteInterceptor(theFhirContext, theDaoRegistry, theInterceptorBroadcaster); } - @Bean - public SimpleJobOperator jobOperator(JobExplorer jobExplorer, JobRepository jobRepository, JobRegistry jobRegistry) { - SimpleJobOperator jobOperator = new SimpleJobOperator(); - - jobOperator.setJobExplorer(jobExplorer); - jobOperator.setJobRepository(jobRepository); - jobOperator.setJobRegistry(jobRegistry); - jobOperator.setJobLauncher(myJobLauncher); - - return jobOperator; - } - - @Lazy @Bean public ResponseTerminologyTranslationInterceptor responseTerminologyTranslationInterceptor(IValidationSupport theValidationSupport) { return new ResponseTerminologyTranslationInterceptor(theValidationSupport); } - /** - * This method should be overridden to provide an actual completed - * bean, but it provides a partially completed entity manager - * factory with HAPI FHIR customizations - */ - protected LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory myConfigurableListableBeanFactory) { - LocalContainerEntityManagerFactoryBean retVal = new HapiFhirLocalContainerEntityManagerFactoryBean(myConfigurableListableBeanFactory); - configureEntityManagerFactory(retVal, fhirContext()); - return retVal; - } - - public abstract FhirContext fhirContext(); - @Bean @Lazy public IGraphQLStorageServices graphqlStorageServices() { @@ -420,7 +323,7 @@ public abstract class BaseConfig { return retVal; } - @Bean(name= BatchConstants.JOB_LAUNCHING_TASK_EXECUTOR) + @Bean(name = BatchConstants.JOB_LAUNCHING_TASK_EXECUTOR) public TaskExecutor jobLaunchingTaskExecutor() { return ThreadPoolUtil.newThreadPool(0, 10, "job-launcher-"); } @@ -441,13 +344,8 @@ public abstract class BaseConfig { } @Bean - public IStaleSearchDeletingSvc staleSearchDeletingSvc() { - return new StaleSearchDeletingSvcImpl(); - } - - @Bean - public HapiFhirHibernateJpaDialect hibernateJpaDialect() { - return new HapiFhirHibernateJpaDialect(fhirContext().getLocalizer()); + public HapiFhirHibernateJpaDialect hibernateJpaDialect(FhirContext theFhirContext) { + return new HapiFhirHibernateJpaDialect(theFhirContext.getLocalizer()); } @Bean @@ -461,11 +359,6 @@ public abstract class BaseConfig { return new RequestPartitionHelperSvc(); } - @Bean - public PersistenceExceptionTranslationPostProcessor persistenceExceptionTranslationPostProcessor() { - return new PersistenceExceptionTranslationPostProcessor(); - } - @Bean public HapiTransactionService hapiTransactionService() { return new HapiTransactionService(); @@ -476,13 +369,6 @@ public abstract class BaseConfig { return new InterceptorService("JPA"); } - /** - * Subclasses may override - */ - protected boolean isSupported(String theResourceType) { - return myDaoRegistry.getResourceDaoOrNull(theResourceType) != null; - } - @Bean public IPackageInstallerSvc npmInstallerSvc() { return new PackageInstallerSvcImpl(); @@ -593,6 +479,7 @@ public abstract class BaseConfig { return new BulkDataImportSvcImpl(); } + @Bean public PersistedJpaBundleProviderFactory persistedJpaBundleProviderFactory() { return new PersistedJpaBundleProviderFactory(); @@ -623,6 +510,7 @@ public abstract class BaseConfig { return new ResourceVersionSvcDaoImpl(); } + /* **************************************************************** * * Prototype Beans Below * * **************************************************************** */ @@ -927,8 +815,8 @@ public abstract class BaseConfig { } @Bean - public UnknownCodeSystemWarningValidationSupport unknownCodeSystemWarningValidationSupport() { - return new UnknownCodeSystemWarningValidationSupport(fhirContext()); + public UnknownCodeSystemWarningValidationSupport unknownCodeSystemWarningValidationSupport(FhirContext theFhirContext) { + return new UnknownCodeSystemWarningValidationSupport(theFhirContext); } @Lazy @@ -936,16 +824,4 @@ public abstract class BaseConfig { public MemberMatcherR4Helper memberMatcherR4Helper(FhirContext theFhirContext) { return new MemberMatcherR4Helper(theFhirContext); } - - - - public static void configureEntityManagerFactory(LocalContainerEntityManagerFactoryBean theFactory, FhirContext theCtx) { - theFactory.setJpaDialect(hibernateJpaDialect(theCtx.getLocalizer())); - theFactory.setPackagesToScan("ca.uhn.fhir.jpa.model.entity", "ca.uhn.fhir.jpa.entity"); - theFactory.setPersistenceProvider(new HibernatePersistenceProvider()); - } - - private static HapiFhirHibernateJpaDialect hibernateJpaDialect(HapiLocalizer theLocalizer) { - return new HapiFhirHibernateJpaDialect(theLocalizer); - } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/JpaDstu2Config.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/JpaDstu2Config.java new file mode 100644 index 00000000000..9a07785d0c0 --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/JpaDstu2Config.java @@ -0,0 +1,67 @@ +package ca.uhn.fhir.jpa.config; + +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; +import ca.uhn.fhir.jpa.dao.ITransactionProcessorVersionAdapter; +import ca.uhn.fhir.jpa.dao.TransactionProcessorVersionAdapterDstu2; +import ca.uhn.fhir.jpa.term.TermReadSvcDstu2; +import ca.uhn.fhir.jpa.term.api.ITermReadSvc; +import ca.uhn.fhir.model.dstu2.composite.MetaDt; +import ca.uhn.fhir.model.dstu2.resource.Bundle; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +/* + * #%L + * HAPI FHIR JPA Server + * %% + * Copyright (C) 2014 - 2022 Smile CDR, Inc. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + +@Configuration +@EnableTransactionManagement +@Import({ + FhirContextDstu2Config.class, + GeneratedDaoAndResourceProviderConfigDstu2.class, + JpaConfig.class +}) +public class JpaDstu2Config { + @Bean + public ITransactionProcessorVersionAdapter transactionProcessorVersionFacade() { + return new TransactionProcessorVersionAdapterDstu2(); + } + + @Bean(name = "mySystemDaoDstu2") + public IFhirSystemDao systemDaoDstu2() { + ca.uhn.fhir.jpa.dao.FhirSystemDaoDstu2 retVal = new ca.uhn.fhir.jpa.dao.FhirSystemDaoDstu2(); + return retVal; + } + + @Bean(name = "mySystemProviderDstu2") + public ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2 systemProviderDstu2(FhirContext theFhirContext) { + ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2 retVal = new ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2(); + retVal.setDao(systemDaoDstu2()); + retVal.setContext(theFhirContext); + return retVal; + } + + @Bean + public ITermReadSvc terminologyService() { + return new TermReadSvcDstu2(); + } +} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/SharedConfigDstu3Plus.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/SharedConfigDstu3Plus.java new file mode 100644 index 00000000000..656c818a0f2 --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/SharedConfigDstu3Plus.java @@ -0,0 +1,57 @@ +package ca.uhn.fhir.jpa.config; + +/*- + * #%L + * HAPI FHIR JPA Server + * %% + * Copyright (C) 2014 - 2022 Smile CDR, Inc. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + +import ca.uhn.fhir.jpa.dao.ObservationLastNIndexPersistSvc; +import ca.uhn.fhir.jpa.term.TermCodeSystemStorageSvcImpl; +import ca.uhn.fhir.jpa.term.TermDeferredStorageSvcImpl; +import ca.uhn.fhir.jpa.term.TermReindexingSvcImpl; +import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc; +import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc; +import ca.uhn.fhir.jpa.term.api.ITermReindexingSvc; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class SharedConfigDstu3Plus { + + @Bean + public ITermCodeSystemStorageSvc termCodeSystemStorageSvc() { + return new TermCodeSystemStorageSvcImpl(); + } + + @Bean + public ITermDeferredStorageSvc termDeferredStorageSvc() { + return new TermDeferredStorageSvcImpl(); + } + + @Bean + public ITermReindexingSvc termReindexingSvc() { + return new TermReindexingSvcImpl(); + } + + @Bean + public ObservationLastNIndexPersistSvc baseObservationLastNIndexpersistSvc() { + return new ObservationLastNIndexPersistSvc(); + } + + +} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/ValidationSupportConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/ValidationSupportConfig.java new file mode 100644 index 00000000000..c15930e94cf --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/ValidationSupportConfig.java @@ -0,0 +1,67 @@ +package ca.uhn.fhir.jpa.config; + +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.context.FhirVersionEnum; +import ca.uhn.fhir.context.support.DefaultProfileValidationSupport; +import ca.uhn.fhir.context.support.IValidationSupport; +import ca.uhn.fhir.jpa.dao.JpaPersistedResourceValidationSupport; +import ca.uhn.fhir.jpa.validation.JpaValidationSupportChain; +import ca.uhn.fhir.jpa.validation.ValidatorPolicyAdvisor; +import ca.uhn.fhir.jpa.validation.ValidatorResourceFetcher; +import ca.uhn.fhir.validation.IInstanceValidatorModule; +import org.hl7.fhir.common.hapi.validation.support.CachingValidationSupport; +import org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain; +import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator; +import org.hl7.fhir.common.hapi.validation.validator.HapiToHl7OrgDstu2ValidatingSupportWrapper; +import org.hl7.fhir.r5.utils.validation.constants.BestPracticeWarningLevel; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; + +@Configuration +public class ValidationSupportConfig { + @Bean(name = "myDefaultProfileValidationSupport") + public DefaultProfileValidationSupport defaultProfileValidationSupport(FhirContext theFhirContext) { + return new DefaultProfileValidationSupport(theFhirContext); + } + + @Bean(name = JpaConfig.JPA_VALIDATION_SUPPORT_CHAIN) + public JpaValidationSupportChain jpaValidationSupportChain(FhirContext theFhirContext) { + return new JpaValidationSupportChain(theFhirContext); + } + + @Bean(name = JpaConfig.JPA_VALIDATION_SUPPORT) + public IValidationSupport jpaValidationSupport(FhirContext theFhirContext) { + return new JpaPersistedResourceValidationSupport(theFhirContext); + } + + @Bean(name = "myInstanceValidator") + public IInstanceValidatorModule instanceValidator(FhirContext theFhirContext, CachingValidationSupport theCachingValidationSupport, ValidationSupportChain theValidationSupportChain) { + if (theFhirContext.getVersion().getVersion().isEqualOrNewerThan(FhirVersionEnum.DSTU3)) { + FhirInstanceValidator val = new FhirInstanceValidator(theCachingValidationSupport); + val.setValidatorResourceFetcher(jpaValidatorResourceFetcher()); + val.setValidatorPolicyAdvisor(jpaValidatorPolicyAdvisor()); + val.setBestPracticeWarningLevel(BestPracticeWarningLevel.Warning); + val.setValidationSupport(theCachingValidationSupport); + return val; + } else { + CachingValidationSupport cachingValidationSupport = new CachingValidationSupport(new HapiToHl7OrgDstu2ValidatingSupportWrapper(theValidationSupportChain)); + FhirInstanceValidator retVal = new FhirInstanceValidator(cachingValidationSupport); + retVal.setBestPracticeWarningLevel(BestPracticeWarningLevel.Warning); + return retVal; + } + } + + @Bean + @Lazy + public ValidatorResourceFetcher jpaValidatorResourceFetcher() { + return new ValidatorResourceFetcher(); + } + + @Bean + @Lazy + public ValidatorPolicyAdvisor jpaValidatorPolicyAdvisor() { + return new ValidatorPolicyAdvisor(); + } + +} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/dstu3/FhirContextDstu3Config.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/dstu3/FhirContextDstu3Config.java new file mode 100644 index 00000000000..bbd05b6ca53 --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/dstu3/FhirContextDstu3Config.java @@ -0,0 +1,20 @@ +package ca.uhn.fhir.jpa.config.dstu3; + +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.context.ParserOptions; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Primary; + +public class FhirContextDstu3Config { + @Primary + @Bean(name = "primaryFhirContext") + public FhirContext fhirContextDstu3() { + FhirContext retVal = FhirContext.forDstu3(); + + // Don't strip versions in some places + ParserOptions parserOptions = retVal.getParserOptions(); + parserOptions.setDontStripVersionsFromReferencesAtPaths("AuditEvent.entity.reference"); + + return retVal; + } +} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/dstu3/BaseDstu3Config.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/dstu3/JpaDstu3Config.java similarity index 65% rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/dstu3/BaseDstu3Config.java rename to hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/dstu3/JpaDstu3Config.java index 835f231d223..7765567f550 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/dstu3/BaseDstu3Config.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/dstu3/JpaDstu3Config.java @@ -1,11 +1,11 @@ package ca.uhn.fhir.jpa.config.dstu3; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.ParserOptions; +import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; -import ca.uhn.fhir.jpa.config.BaseConfigDstu3Plus; -import ca.uhn.fhir.jpa.dao.FulltextSearchSvcImpl; -import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc; +import ca.uhn.fhir.jpa.config.GeneratedDaoAndResourceProviderConfigDstu3; +import ca.uhn.fhir.jpa.config.JpaConfig; +import ca.uhn.fhir.jpa.config.SharedConfigDstu3Plus; import ca.uhn.fhir.jpa.dao.ITransactionProcessorVersionAdapter; import ca.uhn.fhir.jpa.dao.dstu3.TransactionProcessorVersionAdapterDstu3; import ca.uhn.fhir.jpa.graphql.GraphQLProvider; @@ -17,14 +17,13 @@ import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc; import ca.uhn.fhir.jpa.term.api.ITermLoaderSvc; import ca.uhn.fhir.jpa.term.api.ITermReadSvcDstu3; import ca.uhn.fhir.jpa.term.api.ITermVersionAdapterSvc; -import ca.uhn.fhir.jpa.util.ResourceCountCache; -import org.apache.commons.lang3.time.DateUtils; import org.hl7.fhir.dstu3.model.Bundle; import org.hl7.fhir.dstu3.model.Meta; +import org.hl7.fhir.utilities.graphql.IGraphQLStorageServices; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Lazy; -import org.springframework.context.annotation.Primary; import org.springframework.transaction.annotation.EnableTransactionManagement; /* @@ -49,37 +48,22 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; @Configuration @EnableTransactionManagement -public class BaseDstu3Config extends BaseConfigDstu3Plus { - - public static FhirContext ourFhirContext = FhirContext.forDstu3(); - - @Override - public FhirContext fhirContext() { - return fhirContextDstu3(); - } - +@Import({ + FhirContextDstu3Config.class, + GeneratedDaoAndResourceProviderConfigDstu3.class, + SharedConfigDstu3Plus.class, + JpaConfig.class +}) +public class JpaDstu3Config { @Bean - @Override public ITermVersionAdapterSvc terminologyVersionAdapterSvc() { return new TermVersionAdapterSvcDstu3(); } - @Bean - @Primary - public FhirContext fhirContextDstu3() { - FhirContext retVal = ourFhirContext; - - // Don't strip versions in some places - ParserOptions parserOptions = retVal.getParserOptions(); - parserOptions.setDontStripVersionsFromReferencesAtPaths("AuditEvent.entity.reference"); - - return retVal; - } - - @Bean(name = GRAPHQL_PROVIDER_NAME) + @Bean(name = JpaConfig.GRAPHQL_PROVIDER_NAME) @Lazy - public GraphQLProvider graphQLProvider() { - return new GraphQLProvider(fhirContextDstu3(), validationSupportChain(), graphqlStorageServices()); + public GraphQLProvider graphQLProvider(FhirContext theFhirContext, IGraphQLStorageServices theGraphqlStorageServices, IValidationSupport theValidationSupport) { + return new GraphQLProvider(theFhirContext, theValidationSupport, theGraphqlStorageServices); } @Bean @@ -87,27 +71,15 @@ public class BaseDstu3Config extends BaseConfigDstu3Plus { return new TransactionProcessorVersionAdapterDstu3(); } - @Bean(name = "myResourceCountsCache") - public ResourceCountCache resourceCountsCache() { - ResourceCountCache retVal = new ResourceCountCache(() -> systemDaoDstu3().getResourceCounts()); - retVal.setCacheMillis(4 * DateUtils.MILLIS_PER_HOUR); - return retVal; - } - - @Bean - public IFulltextSearchSvc searchDaoDstu3() { - return new FulltextSearchSvcImpl(); - } - @Bean(name = "mySystemDaoDstu3") public IFhirSystemDao systemDaoDstu3() { return new ca.uhn.fhir.jpa.dao.dstu3.FhirSystemDaoDstu3(); } @Bean(name = "mySystemProviderDstu3") - public ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3 systemProviderDstu3() { + public ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3 systemProviderDstu3(FhirContext theFhirContext) { ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3 retVal = new ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3(); - retVal.setContext(fhirContextDstu3()); + retVal.setContext(theFhirContext); retVal.setDao(systemDaoDstu3()); return retVal; } @@ -117,8 +89,7 @@ public class BaseDstu3Config extends BaseConfigDstu3Plus { return new TermLoaderSvcImpl(theDeferredStorageSvc, theCodeSystemStorageSvc); } - @Override - @Bean + @Bean public ITermReadSvcDstu3 terminologyService() { return new TermReadSvcDstu3(); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r4/FhirContextR4Config.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r4/FhirContextR4Config.java new file mode 100644 index 00000000000..024c82347d8 --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r4/FhirContextR4Config.java @@ -0,0 +1,20 @@ +package ca.uhn.fhir.jpa.config.r4; + +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.context.ParserOptions; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Primary; + +public class FhirContextR4Config { + @Bean(name = "primaryFhirContext") + @Primary + public FhirContext fhirContextR4() { + FhirContext retVal = FhirContext.forR4(); + + // Don't strip versions in some places + ParserOptions parserOptions = retVal.getParserOptions(); + parserOptions.setDontStripVersionsFromReferencesAtPaths("AuditEvent.entity.what"); + + return retVal; + } +} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r4/BaseR4Config.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r4/JpaR4Config.java similarity index 63% rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r4/BaseR4Config.java rename to hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r4/JpaR4Config.java index b6b07b5c1a0..857e499010c 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r4/BaseR4Config.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r4/JpaR4Config.java @@ -1,11 +1,11 @@ package ca.uhn.fhir.jpa.config.r4; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.ParserOptions; +import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; -import ca.uhn.fhir.jpa.config.BaseConfigDstu3Plus; -import ca.uhn.fhir.jpa.dao.FulltextSearchSvcImpl; -import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc; +import ca.uhn.fhir.jpa.config.GeneratedDaoAndResourceProviderConfigR4; +import ca.uhn.fhir.jpa.config.JpaConfig; +import ca.uhn.fhir.jpa.config.SharedConfigDstu3Plus; import ca.uhn.fhir.jpa.dao.ITransactionProcessorVersionAdapter; import ca.uhn.fhir.jpa.dao.r4.TransactionProcessorVersionAdapterR4; import ca.uhn.fhir.jpa.graphql.GraphQLProvider; @@ -17,17 +17,67 @@ import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc; import ca.uhn.fhir.jpa.term.api.ITermLoaderSvc; import ca.uhn.fhir.jpa.term.api.ITermReadSvcR4; import ca.uhn.fhir.jpa.term.api.ITermVersionAdapterSvc; -import ca.uhn.fhir.jpa.util.ResourceCountCache; -import org.apache.commons.lang3.time.DateUtils; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.Meta; -import org.springframework.beans.factory.annotation.Autowire; +import org.hl7.fhir.utilities.graphql.IGraphQLStorageServices; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Lazy; -import org.springframework.context.annotation.Primary; import org.springframework.transaction.annotation.EnableTransactionManagement; +@Configuration +@EnableTransactionManagement +@Import({ + FhirContextR4Config.class, + GeneratedDaoAndResourceProviderConfigR4.class, + SharedConfigDstu3Plus.class, + JpaConfig.class +}) +public class JpaR4Config { + + @Bean + public ITermVersionAdapterSvc terminologyVersionAdapterSvc() { + return new TermVersionAdapterSvcR4(); + } + + @Bean + public ITransactionProcessorVersionAdapter transactionProcessorVersionFacade() { + return new TransactionProcessorVersionAdapterR4(); + } + + @Bean(name = JpaConfig.GRAPHQL_PROVIDER_NAME) + @Lazy + public GraphQLProvider graphQLProvider(FhirContext theFhirContext, IGraphQLStorageServices theGraphqlStorageServices, IValidationSupport theValidationSupport) { + return new GraphQLProvider(theFhirContext, theValidationSupport, theGraphqlStorageServices); + } + + @Bean(name = "mySystemDaoR4") + public IFhirSystemDao systemDaoR4() { + ca.uhn.fhir.jpa.dao.r4.FhirSystemDaoR4 retVal = new ca.uhn.fhir.jpa.dao.r4.FhirSystemDaoR4(); + return retVal; + } + + @Bean(name = "mySystemProviderR4") + public ca.uhn.fhir.jpa.provider.r4.JpaSystemProviderR4 systemProviderR4(FhirContext theFhirContext) { + ca.uhn.fhir.jpa.provider.r4.JpaSystemProviderR4 retVal = new ca.uhn.fhir.jpa.provider.r4.JpaSystemProviderR4(); + retVal.setContext(theFhirContext); + retVal.setDao(systemDaoR4()); + return retVal; + } + + @Bean + public ITermLoaderSvc termLoaderService(ITermDeferredStorageSvc theDeferredStorageSvc, ITermCodeSystemStorageSvc theCodeSystemStorageSvc) { + return new TermLoaderSvcImpl(theDeferredStorageSvc, theCodeSystemStorageSvc); + } + + @Bean + public ITermReadSvcR4 terminologyService() { + return new TermReadSvcR4(); + } + +} + /* * #%L * HAPI FHIR JPA Server @@ -47,81 +97,3 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; * limitations under the License. * #L% */ - -@Configuration -@EnableTransactionManagement -public class BaseR4Config extends BaseConfigDstu3Plus { - - @Override - public FhirContext fhirContext() { - return fhirContextR4(); - } - - @Bean - @Override - public ITermVersionAdapterSvc terminologyVersionAdapterSvc() { - return new TermVersionAdapterSvcR4(); - } - - @Bean - @Primary - public FhirContext fhirContextR4() { - FhirContext retVal = FhirContext.forR4(); - - // Don't strip versions in some places - ParserOptions parserOptions = retVal.getParserOptions(); - parserOptions.setDontStripVersionsFromReferencesAtPaths("AuditEvent.entity.what"); - - return retVal; - } - - @Bean - public ITransactionProcessorVersionAdapter transactionProcessorVersionFacade() { - return new TransactionProcessorVersionAdapterR4(); - } - - @Bean(name = GRAPHQL_PROVIDER_NAME) - @Lazy - public GraphQLProvider graphQLProvider() { - return new GraphQLProvider(fhirContextR4(), validationSupportChain(), graphqlStorageServices()); - } - - @Bean(name = "myResourceCountsCache") - public ResourceCountCache resourceCountsCache() { - ResourceCountCache retVal = new ResourceCountCache(() -> systemDaoR4().getResourceCounts()); - retVal.setCacheMillis(4 * DateUtils.MILLIS_PER_HOUR); - return retVal; - } - - @Bean(autowire = Autowire.BY_TYPE) - public IFulltextSearchSvc searchDaoR4() { - FulltextSearchSvcImpl searchDao = new FulltextSearchSvcImpl(); - return searchDao; - } - - @Bean(name = "mySystemDaoR4", autowire = Autowire.BY_NAME) - public IFhirSystemDao systemDaoR4() { - ca.uhn.fhir.jpa.dao.r4.FhirSystemDaoR4 retVal = new ca.uhn.fhir.jpa.dao.r4.FhirSystemDaoR4(); - return retVal; - } - - @Bean(name = "mySystemProviderR4") - public ca.uhn.fhir.jpa.provider.r4.JpaSystemProviderR4 systemProviderR4() { - ca.uhn.fhir.jpa.provider.r4.JpaSystemProviderR4 retVal = new ca.uhn.fhir.jpa.provider.r4.JpaSystemProviderR4(); - retVal.setContext(fhirContextR4()); - retVal.setDao(systemDaoR4()); - return retVal; - } - - @Bean - public ITermLoaderSvc termLoaderService(ITermDeferredStorageSvc theDeferredStorageSvc, ITermCodeSystemStorageSvc theCodeSystemStorageSvc) { - return new TermLoaderSvcImpl(theDeferredStorageSvc, theCodeSystemStorageSvc); - } - - @Override - @Bean(autowire = Autowire.BY_TYPE) - public ITermReadSvcR4 terminologyService() { - return new TermReadSvcR4(); - } - -} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r5/FhirContextR5Config.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r5/FhirContextR5Config.java new file mode 100644 index 00000000000..042e6f22b18 --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r5/FhirContextR5Config.java @@ -0,0 +1,20 @@ +package ca.uhn.fhir.jpa.config.r5; + +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.context.ParserOptions; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Primary; + +public class FhirContextR5Config { + @Bean(name = "primaryFhirContext") + @Primary + public FhirContext fhirContextR5() { + FhirContext retVal = FhirContext.forR5(); + + // Don't strip versions in some places + ParserOptions parserOptions = retVal.getParserOptions(); + parserOptions.setDontStripVersionsFromReferencesAtPaths("AuditEvent.entity.what"); + + return retVal; + } +} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r5/BaseR5Config.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r5/JpaR5Config.java similarity index 63% rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r5/BaseR5Config.java rename to hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r5/JpaR5Config.java index ba338d1b113..d9b1f03bf27 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r5/BaseR5Config.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/r5/JpaR5Config.java @@ -1,11 +1,11 @@ package ca.uhn.fhir.jpa.config.r5; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.ParserOptions; +import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; -import ca.uhn.fhir.jpa.config.BaseConfigDstu3Plus; -import ca.uhn.fhir.jpa.dao.FulltextSearchSvcImpl; -import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc; +import ca.uhn.fhir.jpa.config.GeneratedDaoAndResourceProviderConfigR5; +import ca.uhn.fhir.jpa.config.JpaConfig; +import ca.uhn.fhir.jpa.config.SharedConfigDstu3Plus; import ca.uhn.fhir.jpa.dao.ITransactionProcessorVersionAdapter; import ca.uhn.fhir.jpa.dao.r5.TransactionProcessorVersionAdapterR5; import ca.uhn.fhir.jpa.graphql.GraphQLProvider; @@ -17,15 +17,13 @@ import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc; import ca.uhn.fhir.jpa.term.api.ITermLoaderSvc; import ca.uhn.fhir.jpa.term.api.ITermReadSvcR5; import ca.uhn.fhir.jpa.term.api.ITermVersionAdapterSvc; -import ca.uhn.fhir.jpa.util.ResourceCountCache; -import org.apache.commons.lang3.time.DateUtils; import org.hl7.fhir.r5.model.Bundle; import org.hl7.fhir.r5.model.Meta; -import org.springframework.beans.factory.annotation.Autowire; +import org.hl7.fhir.utilities.graphql.IGraphQLStorageServices; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Lazy; -import org.springframework.context.annotation.Primary; import org.springframework.transaction.annotation.EnableTransactionManagement; /* @@ -50,65 +48,40 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; @Configuration @EnableTransactionManagement -public class BaseR5Config extends BaseConfigDstu3Plus { - - @Override - public FhirContext fhirContext() { - return fhirContextR5(); - } - +@Import({ + FhirContextR5Config.class, + GeneratedDaoAndResourceProviderConfigR5.class, + SharedConfigDstu3Plus.class, + JpaConfig.class +}) +public class JpaR5Config { @Bean - @Override public ITermVersionAdapterSvc terminologyVersionAdapterSvc() { return new TermVersionAdapterSvcR5(); } - @Bean - @Primary - public FhirContext fhirContextR5() { - FhirContext retVal = FhirContext.forR5(); - - // Don't strip versions in some places - ParserOptions parserOptions = retVal.getParserOptions(); - parserOptions.setDontStripVersionsFromReferencesAtPaths("AuditEvent.entity.what"); - - return retVal; - } @Bean public ITransactionProcessorVersionAdapter transactionProcessorVersionFacade() { return new TransactionProcessorVersionAdapterR5(); } - @Bean(name = GRAPHQL_PROVIDER_NAME) + @Bean(name = JpaConfig.GRAPHQL_PROVIDER_NAME) @Lazy - public GraphQLProvider graphQLProvider() { - return new GraphQLProvider(fhirContextR5(), validationSupportChain(), graphqlStorageServices()); + public GraphQLProvider graphQLProvider(FhirContext theFhirContext, IGraphQLStorageServices theGraphqlStorageServices, IValidationSupport theValidationSupport) { + return new GraphQLProvider(theFhirContext, theValidationSupport, theGraphqlStorageServices); } - @Bean(name = "myResourceCountsCache") - public ResourceCountCache resourceCountsCache() { - ResourceCountCache retVal = new ResourceCountCache(() -> systemDaoR5().getResourceCounts()); - retVal.setCacheMillis(4 * DateUtils.MILLIS_PER_HOUR); - return retVal; - } - - @Bean(autowire = Autowire.BY_TYPE) - public IFulltextSearchSvc searchDaoR5() { - FulltextSearchSvcImpl searchDao = new FulltextSearchSvcImpl(); - return searchDao; - } - - @Bean(name = "mySystemDaoR5", autowire = Autowire.BY_NAME) + @Bean(name = "mySystemDaoR5") public IFhirSystemDao systemDaoR5() { ca.uhn.fhir.jpa.dao.r5.FhirSystemDaoR5 retVal = new ca.uhn.fhir.jpa.dao.r5.FhirSystemDaoR5(); return retVal; } @Bean(name = "mySystemProviderR5") - public ca.uhn.fhir.jpa.provider.r5.JpaSystemProviderR5 systemProviderR5() { + public ca.uhn.fhir.jpa.provider.r5.JpaSystemProviderR5 systemProviderR5(FhirContext theFhirContext) { ca.uhn.fhir.jpa.provider.r5.JpaSystemProviderR5 retVal = new ca.uhn.fhir.jpa.provider.r5.JpaSystemProviderR5(); - retVal.setContext(fhirContextR5()); + retVal.setContext(theFhirContext); retVal.setDao(systemDaoR5()); return retVal; } @@ -118,8 +91,7 @@ public class BaseR5Config extends BaseConfigDstu3Plus { return new TermLoaderSvcImpl(theDeferredStorageSvc, theCodeSystemStorageSvc); } - @Override - @Bean(autowire = Autowire.BY_TYPE) + @Bean public ITermReadSvcR5 terminologyService() { return new TermReadSvcR5(); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/util/HapiEntityManagerFactoryUtil.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/util/HapiEntityManagerFactoryUtil.java new file mode 100644 index 00000000000..721ca76b35f --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/util/HapiEntityManagerFactoryUtil.java @@ -0,0 +1,28 @@ +package ca.uhn.fhir.jpa.config.util; + +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.jpa.config.HapiFhirHibernateJpaDialect; +import ca.uhn.fhir.jpa.config.HapiFhirLocalContainerEntityManagerFactoryBean; +import org.hibernate.jpa.HibernatePersistenceProvider; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; + +public final class HapiEntityManagerFactoryUtil { + private HapiEntityManagerFactoryUtil() {} + /** + * This method provides a partially completed entity manager + * factory with HAPI FHIR customizations + */ + public static LocalContainerEntityManagerFactoryBean newEntityManagerFactory(ConfigurableListableBeanFactory myConfigurableListableBeanFactory, FhirContext theFhirContext) { + LocalContainerEntityManagerFactoryBean retVal = new HapiFhirLocalContainerEntityManagerFactoryBean(myConfigurableListableBeanFactory); + configureEntityManagerFactory(retVal, theFhirContext); + return retVal; + } + + public static void configureEntityManagerFactory(LocalContainerEntityManagerFactoryBean theFactory, FhirContext theFhirContext) { + theFactory.setJpaDialect(new HapiFhirHibernateJpaDialect(theFhirContext.getLocalizer())); + theFactory.setPackagesToScan("ca.uhn.fhir.jpa.model.entity", "ca.uhn.fhir.jpa.entity"); + theFactory.setPersistenceProvider(new HibernatePersistenceProvider()); + } + +} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/util/ResourceCountCacheUtil.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/util/ResourceCountCacheUtil.java new file mode 100644 index 00000000000..987da2b60ad --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/util/ResourceCountCacheUtil.java @@ -0,0 +1,14 @@ +package ca.uhn.fhir.jpa.config.util; + +import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; +import ca.uhn.fhir.jpa.util.ResourceCountCache; +import org.apache.commons.lang3.time.DateUtils; + +public final class ResourceCountCacheUtil { + private ResourceCountCacheUtil() {} + public static ResourceCountCache newResourceCountCache(IFhirSystemDao theSystemDao) { + ResourceCountCache retVal = new ResourceCountCache(() -> theSystemDao.getResourceCounts()); + retVal.setCacheMillis(4 * DateUtils.MILLIS_PER_HOUR); + return retVal; + } +} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/util/ValidationSupportConfigUtil.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/util/ValidationSupportConfigUtil.java new file mode 100644 index 00000000000..408d53d859e --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/util/ValidationSupportConfigUtil.java @@ -0,0 +1,16 @@ +package ca.uhn.fhir.jpa.config.util; + +import ca.uhn.fhir.jpa.validation.JpaValidationSupportChain; +import org.hl7.fhir.common.hapi.validation.support.CachingValidationSupport; + +public final class ValidationSupportConfigUtil { + private ValidationSupportConfigUtil() {} + + public static CachingValidationSupport newCachingValidationSupport(JpaValidationSupportChain theJpaValidationSupportChain) { + // Short timeout for code translation because TermConceptMappingSvcImpl has its own caching + CachingValidationSupport.CacheTimeouts cacheTimeouts = CachingValidationSupport.CacheTimeouts.defaultValues() + .setTranslateCodeMillis(1000); + + return new CachingValidationSupport(theJpaValidationSupportChain, cacheTimeouts); + } +} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirSystemDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirSystemDao.java index 773371ae9fc..7fe7cce24bb 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirSystemDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirSystemDao.java @@ -7,14 +7,13 @@ import ca.uhn.fhir.jpa.util.ResourceCountCache; import ca.uhn.fhir.rest.api.RestOperationTypeEnum; import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.api.server.RequestDetails; -import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails; import ca.uhn.fhir.util.StopWatch; import com.google.common.annotations.VisibleForTesting; import org.hl7.fhir.instance.model.api.IBaseBundle; import org.hl7.fhir.instance.model.api.IBaseResource; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.ApplicationContext; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -48,11 +47,11 @@ import java.util.Map; public abstract class BaseHapiFhirSystemDao extends BaseHapiFhirDao implements IFhirSystemDao { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseHapiFhirSystemDao.class); - @Autowired - @Qualifier("myResourceCountsCache") public ResourceCountCache myResourceCountsCache; @Autowired private TransactionProcessor myTransactionProcessor; + @Autowired + private ApplicationContext myApplicationContext; @VisibleForTesting public void setTransactionProcessorForUnitTest(TransactionProcessor theTransactionProcessor) { @@ -89,6 +88,10 @@ public abstract class BaseHapiFhirSystemDao extends B @Nullable @Override public Map getResourceCountsFromCache() { + if (myResourceCountsCache == null) { + // Lazy load this to avoid a circular dependency + myResourceCountsCache = myApplicationContext.getBean("myResourceCountsCache", ResourceCountCache.class); + } return myResourceCountsCache.get(); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoValueSetDstu2.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoValueSetDstu2.java index efbd0696ad6..47ed555de0f 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoValueSetDstu2.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoValueSetDstu2.java @@ -20,12 +20,12 @@ package ca.uhn.fhir.jpa.dao; * #L% */ -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.support.DefaultProfileValidationSupport; import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.IValidationSupport.CodeValidationResult; import ca.uhn.fhir.context.support.ValueSetExpansionOptions; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoCodeSystem; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoValueSet; import ca.uhn.fhir.jpa.model.entity.BaseHasResource; @@ -51,7 +51,6 @@ import org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.instance.model.api.IPrimitiveType; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import javax.annotation.Nonnull; import javax.annotation.PostConstruct; @@ -69,14 +68,13 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank; public class FhirResourceDaoValueSetDstu2 extends BaseHapiFhirResourceDao implements IFhirResourceDaoValueSet, IFhirResourceDaoCodeSystem { + private static FhirContext ourRiCtx; + private DefaultProfileValidationSupport myDefaultProfileValidationSupport; @Autowired private IValidationSupport myJpaValidationSupport; - @Autowired - @Qualifier("myFhirContextDstu2Hl7Org") - private FhirContext myRiCtx; @Autowired private FhirContext myFhirContext; @@ -160,7 +158,7 @@ public class FhirResourceDaoValueSetDstu2 extends BaseHapiFhirResourceDao theContains, String theSystem, String theCode) { for (ExpansionContains nextCode : theContains) { diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/HistoryBuilderFactory.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/HistoryBuilderFactory.java index 162294973d5..0e5fbff9ea2 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/HistoryBuilderFactory.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/HistoryBuilderFactory.java @@ -20,7 +20,7 @@ package ca.uhn.fhir.jpa.dao; * #L% */ -import ca.uhn.fhir.jpa.config.BaseConfig; +import ca.uhn.fhir.jpa.config.JpaConfig; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; @@ -33,7 +33,7 @@ public class HistoryBuilderFactory { private ApplicationContext myApplicationContext; public HistoryBuilder newHistoryBuilder(@Nullable String theResourceType, @Nullable Long theResourceId, @Nullable Date theRangeStartInclusive, @Nullable Date theRangeEndInclusive) { - return (HistoryBuilder) myApplicationContext.getBean(BaseConfig.HISTORY_BUILDER, theResourceType, theResourceId, theRangeStartInclusive, theRangeEndInclusive); + return (HistoryBuilder) myApplicationContext.getBean(JpaConfig.HISTORY_BUILDER, theResourceType, theResourceId, theRangeStartInclusive, theRangeEndInclusive); } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilderFactory.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilderFactory.java index 123886e1766..48f641d3df3 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilderFactory.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilderFactory.java @@ -22,7 +22,7 @@ package ca.uhn.fhir.jpa.dao; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.api.dao.IDao; -import ca.uhn.fhir.jpa.config.BaseConfig; +import ca.uhn.fhir.jpa.config.JpaConfig; import org.hl7.fhir.instance.model.api.IBaseResource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; @@ -35,7 +35,7 @@ public class SearchBuilderFactory { private DaoConfig myDaoConfig; public ISearchBuilder newSearchBuilder(IDao theDao, String theResourceName, Class theResourceType) { - return (ISearchBuilder) myApplicationContext.getBean(BaseConfig.SEARCH_BUILDER, theDao, theResourceName, theResourceType, myDaoConfig); + return (ISearchBuilder) myApplicationContext.getBean(JpaConfig.SEARCH_BUILDER, theDao, theResourceName, theResourceType, myDaoConfig); } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/ValueSetOperationProvider.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/ValueSetOperationProvider.java index 881e2115e65..e6f5bba9283 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/ValueSetOperationProvider.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/ValueSetOperationProvider.java @@ -28,7 +28,7 @@ import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoValueSet; -import ca.uhn.fhir.jpa.config.BaseConfig; +import ca.uhn.fhir.jpa.config.JpaConfig; import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc; import ca.uhn.fhir.jpa.model.util.JpaConstants; import ca.uhn.fhir.jpa.search.autocomplete.ValueSetAutocompleteOptions; @@ -69,7 +69,7 @@ public class ValueSetOperationProvider extends BaseJpaProvider { @Autowired private ITermReadSvc myTermReadSvc; @Autowired - @Qualifier(BaseConfig.JPA_VALIDATION_SUPPORT_CHAIN) + @Qualifier(JpaConfig.JPA_VALIDATION_SUPPORT_CHAIN) private ValidationSupportChain myValidationSupportChain; @Autowired private IValidationSupport myValidationSupport; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/r4/BaseJpaResourceProviderCodeSystemR4.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/r4/BaseJpaResourceProviderCodeSystemR4.java index cd66647b94d..a4074e2a3e0 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/r4/BaseJpaResourceProviderCodeSystemR4.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/r4/BaseJpaResourceProviderCodeSystemR4.java @@ -1,11 +1,11 @@ package ca.uhn.fhir.jpa.provider.r4; -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.support.ConceptValidationOptions; import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.ValidationSupportContext; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoCodeSystem; -import ca.uhn.fhir.jpa.config.BaseConfig; +import ca.uhn.fhir.jpa.config.JpaConfig; import ca.uhn.fhir.jpa.model.util.JpaConstants; import ca.uhn.fhir.jpa.provider.BaseJpaResourceProviderValueSetDstu2; import ca.uhn.fhir.jpa.term.api.ITermReadSvcR4; @@ -53,7 +53,7 @@ import java.util.List; public class BaseJpaResourceProviderCodeSystemR4 extends JpaResourceProviderR4 { @Autowired - @Qualifier(BaseConfig.JPA_VALIDATION_SUPPORT_CHAIN) + @Qualifier(JpaConfig.JPA_VALIDATION_SUPPORT_CHAIN) private ValidationSupportChain myValidationSupportChain; @Autowired diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaBundleProviderFactory.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaBundleProviderFactory.java index 451b2737af1..dd22695a82e 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaBundleProviderFactory.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaBundleProviderFactory.java @@ -20,7 +20,7 @@ package ca.uhn.fhir.jpa.search; * #L% */ -import ca.uhn.fhir.jpa.config.BaseConfig; +import ca.uhn.fhir.jpa.config.JpaConfig; import ca.uhn.fhir.jpa.dao.ISearchBuilder; import ca.uhn.fhir.jpa.entity.Search; import ca.uhn.fhir.rest.api.server.RequestDetails; @@ -33,16 +33,16 @@ public class PersistedJpaBundleProviderFactory { private ApplicationContext myApplicationContext; public PersistedJpaBundleProvider newInstance(RequestDetails theRequest, String theUuid) { - Object retVal = myApplicationContext.getBean(BaseConfig.PERSISTED_JPA_BUNDLE_PROVIDER, theRequest, theUuid); + Object retVal = myApplicationContext.getBean(JpaConfig.PERSISTED_JPA_BUNDLE_PROVIDER, theRequest, theUuid); return (PersistedJpaBundleProvider) retVal; } public PersistedJpaBundleProvider newInstance(RequestDetails theRequest, Search theSearch) { - Object retVal = myApplicationContext.getBean(BaseConfig.PERSISTED_JPA_BUNDLE_PROVIDER_BY_SEARCH, theRequest, theSearch); + Object retVal = myApplicationContext.getBean(JpaConfig.PERSISTED_JPA_BUNDLE_PROVIDER_BY_SEARCH, theRequest, theSearch); return (PersistedJpaBundleProvider) retVal; } public PersistedJpaSearchFirstPageBundleProvider newInstanceFirstPage(RequestDetails theRequestDetails, Search theSearch, SearchCoordinatorSvcImpl.SearchTask theTask, ISearchBuilder theSearchBuilder) { - return (PersistedJpaSearchFirstPageBundleProvider) myApplicationContext.getBean(BaseConfig.PERSISTED_JPA_SEARCH_FIRST_PAGE_BUNDLE_PROVIDER, theRequestDetails, theSearch, theTask, theSearchBuilder); + return (PersistedJpaSearchFirstPageBundleProvider) myApplicationContext.getBean(JpaConfig.PERSISTED_JPA_SEARCH_FIRST_PAGE_BUNDLE_PROVIDER, theRequestDetails, theSearch, theTask, theSearchBuilder); } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcDstu2.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcDstu2.java index f134e6395c0..aee5b2af2b2 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcDstu2.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcDstu2.java @@ -20,10 +20,10 @@ package ca.uhn.fhir.jpa.term; * #L% */ -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.support.ConceptValidationOptions; import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.ValueSetExpansionOptions; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt; import ca.uhn.fhir.model.dstu2.composite.CodingDt; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportSvcImplR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportSvcImplR4Test.java index 8f6eee3ed80..6a5a3cf6711 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportSvcImplR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportSvcImplR4Test.java @@ -774,7 +774,7 @@ public class BulkDataExportSvcImplR4Test extends BaseJpaR4Test { } private List readBulkExportContentsIntoResources(String theContents, Class theClass) { - IParser iParser = myFhirCtx.newJsonParser(); + IParser iParser = myFhirContext.newJsonParser(); return Arrays.stream(theContents.split("\n")) .map(iParser::parseResource) .map(theClass::cast) diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/imprt/svc/BulkDataImportR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/imprt/svc/BulkDataImportR4Test.java index caf0fb1bd90..4a778989a8d 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/imprt/svc/BulkDataImportR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/imprt/svc/BulkDataImportR4Test.java @@ -203,10 +203,10 @@ public class BulkDataImportR4Test extends BaseJpaR4Test implements ITestDataBuil StringBuilder fileContents = new StringBuilder(); for (int transactionIdx = 0; transactionIdx < transactionsPerFile; transactionIdx++) { - BundleBuilder bundleBuilder = new BundleBuilder(myFhirCtx); + BundleBuilder bundleBuilder = new BundleBuilder(myFhirContext); IBaseResource patient = buildPatient(withFamily("FAM " + fileIndex + " " + transactionIdx), withIdentifier(null, "patient" + counter++)); bundleBuilder.addTransactionCreateEntry(patient); - fileContents.append(myFhirCtx.newJsonParser().setPrettyPrint(false).encodeResourceToString(bundleBuilder.getBundle())); + fileContents.append(myFhirContext.newJsonParser().setPrettyPrint(false).encodeResourceToString(bundleBuilder.getBundle())); fileContents.append("\n"); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestDstu2Config.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestDstu2Config.java index db3174707f4..fadfb104b34 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestDstu2Config.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestDstu2Config.java @@ -1,5 +1,8 @@ package ca.uhn.fhir.jpa.config; +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.jpa.config.util.HapiEntityManagerFactoryUtil; +import ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect; import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; @@ -8,7 +11,6 @@ import ca.uhn.fhir.validation.ResultSeverityEnum; import net.ttddyy.dsproxy.listener.ThreadQueryCountHolder; import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder; import org.apache.commons.dbcp2.BasicDataSource; -import ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -18,7 +20,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Lazy; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.transaction.annotation.EnableTransactionManagement; import javax.sql.DataSource; import java.sql.Connection; @@ -29,9 +30,13 @@ import java.util.concurrent.TimeUnit; import static org.junit.jupiter.api.Assertions.fail; @Configuration -@Import({TestJPAConfig.class, TestHibernateSearchAddInConfig.DefaultLuceneHeap.class}) -@EnableTransactionManagement() -public class TestDstu2Config extends BaseJavaConfigDstu2 { +@Import({ + JpaDstu2Config.class, + HapiJpaConfig.class, + TestJPAConfig.class, + TestHibernateSearchAddInConfig.DefaultLuceneHeap.class +}) +public class TestDstu2Config { private static final Logger ourLog = LoggerFactory.getLogger(TestDstu2Config.class); private static int ourMaxThreads; @@ -129,10 +134,9 @@ public class TestDstu2Config extends BaseJavaConfigDstu2 { return dataSource; } - @Override @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory) { - LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory(theConfigurableListableBeanFactory); + public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory, FhirContext theFhirContext) { + LocalContainerEntityManagerFactoryBean retVal = HapiEntityManagerFactoryUtil.newEntityManagerFactory(theConfigurableListableBeanFactory, theFhirContext); retVal.setPersistenceUnitName("PU_HapiFhirJpaDstu2"); retVal.setDataSource(dataSource()); retVal.setJpaProperties(jpaProperties()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestDstu3Config.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestDstu3Config.java index 29013ba4a32..2d4c3591343 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestDstu3Config.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestDstu3Config.java @@ -1,5 +1,9 @@ package ca.uhn.fhir.jpa.config; +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.jpa.config.dstu3.JpaDstu3Config; +import ca.uhn.fhir.jpa.config.util.HapiEntityManagerFactoryUtil; +import ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect; import ca.uhn.fhir.jpa.subscription.match.deliver.email.EmailSenderImpl; import ca.uhn.fhir.jpa.subscription.match.deliver.email.IEmailSender; import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener; @@ -11,7 +15,7 @@ import ca.uhn.fhir.rest.server.mail.MailSvc; import ca.uhn.fhir.validation.ResultSeverityEnum; import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder; import org.apache.commons.dbcp2.BasicDataSource; -import ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect; +import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.annotation.Bean; @@ -21,7 +25,6 @@ import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Primary; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.transaction.annotation.EnableTransactionManagement; import javax.sql.DataSource; import java.sql.Connection; @@ -31,9 +34,13 @@ import java.util.concurrent.TimeUnit; import static org.junit.jupiter.api.Assertions.fail; @Configuration -@Import({TestJPAConfig.class, TestHibernateSearchAddInConfig.DefaultLuceneHeap.class}) -@EnableTransactionManagement() -public class TestDstu3Config extends BaseJavaConfigDstu3 { +@Import({ + JpaDstu3Config.class, + HapiJpaConfig.class, + TestJPAConfig.class, + TestHibernateSearchAddInConfig.DefaultLuceneHeap.class +}) +public class TestDstu3Config { static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TestDstu3Config.class); private Exception myLastStackTrace; @@ -139,10 +146,9 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 { return new EmailSenderImpl(mailSvc); } - @Override @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory) { - LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory(theConfigurableListableBeanFactory); + public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory, FhirContext theFhirContext) { + LocalContainerEntityManagerFactoryBean retVal = HapiEntityManagerFactoryUtil.newEntityManagerFactory(theConfigurableListableBeanFactory, theFhirContext); retVal.setPersistenceUnitName("PU_HapiFhirJpaDstu3"); retVal.setDataSource(dataSource()); retVal.setJpaProperties(jpaProperties()); @@ -172,12 +178,12 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 { */ @Bean @Lazy - public RequestValidatingInterceptor requestValidatingInterceptor() { + public RequestValidatingInterceptor requestValidatingInterceptor(FhirInstanceValidator theFhirInstanceValidator) { RequestValidatingInterceptor requestValidator = new RequestValidatingInterceptor(); requestValidator.setFailOnSeverity(ResultSeverityEnum.ERROR); requestValidator.setAddResponseHeaderOnSeverity(null); requestValidator.setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum.INFORMATION); - requestValidator.addValidatorModule(instanceValidator()); + requestValidator.addValidatorModule(theFhirInstanceValidator); return requestValidator; } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestHibernateSearchAddInConfig.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestHibernateSearchAddInConfig.java index 06e764e8bc7..f6b7319f603 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestHibernateSearchAddInConfig.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestHibernateSearchAddInConfig.java @@ -68,8 +68,8 @@ public class TestHibernateSearchAddInConfig { } - @Bean(name={"searchDao", "searchDaoDstu2", "searchDaoDstu3", "searchDaoR4", "searchDaoR5"}) - public IFulltextSearchSvc searchDao() { + @Bean + public IFulltextSearchSvc fullTextSearchSvc() { ourLog.info("Hibernate Search: FulltextSearchSvcImpl present"); return new FulltextSearchSvcImpl(); } @@ -88,9 +88,9 @@ public class TestHibernateSearchAddInConfig { }; } - @Primary // force override of default bean which might have a variety of names - @Bean(name={"searchDao", "searchDaoDstu2", "searchDaoDstu3", "searchDaoR4", "searchDaoR5"}) - public IFulltextSearchSvc searchDao() { + @Primary + @Bean + public IFulltextSearchSvc fullTextSearchSvc() { ourLog.info("Hibernate Search: FulltextSearchSvcImpl not available"); return null; } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestR4Config.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestR4Config.java index a265b570749..cd7239c1fe3 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestR4Config.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestR4Config.java @@ -1,10 +1,10 @@ package ca.uhn.fhir.jpa.config; -import ca.uhn.fhir.jpa.batch.BatchJobsConfig; -import ca.uhn.fhir.jpa.batch.api.IBatchJobSubmitter; -import ca.uhn.fhir.jpa.batch.svc.BatchJobSubmitterImpl; +import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.binstore.IBinaryStorageSvc; import ca.uhn.fhir.jpa.binstore.MemoryBinaryStorageSvcImpl; +import ca.uhn.fhir.jpa.config.r4.JpaR4Config; +import ca.uhn.fhir.jpa.config.util.HapiEntityManagerFactoryUtil; import ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect; import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; @@ -14,7 +14,7 @@ import net.ttddyy.dsproxy.listener.SingleQueryCountHolder; import net.ttddyy.dsproxy.listener.logging.SLF4JLogLevel; import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder; import org.apache.commons.dbcp2.BasicDataSource; -import org.hibernate.jpa.HibernatePersistenceProvider; +import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.annotation.Bean; @@ -22,7 +22,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Lazy; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.transaction.annotation.EnableTransactionManagement; import javax.sql.DataSource; import java.sql.Connection; @@ -32,9 +31,13 @@ import java.util.concurrent.TimeUnit; import static org.junit.jupiter.api.Assertions.fail; @Configuration -@Import({TestJPAConfig.class, BatchJobsConfig.class, TestHibernateSearchAddInConfig.DefaultLuceneHeap.class}) -@EnableTransactionManagement() -public class TestR4Config extends BaseJavaConfigR4 { +@Import({ + JpaR4Config.class, + HapiJpaConfig.class, + TestJPAConfig.class, + TestHibernateSearchAddInConfig.DefaultLuceneHeap.class +}) +public class TestR4Config { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TestR4Config.class); public static Integer ourMaxThreads; @@ -60,12 +63,6 @@ public class TestR4Config extends BaseJavaConfigR4 { private Exception myLastStackTrace; - @Override - @Bean - public IBatchJobSubmitter batchJobSubmitter() { - return new BatchJobSubmitterImpl(); - } - @Bean public CircularQueueCaptureQueriesListener captureQueriesListener() { return new CircularQueueCaptureQueriesListener(); @@ -144,14 +141,9 @@ public class TestR4Config extends BaseJavaConfigR4 { } - @Override @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory) { - LocalContainerEntityManagerFactoryBean retVal = new HapiFhirLocalContainerEntityManagerFactoryBean(theConfigurableListableBeanFactory); - configureEntityManagerFactory(retVal, fhirContext()); - retVal.setJpaDialect(new HapiFhirHibernateJpaDialect(fhirContext().getLocalizer())); - retVal.setPackagesToScan("ca.uhn.fhir.jpa.model.entity", "ca.uhn.fhir.jpa.entity"); - retVal.setPersistenceProvider(new HibernatePersistenceProvider()); + public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory, FhirContext theFhirContext) { + LocalContainerEntityManagerFactoryBean retVal = HapiEntityManagerFactoryUtil.newEntityManagerFactory(theConfigurableListableBeanFactory, theFhirContext); retVal.setPersistenceUnitName("PU_HapiFhirJpaR4"); retVal.setDataSource(dataSource()); retVal.setJpaProperties(jpaProperties()); @@ -180,12 +172,12 @@ public class TestR4Config extends BaseJavaConfigR4 { */ @Bean @Lazy - public RequestValidatingInterceptor requestValidatingInterceptor() { + public RequestValidatingInterceptor requestValidatingInterceptor(FhirInstanceValidator theFhirInstanceValidator) { RequestValidatingInterceptor requestValidator = new RequestValidatingInterceptor(); requestValidator.setFailOnSeverity(ResultSeverityEnum.ERROR); requestValidator.setAddResponseHeaderOnSeverity(null); requestValidator.setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum.INFORMATION); - requestValidator.addValidatorModule(instanceValidator()); + requestValidator.addValidatorModule(theFhirInstanceValidator); return requestValidator; } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestR5Config.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestR5Config.java index 2c5344c9d05..7ffccad4bcb 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestR5Config.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestR5Config.java @@ -1,7 +1,11 @@ package ca.uhn.fhir.jpa.config; +import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.binstore.IBinaryStorageSvc; import ca.uhn.fhir.jpa.binstore.MemoryBinaryStorageSvcImpl; +import ca.uhn.fhir.jpa.config.r5.JpaR5Config; +import ca.uhn.fhir.jpa.config.util.HapiEntityManagerFactoryUtil; +import ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect; import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; @@ -9,7 +13,7 @@ import ca.uhn.fhir.validation.ResultSeverityEnum; import net.ttddyy.dsproxy.listener.SingleQueryCountHolder; import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder; import org.apache.commons.dbcp2.BasicDataSource; -import ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect; +import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.annotation.Bean; @@ -18,7 +22,6 @@ import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Lazy; import org.springframework.core.env.Environment; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.transaction.annotation.EnableTransactionManagement; import javax.sql.DataSource; import java.sql.Connection; @@ -27,9 +30,13 @@ import java.util.Properties; import static org.junit.jupiter.api.Assertions.fail; @Configuration -@Import({TestJPAConfig.class, TestHibernateSearchAddInConfig.DefaultLuceneHeap.class}) -@EnableTransactionManagement() -public class TestR5Config extends BaseJavaConfigR5 { +@Import({ + JpaR5Config.class, + HapiJpaConfig.class, + TestJPAConfig.class, + TestHibernateSearchAddInConfig.DefaultLuceneHeap.class +}) +public class TestR5Config { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TestR5Config.class); public static Integer ourMaxThreads; @@ -134,10 +141,9 @@ public class TestR5Config extends BaseJavaConfigR5 { return new SingleQueryCountHolder(); } - @Override @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory) { - LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory(theConfigurableListableBeanFactory); + public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory, FhirContext theFhirContext) { + LocalContainerEntityManagerFactoryBean retVal = HapiEntityManagerFactoryUtil.newEntityManagerFactory(theConfigurableListableBeanFactory, theFhirContext); retVal.setPersistenceUnitName("PU_HapiFhirJpaR5"); retVal.setDataSource(dataSource()); retVal.setJpaProperties(jpaProperties()); @@ -166,12 +172,12 @@ public class TestR5Config extends BaseJavaConfigR5 { */ @Bean @Lazy - public RequestValidatingInterceptor requestValidatingInterceptor() { + public RequestValidatingInterceptor requestValidatingInterceptor(FhirInstanceValidator theFhirInstanceValidator) { RequestValidatingInterceptor requestValidator = new RequestValidatingInterceptor(); requestValidator.setFailOnSeverity(ResultSeverityEnum.ERROR); requestValidator.setAddResponseHeaderOnSeverity(null); requestValidator.setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum.INFORMATION); - requestValidator.addValidatorModule(instanceValidator()); + requestValidator.addValidatorModule(theFhirInstanceValidator); return requestValidator; } 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 d1f67ab4d3f..6eea53776ff 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 @@ -10,7 +10,7 @@ import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; import ca.uhn.fhir.jpa.api.model.ExpungeOptions; import ca.uhn.fhir.jpa.api.svc.ISearchCoordinatorSvc; import ca.uhn.fhir.jpa.bulk.export.api.IBulkDataExportSvc; -import ca.uhn.fhir.jpa.config.BaseConfig; +import ca.uhn.fhir.jpa.config.JpaConfig; import ca.uhn.fhir.jpa.dao.data.IForcedIdDao; import ca.uhn.fhir.jpa.dao.data.IResourceHistoryTableDao; import ca.uhn.fhir.jpa.dao.data.IResourceIndexedComboTokensNonUniqueDao; @@ -194,7 +194,7 @@ public abstract class BaseJpaTest extends BaseTest { private IdHelperService myIdHelperService; @Autowired private MemoryCacheService myMemoryCacheService; - @Qualifier(BaseConfig.JPA_VALIDATION_SUPPORT) + @Qualifier(JpaConfig.JPA_VALIDATION_SUPPORT) @Autowired private IValidationSupport myJpaPersistedValidationSupport; @Autowired @@ -305,7 +305,7 @@ public abstract class BaseJpaTest extends BaseTest { }); } - protected abstract FhirContext getContext(); + protected abstract FhirContext getFhirContext(); protected abstract PlatformTransactionManager getTxManager(); @@ -458,7 +458,7 @@ public abstract class BaseJpaTest extends BaseTest { protected List toUnqualifiedIdValues(IBaseBundle theFound) { List retVal = new ArrayList<>(); - List res = BundleUtil.toListOfResources(getContext(), theFound); + List res = BundleUtil.toListOfResources(getFhirContext(), theFound); int size = res.size(); ourLog.info("Found {} results", size); for (IBaseResource next : res) { @@ -481,7 +481,7 @@ public abstract class BaseJpaTest extends BaseTest { protected List toUnqualifiedVersionlessIdValues(IBaseBundle theFound) { List retVal = new ArrayList<>(); - List res = BundleUtil.toListOfResources(getContext(), theFound); + List res = BundleUtil.toListOfResources(getFhirContext(), theFound); int size = res.size(); ourLog.info("Found {} results", size); for (IBaseResource next : res) { diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/BaseJpaDstu2SystemTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/BaseJpaDstu2SystemTest.java index 0f42439a65a..ae3d1ff799a 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/BaseJpaDstu2SystemTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/BaseJpaDstu2SystemTest.java @@ -4,8 +4,6 @@ import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster; import ca.uhn.fhir.jpa.rp.dstu2.PatientResourceProvider; import ca.uhn.fhir.rest.server.RestfulServer; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; -import ca.uhn.fhir.util.TestUtil; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import javax.servlet.ServletConfig; @@ -26,7 +24,7 @@ public abstract class BaseJpaDstu2SystemTest extends BaseJpaDstu2Test { when(mySrd.getInterceptorBroadcaster()).thenReturn(mock(IInterceptorBroadcaster.class)); if (myServer == null) { - myServer = new RestfulServer(myFhirCtx); + myServer = new RestfulServer(myFhirContext); PatientResourceProvider patientRp = new PatientResourceProvider(); patientRp.setDao(myPatientDao); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/BaseJpaDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/BaseJpaDstu2Test.java index 8da2f74ef13..44ead5d6a4c 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/BaseJpaDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/BaseJpaDstu2Test.java @@ -21,7 +21,6 @@ import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; import ca.uhn.fhir.jpa.search.reindex.IResourceReindexingSvc; import ca.uhn.fhir.jpa.searchparam.registry.ISearchParamRegistryController; -import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import ca.uhn.fhir.jpa.sp.ISearchParamPresenceSvc; import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionLoader; import ca.uhn.fhir.jpa.util.ResourceCountCache; @@ -59,8 +58,8 @@ import ca.uhn.fhir.model.dstu2.resource.ValueSet; import ca.uhn.fhir.parser.IParser; import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory; +import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import org.apache.commons.io.IOUtils; -import org.hl7.fhir.common.hapi.validation.support.CachingValidationSupport; import org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain; import org.hl7.fhir.instance.model.api.IBaseResource; import org.junit.jupiter.api.AfterEach; @@ -133,8 +132,7 @@ public abstract class BaseJpaDstu2Test extends BaseJpaTest { @Autowired protected EntityManager myEntityManager; @Autowired - @Qualifier("myFhirContextDstu2") - protected FhirContext myFhirCtx; + protected FhirContext myFhirContext; @Autowired @Qualifier("myImmunizationDaoDstu2") protected IFhirResourceDao myImmunizationDao; @@ -248,8 +246,8 @@ public abstract class BaseJpaDstu2Test extends BaseJpaTest { } @Override - protected FhirContext getContext() { - return myFhirCtx; + public FhirContext getFhirContext() { + return myFhirContext; } @Override @@ -263,7 +261,7 @@ public abstract class BaseJpaDstu2Test extends BaseJpaTest { fail("Unable to load resource: " + resourceName); } String string = IOUtils.toString(stream, StandardCharsets.UTF_8); - IParser newJsonParser = EncodingEnum.detectEncodingNoDefault(string).newParser(myFhirCtx); + IParser newJsonParser = EncodingEnum.detectEncodingNoDefault(string).newParser(myFhirContext); return newJsonParser.parseResource(type, string); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2SearchNoFtTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2SearchNoFtTest.java index d456d67d255..0124f028dae 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2SearchNoFtTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2SearchNoFtTest.java @@ -2,11 +2,16 @@ package ca.uhn.fhir.jpa.dao.dstu2; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.config.TestHibernateSearchAddInConfig; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.jpa.dao.data.ISearchParamPresentDao; +import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamDate; +import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamNumber; +import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamQuantity; +import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamString; +import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamToken; +import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamUri; +import ca.uhn.fhir.jpa.model.entity.ResourceLink; import ca.uhn.fhir.jpa.searchparam.SearchParamConstants; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; -import ca.uhn.fhir.jpa.dao.data.ISearchParamPresentDao; -import ca.uhn.fhir.jpa.model.entity.*; import ca.uhn.fhir.jpa.util.TestUtil; import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.api.Include; @@ -20,7 +25,23 @@ import ca.uhn.fhir.model.dstu2.composite.IdentifierDt; import ca.uhn.fhir.model.dstu2.composite.PeriodDt; import ca.uhn.fhir.model.dstu2.composite.QuantityDt; import ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt; -import ca.uhn.fhir.model.dstu2.resource.*; +import ca.uhn.fhir.model.dstu2.resource.Appointment; +import ca.uhn.fhir.model.dstu2.resource.ConceptMap; +import ca.uhn.fhir.model.dstu2.resource.Device; +import ca.uhn.fhir.model.dstu2.resource.DiagnosticOrder; +import ca.uhn.fhir.model.dstu2.resource.DiagnosticReport; +import ca.uhn.fhir.model.dstu2.resource.Encounter; +import ca.uhn.fhir.model.dstu2.resource.Immunization; +import ca.uhn.fhir.model.dstu2.resource.Location; +import ca.uhn.fhir.model.dstu2.resource.Medication; +import ca.uhn.fhir.model.dstu2.resource.MedicationOrder; +import ca.uhn.fhir.model.dstu2.resource.Observation; +import ca.uhn.fhir.model.dstu2.resource.Organization; +import ca.uhn.fhir.model.dstu2.resource.Patient; +import ca.uhn.fhir.model.dstu2.resource.Practitioner; +import ca.uhn.fhir.model.dstu2.resource.Subscription; +import ca.uhn.fhir.model.dstu2.resource.Substance; +import ca.uhn.fhir.model.dstu2.resource.ValueSet; import ca.uhn.fhir.model.dstu2.valueset.ContactPointSystemEnum; import ca.uhn.fhir.model.dstu2.valueset.SubscriptionChannelTypeEnum; import ca.uhn.fhir.model.dstu2.valueset.SubscriptionStatusEnum; @@ -34,7 +55,21 @@ import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.SortOrderEnum; import ca.uhn.fhir.rest.api.SortSpec; import ca.uhn.fhir.rest.api.server.IBundleProvider; -import ca.uhn.fhir.rest.param.*; +import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.param.CompositeParam; +import ca.uhn.fhir.rest.param.DateParam; +import ca.uhn.fhir.rest.param.DateRangeParam; +import ca.uhn.fhir.rest.param.NumberParam; +import ca.uhn.fhir.rest.param.ParamPrefixEnum; +import ca.uhn.fhir.rest.param.QuantityParam; +import ca.uhn.fhir.rest.param.ReferenceParam; +import ca.uhn.fhir.rest.param.StringAndListParam; +import ca.uhn.fhir.rest.param.StringOrListParam; +import ca.uhn.fhir.rest.param.StringParam; +import ca.uhn.fhir.rest.param.TokenAndListParam; +import ca.uhn.fhir.rest.param.TokenOrListParam; +import ca.uhn.fhir.rest.param.TokenParam; +import ca.uhn.fhir.rest.param.UriParam; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import org.apache.commons.lang3.StringUtils; import org.hl7.fhir.instance.model.api.IBaseResource; @@ -2112,7 +2147,7 @@ public class FhirResourceDaoDstu2SearchNoFtTest extends BaseJpaDstu2Test { value = myDeviceDao.search(new SearchParameterMap()); if (value.size() > 0) { ourLog.info("Found: " + (value.getResources(0, 1).get(0).getIdElement())); - fail(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(value.getResources(0, 1).get(0))); + fail(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(value.getResources(0, 1).get(0))); } assertEquals(0, value.size().intValue()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2Test.java index 72c12d1891e..0c8fb706cc6 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2Test.java @@ -1510,7 +1510,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test { Set val = myOrganizationDao.searchForIds(new SearchParameterMap("name", new StringParam("P")), null); int initial = val.size(); - Organization org = myFhirCtx.newJsonParser().parseResource(Organization.class, inputStr); + Organization org = myFhirContext.newJsonParser().parseResource(Organization.class, inputStr); myOrganizationDao.create(org, mySrd); val = myOrganizationDao.searchForIds(new SearchParameterMap("name", new StringParam("P")), null); @@ -2084,7 +2084,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test { oid1 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -2096,7 +2096,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test { oid2 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -2108,7 +2108,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test { oid3 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -2120,7 +2120,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test { oid4 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } @@ -2681,7 +2681,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test { IIdType orgId = myOrganizationDao.create(org, mySrd).getId(); Organization returned = myOrganizationDao.read(orgId, mySrd); - String val = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned); + String val = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned); ourLog.info(val); assertThat(val, containsString("")); @@ -2842,16 +2842,16 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test { String stream = IOUtils.toString(getClass().getResourceAsStream("/binu_testpatient_structuredefinition_dstu2.xml"), StandardCharsets.UTF_8); - StructureDefinition sd = myFhirCtx.newXmlParser().parseResource(StructureDefinition.class, stream); + StructureDefinition sd = myFhirContext.newXmlParser().parseResource(StructureDefinition.class, stream); myStructureDefinitionDao.create(sd, mySrd); String rawResource = IOUtils.toString(getClass().getResourceAsStream("/binu_testpatient_resource.json"), StandardCharsets.UTF_8); - IBaseResource parsedResource = myFhirCtx.newJsonParser().parseResource(rawResource); + IBaseResource parsedResource = myFhirContext.newJsonParser().parseResource(rawResource); try { myPatientDao.validate((Patient) parsedResource, null, rawResource, EncodingEnum.JSON, ValidationModeEnum.UPDATE, null, mySrd); fail(); } catch (PreconditionFailedException e) { - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); } } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2ValidateTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2ValidateTest.java index 6b3ab511fe9..86514f49aaf 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2ValidateTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2ValidateTest.java @@ -18,19 +18,17 @@ import ca.uhn.fhir.rest.api.ValidationModeEnum; import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException; import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; -import ca.uhn.fhir.util.TestUtil; import org.hl7.fhir.instance.model.api.IBaseOperationOutcome; import org.hl7.fhir.instance.model.api.IIdType; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; -import static org.hamcrest.Matchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; import static org.junit.jupiter.api.Assertions.fail; public class FhirResourceDaoDstu2ValidateTest extends BaseJpaDstu2Test { @@ -51,7 +49,7 @@ public class FhirResourceDaoDstu2ValidateTest extends BaseJpaDstu2Test { String methodName = "testValidateResourceContainingProfileDeclarationJson"; OperationOutcome outcome = doTestValidateResourceContainingProfileDeclaration(methodName, EncodingEnum.JSON); - String ooString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String ooString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(ooString); assertThat(ooString, containsString("Observation.subject: minimum required = 1, but only found 0")); assertThat(ooString, containsString("Observation.encounter: max allowed = 0, but found 1")); @@ -63,7 +61,7 @@ public class FhirResourceDaoDstu2ValidateTest extends BaseJpaDstu2Test { String methodName = "testValidateResourceContainingProfileDeclarationXml"; OperationOutcome outcome = doTestValidateResourceContainingProfileDeclaration(methodName, EncodingEnum.XML); - String ooString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String ooString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(ooString); assertThat(ooString, containsString("Observation.subject: minimum required = 1, but only found 0")); assertThat(ooString, containsString("Observation.encounter: max allowed = 0, but found 1")); @@ -99,7 +97,7 @@ public class FhirResourceDaoDstu2ValidateTest extends BaseJpaDstu2Test { ValidationModeEnum mode = ValidationModeEnum.CREATE; switch (enc) { case JSON: - encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(input); + encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(input); ourLog.info(encoded); try { myObservationDao.validate(input, null, encoded, EncodingEnum.JSON, mode, null, mySrd); @@ -109,7 +107,7 @@ public class FhirResourceDaoDstu2ValidateTest extends BaseJpaDstu2Test { } break; case XML: - encoded = myFhirCtx.newXmlParser().encodeResourceToString(input); + encoded = myFhirContext.newXmlParser().encodeResourceToString(input); try { myObservationDao.validate(input, null, encoded, EncodingEnum.XML, mode, null, mySrd); fail(); @@ -136,13 +134,13 @@ public class FhirResourceDaoDstu2ValidateTest extends BaseJpaDstu2Test { input.getCode().addCoding().setSystem("http://loinc.org").setCode("12345"); ValidationModeEnum mode = ValidationModeEnum.CREATE; - String encoded = myFhirCtx.newJsonParser().encodeResourceToString(input); + String encoded = myFhirContext.newJsonParser().encodeResourceToString(input); ourLog.info(encoded); try { myObservationDao.validate(input, null, encoded, EncodingEnum.JSON, mode, null, mySrd); fail(); } catch (PreconditionFailedException e) { - String ooString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome()); + String ooString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome()); ourLog.info(ooString); assertThat(ooString, containsString("Profile reference 'http://example.com/StructureDefinition/testValidateResourceContainingProfileDeclarationInvalid' has not been checked because it is unknown")); } @@ -204,7 +202,7 @@ public class FhirResourceDaoDstu2ValidateTest extends BaseJpaDstu2Test { } catch (PreconditionFailedException e) { // should not happen IBaseOperationOutcome oo = e.getOperationOutcome(); - fail(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); + fail(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); } pat.setId(""); @@ -238,7 +236,7 @@ public class FhirResourceDaoDstu2ValidateTest extends BaseJpaDstu2Test { outcome = (OperationOutcome) e.getOperationOutcome(); } - String ooString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String ooString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(ooString); assertThat(ooString, containsString("Unable to delete Organization")); @@ -247,7 +245,7 @@ public class FhirResourceDaoDstu2ValidateTest extends BaseJpaDstu2Test { myPatientDao.update(pat, mySrd); outcome = (OperationOutcome) myOrganizationDao.validate(null, orgId, null, null, ValidationModeEnum.DELETE, null, mySrd).getOperationOutcome(); - ooString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + ooString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(ooString); assertThat(ooString, containsString("Ok to delete")); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoValueSetDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoValueSetDstu2Test.java index d6520404f7d..19074543caf 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoValueSetDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoValueSetDstu2Test.java @@ -157,7 +157,7 @@ public class FhirResourceDaoValueSetDstu2Test extends BaseJpaDstu2Test { String resp; ValueSet expanded = myValueSetDao.expand(myExtensionalVsId, null, mySrd); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); // @formatter:off assertThat(resp, @@ -182,7 +182,7 @@ public class FhirResourceDaoValueSetDstu2Test extends BaseJpaDstu2Test { */ expanded = myValueSetDao.expand(myExtensionalVsId, new ValueSetExpansionOptions().setFilter("systolic"), mySrd); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); //@formatter:off assertThat(resp, stringContainsInOrder( @@ -195,7 +195,7 @@ public class FhirResourceDaoValueSetDstu2Test extends BaseJpaDstu2Test { */ expanded = myValueSetDao.expand(myExtensionalVsId, new ValueSetExpansionOptions().setFilter("11378"), mySrd); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); //@formatter:off assertThat(resp, stringContainsInOrder( @@ -207,7 +207,7 @@ public class FhirResourceDaoValueSetDstu2Test extends BaseJpaDstu2Test { @Test public void testExpandByIdentifier() { ValueSet expanded = myValueSetDao.expandByIdentifier("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2", new ValueSetExpansionOptions().setFilter("11378")); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); //@formatter:off assertThat(resp, stringContainsInOrder( @@ -222,7 +222,7 @@ public class FhirResourceDaoValueSetDstu2Test extends BaseJpaDstu2Test { public void testExpandByValueSet() throws IOException { ValueSet toExpand = loadResourceFromClasspath(ValueSet.class, "/extensional-case-2.xml"); ValueSet expanded = myValueSetDao.expand(toExpand, new ValueSetExpansionOptions().setFilter("11378")); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); //@formatter:off assertThat(resp, stringContainsInOrder( diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirSystemDaoDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirSystemDaoDstu2Test.java index 128781509c6..d429ff99579 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirSystemDaoDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirSystemDaoDstu2Test.java @@ -50,7 +50,16 @@ import java.util.ArrayList; import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.emptyString; +import static org.hamcrest.Matchers.endsWith; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.startsWith; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; @@ -168,7 +177,7 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest { assertEquals(2, resp.getEntry().size()); assertEquals(BundleTypeEnum.BATCH_RESPONSE, resp.getTypeElement().getValueAsEnum()); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); EntryResponse respEntry; // Bundle.entry[1] is create response @@ -200,11 +209,11 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest { @Test public void testTransactionBug638() throws Exception { String input = loadClasspath("/bug638.xml"); - Bundle request = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + Bundle request = myFhirContext.newXmlParser().parseResource(Bundle.class, input); Bundle resp = mySystemDao.transaction(mySrd, request); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); assertEquals(18, resp.getEntry().size()); } @@ -1045,11 +1054,11 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest { InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/transaction_link_patient_eve.xml"); String bundleStr = IOUtils.toString(bundleRes); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, bundleStr); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, bundleStr); Bundle resp = mySystemDao.transaction(mySrd, bundle); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); assertThat(resp.getEntry().get(0).getResponse().getLocation(), startsWith("Patient/a555-44-4444/_history/")); assertThat(resp.getEntry().get(1).getResponse().getLocation(), startsWith("Patient/temp6789/_history/")); @@ -1063,8 +1072,8 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest { public void testTransactionFromBundle6() throws Exception { InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/simone_bundle3.xml"); String bundle = IOUtils.toString(bundleRes); - Bundle output = mySystemDao.transaction(mySrd, myFhirCtx.newXmlParser().parseResource(Bundle.class, bundle)); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + Bundle output = mySystemDao.transaction(mySrd, myFhirContext.newXmlParser().parseResource(Bundle.class, bundle)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); } @Test @@ -1072,11 +1081,11 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest { InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/josh-bundle.json"); String bundleStr = IOUtils.toString(bundleRes); - Bundle bundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, bundleStr); + Bundle bundle = myFhirContext.newJsonParser().parseResource(Bundle.class, bundleStr); Bundle resp = mySystemDao.transaction(mySrd, bundle); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); assertEquals("201 Created", resp.getEntry().get(0).getResponse().getStatus()); assertEquals("201 Created", resp.getEntry().get(1).getResponse().getStatus()); @@ -1137,7 +1146,7 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest { } private void testTransactionOrderingValidateResponse(int pass, Bundle resp) { - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); assertEquals(4, resp.getEntry().size()); assertEquals("200 OK", resp.getEntry().get(0).getResponse().getStatus()); if (pass == 0) { @@ -1291,7 +1300,7 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest { Bundle resp = mySystemDao.transaction(mySrd, request); assertEquals(2, resp.getEntry().size()); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); Entry nextEntry = resp.getEntry().get(0); assertEquals("200 OK", nextEntry.getResponse().getStatus()); @@ -1435,7 +1444,7 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest { Bundle initialBundleResponse = mySystemDao.transaction(mySrd, request); assertEquals(1, initialBundleResponse.getEntry().size()); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(initialBundleResponse)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(initialBundleResponse)); Entry initialBundleResponseEntry = initialBundleResponse.getEntry().get(0); assertEquals("201 Created", initialBundleResponseEntry.getResponse().getStatus()); @@ -1445,7 +1454,7 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest { Bundle secondBundleResponse = mySystemDao.transaction(mySrd, request); assertEquals(1, secondBundleResponse.getEntry().size()); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(secondBundleResponse)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(secondBundleResponse)); Entry secondBundleResponseEntry = secondBundleResponse.getEntry().get(0); assertEquals("200 OK", secondBundleResponseEntry.getResponse().getStatus()); @@ -1464,7 +1473,7 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest { Bundle initialBundleResponse = mySystemDao.transaction(mySrd, request); assertEquals(1, initialBundleResponse.getEntry().size()); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(initialBundleResponse)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(initialBundleResponse)); Entry initialBundleResponseEntry = initialBundleResponse.getEntry().get(0); assertEquals("201 Created", initialBundleResponseEntry.getResponse().getStatus()); @@ -1472,7 +1481,7 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest { Bundle secondBundleResponse = mySystemDao.transaction(mySrd, request); assertEquals(1, secondBundleResponse.getEntry().size()); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(secondBundleResponse)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(secondBundleResponse)); Entry secondBundleResponseEntry = secondBundleResponse.getEntry().get(0); assertEquals("200 OK", secondBundleResponseEntry.getResponse().getStatus()); @@ -1591,9 +1600,9 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest { "}"; //@formatter:on - Bundle inputBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, input); + Bundle inputBundle = myFhirContext.newJsonParser().parseResource(Bundle.class, input); Bundle outputBundle = mySystemDao.transaction(mySrd, inputBundle); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(outputBundle)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(outputBundle)); } @Test @@ -1657,7 +1666,7 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest { //@formatter:on Bundle outputBundle = mySystemDao.transaction(mySrd, inputBundle); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(outputBundle)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(outputBundle)); assertEquals(3, outputBundle.getEntry().size()); IdDt id0 = new IdDt(outputBundle.getEntry().get(0).getResponse().getLocation()); @@ -1680,9 +1689,9 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest { // First bundle (name is Joshua) String input = IOUtils.toString(getClass().getResource("/dstu3-post1.xml"), StandardCharsets.UTF_8); - Bundle request = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + Bundle request = myFhirContext.newXmlParser().parseResource(Bundle.class, input); Bundle response = mySystemDao.transaction(mySrd, request); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); assertEquals(1, response.getEntry().size()); assertEquals("201 Created", response.getEntry().get(0).getResponse().getStatus()); @@ -1692,9 +1701,9 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest { // Now the second (name is Adam, shouldn't get used) input = IOUtils.toString(getClass().getResource("/dstu3-post2.xml"), StandardCharsets.UTF_8); - request = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + request = myFhirContext.newXmlParser().parseResource(Bundle.class, input); response = mySystemDao.transaction(mySrd, request); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); assertEquals(1, response.getEntry().size()); assertEquals("200 OK", response.getEntry().get(0).getResponse().getStatus()); @@ -1703,7 +1712,7 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest { assertEquals(id, id2); Patient patient = myPatientDao.read(new IdType(id), mySrd); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient)); assertEquals("Joshua", patient.getNameFirstRep().getGivenAsSingleString()); } @@ -1722,10 +1731,10 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest { mo.setMedication(new ResourceReferenceDt(medId)); bundle.addEntry().setResource(mo).setFullUrl(mo.getId().getValue()).getRequest().setMethod(HTTPVerbEnum.POST); - ourLog.info("Request:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info("Request:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); Bundle outcome = mySystemDao.transaction(mySrd, bundle); - ourLog.info("Response:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info("Response:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); IdDt medId1 = new IdDt(outcome.getEntry().get(0).getResponse().getLocation()); IdDt medOrderId1 = new IdDt(outcome.getEntry().get(1).getResponse().getLocation()); @@ -1782,7 +1791,7 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest { Bundle resp = mySystemDao.transaction(mySrd, res); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); assertEquals(BundleTypeEnum.TRANSACTION_RESPONSE, resp.getTypeElement().getValueAsEnum()); assertEquals(3, resp.getEntry().size()); @@ -1823,7 +1832,7 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest { Bundle resp = mySystemDao.transaction(mySrd, res); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); assertEquals(BundleTypeEnum.TRANSACTION_RESPONSE, resp.getTypeElement().getValueAsEnum()); assertEquals(3, resp.getEntry().size()); @@ -1973,7 +1982,7 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest { drEntry.setResource(dr).setFullUrl(dr.getId()).getRequest().setUrl("DiagnosticReport").setMethod(HTTPVerbEnum.POST); transactionBundle.addEntry(drEntry); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(transactionBundle)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(transactionBundle)); Bundle transactionResp = mySystemDao.transaction(mySrd, transactionBundle); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3SystemTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3SystemTest.java index 2f3f34ea987..26b5b890da7 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3SystemTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3SystemTest.java @@ -25,7 +25,7 @@ public abstract class BaseJpaDstu3SystemTest extends BaseJpaDstu3Test { when(mySrd.getInterceptorBroadcaster()).thenReturn(mock(IInterceptorBroadcaster.class)); if (myServer == null) { - myServer = new RestfulServer(myFhirCtx); + myServer = new RestfulServer(myFhirContext); PatientResourceProvider patientRp = new PatientResourceProvider(); patientRp.setDao(myPatientDao); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java index 44a26b70366..c458aacded1 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java @@ -105,7 +105,6 @@ import org.hl7.fhir.dstu3.model.Task; import org.hl7.fhir.dstu3.model.ValueSet; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.instance.model.api.IBaseResource; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.ExtendWith; @@ -196,11 +195,10 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest { @Autowired @Qualifier("myEncounterDaoDstu3") protected IFhirResourceDao myEncounterDao; - // @PersistenceContext() @Autowired protected EntityManager myEntityManager; @Autowired - protected FhirContext myFhirCtx; + protected FhirContext myFhirContext; @Autowired @Qualifier("myGroupDaoDstu3") protected IFhirResourceDao myGroupDao; @@ -395,12 +393,12 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest { @BeforeEach public void beforeResetConfig() { - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); } @Override - protected FhirContext getContext() { - return myFhirCtx; + public FhirContext getFhirContext() { + return myFhirContext; } @Override @@ -414,7 +412,7 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest { fail("Unable to load resource: " + resourceName); } String string = IOUtils.toString(stream, StandardCharsets.UTF_8); - IParser newJsonParser = EncodingEnum.detectEncodingNoDefault(string).newParser(myFhirCtx); + IParser newJsonParser = EncodingEnum.detectEncodingNoDefault(string).newParser(myFhirContext); return newJsonParser.parseResource(type, string); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoCustomTypeDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoCustomTypeDstu3Test.java index 183b4ecd13d..990d2a0a3fd 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoCustomTypeDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoCustomTypeDstu3Test.java @@ -4,9 +4,9 @@ import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.rest.api.server.IBundleProvider; import org.hl7.fhir.dstu3.model.StringType; import org.hl7.fhir.instance.model.api.IIdType; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -17,7 +17,7 @@ public class FhirResourceDaoCustomTypeDstu3Test extends BaseJpaDstu3Test { @BeforeEach public void before() { - myFhirCtx.setDefaultTypeForProfile(CustomObservationDstu3.PROFILE, CustomObservationDstu3.class); + myFhirContext.setDefaultTypeForProfile(CustomObservationDstu3.PROFILE, CustomObservationDstu3.class); } @Test @@ -39,6 +39,6 @@ public class FhirResourceDaoCustomTypeDstu3Test extends BaseJpaDstu3Test { @AfterEach public void after() { - myFhirCtx.setDefaultTypeForProfile(CustomObservationDstu3.PROFILE, null); + myFhirContext.setDefaultTypeForProfile(CustomObservationDstu3.PROFILE, null); } } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDocumentDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDocumentDstu3Test.java index 2cbb645c7cc..05fe5feea7b 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDocumentDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDocumentDstu3Test.java @@ -1,10 +1,8 @@ package ca.uhn.fhir.jpa.dao.dstu3; import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome; -import ca.uhn.fhir.util.TestUtil; import org.apache.commons.io.IOUtils; import org.hl7.fhir.dstu3.model.Bundle; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Test; import java.nio.charset.StandardCharsets; @@ -16,7 +14,7 @@ public class FhirResourceDaoDocumentDstu3Test extends BaseJpaDstu3Test { @Test public void testPostDocument() throws Exception { String input = IOUtils.toString(getClass().getResourceAsStream("/sample-document.xml"), StandardCharsets.UTF_8); - Bundle inputBundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + Bundle inputBundle = myFhirContext.newXmlParser().parseResource(Bundle.class, input); DaoMethodOutcome responseBundle = myBundleDao.create(inputBundle, mySrd); } } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3CodeSystemTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3CodeSystemTest.java index 187ad7baa7c..9030b86f230 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3CodeSystemTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3CodeSystemTest.java @@ -34,7 +34,7 @@ public class FhirResourceDaoDstu3CodeSystemTest extends BaseJpaDstu3Test { TermReindexingSvcImpl.setForceSaveDeferredAlwaysForUnitTest(true); String input = IOUtils.toString(getClass().getResource("/dstu3_codesystem_complete.json"), StandardCharsets.UTF_8); - CodeSystem cs = myFhirCtx.newJsonParser().parseResource(CodeSystem.class, input); + CodeSystem cs = myFhirContext.newJsonParser().parseResource(CodeSystem.class, input); myCodeSystemDao.create(cs, mySrd); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ConceptMapTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ConceptMapTest.java index 7f390e8a904..bb152dc9446 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ConceptMapTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ConceptMapTest.java @@ -1,8 +1,8 @@ package ca.uhn.fhir.jpa.dao.dstu3; import ca.uhn.fhir.context.support.TranslateConceptResult; -import ca.uhn.fhir.jpa.api.model.TranslationRequest; import ca.uhn.fhir.context.support.TranslateConceptResults; +import ca.uhn.fhir.jpa.api.model.TranslationRequest; import ca.uhn.fhir.jpa.entity.TermConceptMap; import org.hl7.fhir.dstu3.model.ConceptMap; import org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus; @@ -62,7 +62,7 @@ public class FhirResourceDaoDstu3ConceptMapTest extends BaseJpaDstu3Test { public void testTranslateByCodeSystemsAndSourceCodeOneToMany() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ContainedTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ContainedTest.java index 8319ec16bd6..b71cfc6dfc5 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ContainedTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ContainedTest.java @@ -36,7 +36,7 @@ public class FhirResourceDaoDstu3ContainedTest extends BaseJpaDstu3Test { p2.addName().setFamily("MYFAMILY").addGiven("MYGIVEN"); IIdType pid2 = myPatientDao.create(p2, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(o2)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(o2)); SearchParameterMap map = new SearchParameterMap(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3PhoneticSearchNoFtTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3PhoneticSearchNoFtTest.java index a8eee02556f..fed39699ed8 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3PhoneticSearchNoFtTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3PhoneticSearchNoFtTest.java @@ -96,7 +96,7 @@ public class FhirResourceDaoDstu3PhoneticSearchNoFtTest extends BaseJpaDstu3Test patient.addName().addGiven(GALE); patient.addAddress().addLine(ADDRESS); patient.addTelecom().setValue(PHONE); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); IIdType pId = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless(); @@ -150,7 +150,7 @@ public class FhirResourceDaoDstu3PhoneticSearchNoFtTest extends BaseJpaDstu3Test searchParameter.addExtension() .setUrl(HapiExtensions.EXT_SEARCHPARAM_PHONETIC_ENCODER) .setValue(new StringType(theEncoder.name())); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(searchParameter)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(searchParameter)); mySearchParameterDao.create(searchParameter, mySrd).getId().toUnqualifiedVersionless(); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchCustomSearchParamTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchCustomSearchParamTest.java index 587d9f81696..7421467eda3 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchCustomSearchParamTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchCustomSearchParamTest.java @@ -14,13 +14,34 @@ import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; -import ca.uhn.fhir.util.TestUtil; -import org.hl7.fhir.dstu3.model.*; +import org.hl7.fhir.dstu3.model.Appointment; import org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus; +import org.hl7.fhir.dstu3.model.CodeType; +import org.hl7.fhir.dstu3.model.CodeableConcept; +import org.hl7.fhir.dstu3.model.Coding; +import org.hl7.fhir.dstu3.model.Communication; +import org.hl7.fhir.dstu3.model.Condition; +import org.hl7.fhir.dstu3.model.DateTimeType; +import org.hl7.fhir.dstu3.model.DateType; +import org.hl7.fhir.dstu3.model.DecimalType; +import org.hl7.fhir.dstu3.model.Enumerations; import org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender; +import org.hl7.fhir.dstu3.model.Extension; +import org.hl7.fhir.dstu3.model.IntegerType; +import org.hl7.fhir.dstu3.model.Medication; +import org.hl7.fhir.dstu3.model.MedicationAdministration; +import org.hl7.fhir.dstu3.model.MedicationRequest; +import org.hl7.fhir.dstu3.model.MedicationStatement; +import org.hl7.fhir.dstu3.model.Observation; +import org.hl7.fhir.dstu3.model.Patient; +import org.hl7.fhir.dstu3.model.Practitioner; +import org.hl7.fhir.dstu3.model.ProcedureRequest; +import org.hl7.fhir.dstu3.model.Reference; +import org.hl7.fhir.dstu3.model.SearchParameter; +import org.hl7.fhir.dstu3.model.Specimen; +import org.hl7.fhir.dstu3.model.StringType; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.instance.model.api.IIdType; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -158,7 +179,7 @@ public class FhirResourceDaoDstu3SearchCustomSearchParamTest extends BaseJpaDstu pract.addName().setFamily("PRACT"); myPractitionerDao.update(pract); - Patient pat = myFhirCtx.newJsonParser().parseResource(Patient.class, loadClasspath("/dstu3_custom_resource_patient.json")); + Patient pat = myFhirContext.newJsonParser().parseResource(Patient.class, loadClasspath("/dstu3_custom_resource_patient.json")); IIdType pid = myPatientDao.create(pat, mySrd).getId().toUnqualifiedVersionless(); SearchParameterMap params = new SearchParameterMap(); @@ -928,7 +949,7 @@ public class FhirResourceDaoDstu3SearchCustomSearchParamTest extends BaseJpaDstu sp.setExpression("Observation.specimen.resolve().receivedTime"); sp.setXpathUsage(SearchParameter.XPathUsageType.NORMAL); sp.setStatus(Enumerations.PublicationStatus.ACTIVE); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(sp)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(sp)); mySearchParameterDao.create(sp); mySearchParamRegistry.forceRefresh(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchDistanceTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchDistanceTest.java index 20b7e6c9baf..e8ff123641a 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchDistanceTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchDistanceTest.java @@ -40,7 +40,7 @@ public class FhirResourceDaoDstu3SearchDistanceTest extends BaseJpaDstu3Test { SearchParameterMap map = myMatchUrlService.translateMatchUrl( "Location?" + Location.SP_NEAR + "=" + latitude + ":" + longitude, - myFhirCtx.getResourceDefinition("Location")); + myFhirContext.getResourceDefinition("Location")); List ids = toUnqualifiedVersionlessIdValues(myLocationDao.search(map)); assertThat(ids, contains(locId)); @@ -60,7 +60,7 @@ public class FhirResourceDaoDstu3SearchDistanceTest extends BaseJpaDstu3Test { Location.SP_NEAR + "=" + latitude + ":" + longitude + "&" + Location.SP_NEAR_DISTANCE + "=0||", - myFhirCtx.getResourceDefinition("Location")); + myFhirContext.getResourceDefinition("Location")); List ids = toUnqualifiedVersionlessIdValues(myLocationDao.search(map)); assertThat(ids, contains(locId)); @@ -81,7 +81,7 @@ public class FhirResourceDaoDstu3SearchDistanceTest extends BaseJpaDstu3Test { "Location?" + Location.SP_NEAR + "=" + CoordCalculatorTest.LATITUDE_CHIN + ":" + CoordCalculatorTest.LONGITUDE_CHIN + "&" + - Location.SP_NEAR_DISTANCE + "=" + bigEnoughDistance + "|http://unitsofmeasure.org|km", myFhirCtx.getResourceDefinition("Location")); + Location.SP_NEAR_DISTANCE + "=" + bigEnoughDistance + "|http://unitsofmeasure.org|km", myFhirContext.getResourceDefinition("Location")); List ids = toUnqualifiedVersionlessIdValues(myLocationDao.search(map)); assertThat(ids, contains(locId)); @@ -93,7 +93,7 @@ public class FhirResourceDaoDstu3SearchDistanceTest extends BaseJpaDstu3Test { "Location?" + Location.SP_NEAR + "=" + CoordCalculatorTest.LATITUDE_CHIN + ":" + CoordCalculatorTest.LONGITUDE_CHIN + "&" + - Location.SP_NEAR_DISTANCE + "=" + tooSmallDistance + "|http://unitsofmeasure.org|km", myFhirCtx.getResourceDefinition("Location")); + Location.SP_NEAR_DISTANCE + "=" + tooSmallDistance + "|http://unitsofmeasure.org|km", myFhirContext.getResourceDefinition("Location")); List ids = toUnqualifiedVersionlessIdValues(myLocationDao.search(map)); assertThat(ids.size(), is(0)); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java index 462655a9ff7..14934ac43b9 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java @@ -261,10 +261,10 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test { */ @Test public void testEverythingWithLargeSet() throws Exception { - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); String inputString = IOUtils.toString(getClass().getResourceAsStream("/david_big_bundle.json"), StandardCharsets.UTF_8); - Bundle inputBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, inputString); + Bundle inputBundle = myFhirContext.newJsonParser().parseResource(Bundle.class, inputString); inputBundle.setType(BundleType.TRANSACTION); Set allIds = new TreeSet<>(); @@ -329,7 +329,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test { map.setLoadSynchronous(true); ReferenceParam referenceParam = new ReferenceParam(); - referenceParam.setValueAsQueryToken(myFhirCtx, "subject", "._has:Group:member:_id", "Group/G"); + referenceParam.setValueAsQueryToken(myFhirContext, "subject", "._has:Group:member:_id", "Group/G"); map.add("subject", referenceParam); List actual = toUnqualifiedVersionlessIdValues(myDiagnosticReportDao.search(map)); assertThat(actual, containsInAnyOrder("DiagnosticReport/DR")); @@ -671,7 +671,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test { public void testIndexWithUtf8Chars() throws IOException { String input = IOUtils.toString(getClass().getResourceAsStream("/bug454_utf8.json"), StandardCharsets.UTF_8); - CodeSystem cs = (CodeSystem) myFhirCtx.newJsonParser().parseResource(input); + CodeSystem cs = (CodeSystem) myFhirContext.newJsonParser().parseResource(input); myCodeSystemDao.create(cs); } @@ -2920,7 +2920,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test { value = myDeviceDao.search(new SearchParameterMap()); if (value.size() > 0) { ourLog.info("Found: " + (value.getResources(0, 1).get(0).getIdElement())); - fail(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(value.getResources(0, 1).get(0))); + fail(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(value.getResources(0, 1).get(0))); } assertEquals(0, value.size().intValue()); @@ -3252,7 +3252,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test { @Test public void testSearchWithUriParamBelow() throws Exception { - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); Class type = ValueSet.class; String resourceName = "/valueset-dstu2.json"; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3StructureDefinitionTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3StructureDefinitionTest.java index d852ff06d21..a588e8bae4d 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3StructureDefinitionTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3StructureDefinitionTest.java @@ -1,8 +1,6 @@ package ca.uhn.fhir.jpa.dao.dstu3; -import ca.uhn.fhir.util.TestUtil; import org.hl7.fhir.dstu3.model.StructureDefinition; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; @@ -24,7 +22,7 @@ public class FhirResourceDaoDstu3StructureDefinitionTest extends BaseJpaDstu3Tes assertEquals(0, sd.getSnapshot().getElement().size()); StructureDefinition output = myStructureDefinitionDao.generateSnapshot(sd, "http://foo", null, "THE BEST PROFILE"); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); assertEquals(54, output.getSnapshot().getElement().size()); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java index a5c8088855a..f8f7d9d5364 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java @@ -221,11 +221,11 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { } private void logAndValidateValueSet(ValueSet theResult) { - IParser parser = myFhirCtx.newXmlParser().setPrettyPrint(true); + IParser parser = myFhirContext.newXmlParser().setPrettyPrint(true); String encoded = parser.encodeResourceToString(theResult); ourLog.info(encoded); - FhirValidator validator = myFhirCtx.newValidator(); + FhirValidator validator = myFhirContext.newValidator(); validator.setValidateAgainstStandardSchema(true); validator.setValidateAgainstStandardSchematron(true); ValidationResult result = validator.validateWithResult(theResult); @@ -332,7 +332,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { ValueSet result = myValueSetDao.expandByIdentifier("http://hl7.org/fhir/ValueSet/doc-typecodes", new ValueSetExpansionOptions().setFilter("")); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(result)); } @@ -673,7 +673,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { assertEquals(4, result.getExpansion().getContains().size()); - String encoded = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result); + String encoded = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(result); assertThat(encoded, containsStringIgnoringCase("")); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3Test.java index bf45f34e518..4b7a432ac30 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3Test.java @@ -32,7 +32,6 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; - import com.google.common.collect.Lists; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.RandomStringUtils; @@ -100,6 +99,7 @@ import java.util.List; import java.util.Set; import static org.apache.commons.lang3.StringUtils.defaultString; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.containsString; @@ -114,7 +114,6 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; -import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; @@ -464,11 +463,11 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test { String vsContents; vsContents = IOUtils.toString(FhirResourceDaoDstu3Test.class.getResourceAsStream("/org/hl7/fhir/dstu3/model/profile/" + name + ".xml"), StandardCharsets.UTF_8); - bundle = myFhirCtx.newXmlParser().parseResource(org.hl7.fhir.dstu3.model.Bundle.class, vsContents); + bundle = myFhirContext.newXmlParser().parseResource(org.hl7.fhir.dstu3.model.Bundle.class, vsContents); for (BundleEntryComponent i : bundle.getEntry()) { org.hl7.fhir.dstu3.model.Resource next = i.getResource(); - ourLog.debug(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(next)); + ourLog.debug(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(next)); if (next instanceof StructureDefinition) { myStructureDefinitionDao.update((StructureDefinition) next, mySrd); } else if (next instanceof CompartmentDefinition) { @@ -617,7 +616,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test { " "; //@formatter:on - NamingSystem res = myFhirCtx.newXmlParser().parseResource(NamingSystem.class, input); + NamingSystem res = myFhirContext.newXmlParser().parseResource(NamingSystem.class, input); IIdType id = myNamingSystemDao.create(res, mySrd).getId().toUnqualifiedVersionless(); assertThat(toUnqualifiedVersionlessIdValues(myNamingSystemDao.search(new SearchParameterMap(NamingSystem.SP_NAME, new StringParam("NDF")).setLoadSynchronous(true))), org.hamcrest.Matchers.contains(id.getValue())); @@ -1918,7 +1917,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test { Set val = myOrganizationDao.searchForIds(new SearchParameterMap("name", new StringParam("P")), null); int initial = val.size(); - Organization org = myFhirCtx.newJsonParser().parseResource(Organization.class, inputStr); + Organization org = myFhirContext.newJsonParser().parseResource(Organization.class, inputStr); myOrganizationDao.create(org, mySrd); val = myOrganizationDao.searchForIds(new SearchParameterMap("name", new StringParam("P")), null); @@ -2555,7 +2554,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test { oid1 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -2567,7 +2566,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test { oid2 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -2579,7 +2578,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test { oid3 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -2591,7 +2590,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test { oid4 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } @@ -3150,7 +3149,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test { IIdType orgId = myOrganizationDao.create(org, mySrd).getId(); Organization returned = myOrganizationDao.read(orgId, mySrd); - String val = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned); + String val = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned); ourLog.info(val); assertThat(val, containsString("")); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ValidateTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ValidateTest.java index 3481cb129b2..9078eff907b 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ValidateTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ValidateTest.java @@ -1,9 +1,8 @@ package ca.uhn.fhir.jpa.dao.dstu3; import ca.uhn.fhir.context.support.IValidationSupport; -import ca.uhn.fhir.jpa.config.BaseConfig; +import ca.uhn.fhir.jpa.config.JpaConfig; import ca.uhn.fhir.jpa.dao.JpaPersistedResourceValidationSupport; -import ca.uhn.fhir.jpa.util.TestUtil; import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.ValidationModeEnum; @@ -16,14 +15,27 @@ import ca.uhn.fhir.validation.IValidatorModule; import org.apache.commons.io.IOUtils; import org.hl7.fhir.common.hapi.validation.support.CachingValidationSupport; import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator; -import org.hl7.fhir.dstu3.model.*; +import org.hl7.fhir.dstu3.model.Bundle; import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; +import org.hl7.fhir.dstu3.model.CodeSystem; +import org.hl7.fhir.dstu3.model.Coding; +import org.hl7.fhir.dstu3.model.IdType; +import org.hl7.fhir.dstu3.model.Narrative; +import org.hl7.fhir.dstu3.model.Observation; import org.hl7.fhir.dstu3.model.Observation.ObservationStatus; +import org.hl7.fhir.dstu3.model.OperationOutcome; +import org.hl7.fhir.dstu3.model.Organization; +import org.hl7.fhir.dstu3.model.Patient; +import org.hl7.fhir.dstu3.model.Questionnaire; +import org.hl7.fhir.dstu3.model.QuestionnaireResponse; +import org.hl7.fhir.dstu3.model.Reference; +import org.hl7.fhir.dstu3.model.StringType; +import org.hl7.fhir.dstu3.model.StructureDefinition; +import org.hl7.fhir.dstu3.model.ValueSet; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r5.utils.validation.constants.BestPracticeWarningLevel; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -34,9 +46,9 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.stream.Collectors; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.fail; public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { @@ -48,7 +60,7 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { @Autowired private FhirInstanceValidator myFhirInstanceValidator; @Autowired - @Qualifier(BaseConfig.JPA_VALIDATION_SUPPORT) + @Qualifier(JpaConfig.JPA_VALIDATION_SUPPORT) private IValidationSupport myPersistedResourceValidationSupport; @Test @@ -65,9 +77,9 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { qr.addItem().setLinkId("A").addAnswer().setValue(new StringType("AAA")); MethodOutcome results = myQuestionnaireResponseDao.validate(qr, null, null, null, null, null, null); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(results.getOperationOutcome())); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(results.getOperationOutcome())); } catch (PreconditionFailedException e) { - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); fail(e.toString()); } @@ -83,7 +95,7 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { qr.addItem().setLinkId("A").addAnswer().setValue(new StringType("AAA")); MethodOutcome results = myQuestionnaireResponseDao.validate(qr, null, null, null, null, null, null); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(results.getOperationOutcome())); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(results.getOperationOutcome())); ourLog.info("Clearing cache"); myValidationSupport.invalidateCaches(); @@ -94,7 +106,7 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { myQuestionnaireResponseDao.validate(qr, null, null, null, null, null, null); fail(); } catch (PreconditionFailedException e) { - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); // good } @@ -110,7 +122,7 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { myValueSetDao.create(vs); ValueSet expansion = myValueSetDao.expandByIdentifier("http://ccim.on.ca/fhir/iar/ValueSet/iar-citizenship-status", null); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); assertThat(expansion.getExpansion().getContains().stream().map(t->t.getCode()).collect(Collectors.toList()), containsInAnyOrder( "CDN", "PR", "TR", "REF", "UNK", "ASKU" @@ -163,25 +175,25 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { try { MethodOutcome outcome = myQuestionnaireResponseDao.validate(qr, null, null, null, ValidationModeEnum.CREATE, null, mySrd); OperationOutcome oo = (OperationOutcome) outcome.getOperationOutcome(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); fail(); } catch (PreconditionFailedException e) { OperationOutcome oo = (OperationOutcome) e.getOperationOutcome(); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); ourLog.info(encoded); assertThat(encoded, containsString("is not in the options value set")); } // Validate as string try { - String raw = myFhirCtx.newJsonParser().encodeResourceToString(qr); + String raw = myFhirContext.newJsonParser().encodeResourceToString(qr); MethodOutcome outcome = myQuestionnaireResponseDao.validate(qr, null, raw, EncodingEnum.JSON, ValidationModeEnum.CREATE, null, mySrd); OperationOutcome oo = (OperationOutcome) outcome.getOperationOutcome(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); fail(); } catch (PreconditionFailedException e) { OperationOutcome oo = (OperationOutcome) e.getOperationOutcome(); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); ourLog.info(encoded); assertThat(encoded, containsString("is not in the options value set")); } @@ -192,14 +204,14 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { @Test public void testValidateStructureDefinition() throws Exception { String input = IOUtils.toString(getClass().getResourceAsStream("/sd-david-dhtest7.json"), StandardCharsets.UTF_8); - StructureDefinition sd = myFhirCtx.newJsonParser().parseResource(StructureDefinition.class, input); + StructureDefinition sd = myFhirContext.newJsonParser().parseResource(StructureDefinition.class, input); ourLog.info("Starting validation"); try { myStructureDefinitionDao.validate(sd, null, null, null, ValidationModeEnum.UPDATE, null, mySrd); } catch (PreconditionFailedException e) { - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); } ourLog.info("Done validation"); @@ -217,14 +229,14 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { @Test public void testValidateDocument() throws Exception { String input = IOUtils.toString(getClass().getResourceAsStream("/document-bundle-dstu3.json"), StandardCharsets.UTF_8); - Bundle document = myFhirCtx.newJsonParser().parseResource(Bundle.class, input); + Bundle document = myFhirContext.newJsonParser().parseResource(Bundle.class, input); ourLog.info("Starting validation"); try { MethodOutcome outcome = myBundleDao.validate(document, null, null, null, ValidationModeEnum.CREATE, null, mySrd); } catch (PreconditionFailedException e) { - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); } ourLog.info("Done validation"); @@ -237,7 +249,7 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { String methodName = "testValidateResourceContainingProfileDeclarationJson"; OperationOutcome outcome = doTestValidateResourceContainingProfileDeclaration(methodName, EncodingEnum.JSON); - String ooString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String ooString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(ooString); assertThat(ooString, containsString("Element '.subject': minimum required = 1, but only found 0")); assertThat(ooString, containsString("Element encounter @ : max allowed = 0, but found 1")); @@ -250,7 +262,7 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { String methodName = "testValidateResourceContainingProfileDeclarationXml"; OperationOutcome outcome = doTestValidateResourceContainingProfileDeclaration(methodName, EncodingEnum.XML); - String ooString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String ooString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(ooString); assertThat(ooString, containsString("Element '/f:Observation.subject': minimum required = 1, but only found 0")); assertThat(ooString, containsString("Element encounter @ /f:Observation: max allowed = 0, but found 1")); @@ -287,7 +299,7 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { ValidationModeEnum mode = ValidationModeEnum.CREATE; switch (enc) { case JSON: - encoded = myFhirCtx.newJsonParser().encodeResourceToString(input); + encoded = myFhirContext.newJsonParser().encodeResourceToString(input); try { myObservationDao.validate(input, null, encoded, EncodingEnum.JSON, mode, null, mySrd); fail(); @@ -296,7 +308,7 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { } break; case XML: - encoded = myFhirCtx.newXmlParser().encodeResourceToString(input); + encoded = myFhirContext.newXmlParser().encodeResourceToString(input); try { myObservationDao.validate(input, null, encoded, EncodingEnum.XML, mode, null, mySrd); fail(); @@ -323,15 +335,15 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { input.getCode().addCoding().setSystem("http://loinc.org").setCode("12345"); ValidationModeEnum mode = ValidationModeEnum.CREATE; - String encoded = myFhirCtx.newJsonParser().encodeResourceToString(input); + String encoded = myFhirContext.newJsonParser().encodeResourceToString(input); try { // Expected to throw exception MethodOutcome output = myObservationDao.validate(input, null, encoded, EncodingEnum.JSON, mode, null, mySrd); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(output.getOperationOutcome())); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output.getOperationOutcome())); fail(); } catch (PreconditionFailedException e) { OperationOutcome oo = (OperationOutcome) e.getOperationOutcome(); - String outputString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); + String outputString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); ourLog.info(outputString); assertThat(outputString, containsString("Profile reference 'http://example.com/StructureDefinition/testValidateResourceContainingProfileDeclarationInvalid' has not been checked because it is unknown")); } @@ -421,7 +433,7 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { outcome = (OperationOutcome) e.getOperationOutcome(); } - String ooString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String ooString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(ooString); assertThat(ooString, containsString("Unable to delete Organization")); @@ -430,7 +442,7 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { myPatientDao.update(pat, mySrd); outcome = (OperationOutcome) myOrganizationDao.validate(null, orgId, null, null, ValidationModeEnum.DELETE, null, mySrd).getOperationOutcome(); - ooString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + ooString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(ooString); assertThat(ooString, containsString("Ok to delete")); @@ -460,10 +472,10 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { try { MethodOutcome results = myQuestionnaireDao.validate(null, null, input, EncodingEnum.XML, ValidationModeEnum.UPDATE, null, mySrd); OperationOutcome oo = (OperationOutcome) results.getOperationOutcome(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); } catch (PreconditionFailedException e) { // this is a failure of the test - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); throw e; } } @@ -479,16 +491,16 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { p.getMeta().addProfile("http://hl7.org/fhir/StructureDefinition/MyPatient421"); p.setActive(true); - String raw = myFhirCtx.newJsonParser().encodeResourceToString(p); + String raw = myFhirContext.newJsonParser().encodeResourceToString(p); try { MethodOutcome outcome = myPatientDao.validate(p, null, raw, EncodingEnum.JSON, null, null, mySrd); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getOperationOutcome()); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getOperationOutcome()); ourLog.info("OO: {}", encoded); assertThat(encoded, containsString("No issues detected")); } catch (PreconditionFailedException e) { // not expected, but let's log the error - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); fail(e.toString()); } } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ValueSetTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ValueSetTest.java index a12be5c911a..902d05dd499 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ValueSetTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ValueSetTest.java @@ -128,7 +128,7 @@ public class FhirResourceDaoDstu3ValueSetTest extends BaseJpaDstu3Test { assertEquals("http://hl7.org/fhir/ValueSet/endpoint-payload-type", vs.getUrl()); ValueSet expansion = myValueSetDao.expand(vs.getIdElement(), null, mySrd); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expansion)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expansion)); } @Test @@ -136,7 +136,7 @@ public class FhirResourceDaoDstu3ValueSetTest extends BaseJpaDstu3Test { String resp; ValueSet expanded = myValueSetDao.expand(myExtensionalVsId, null, mySrd); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, containsString("")); @@ -157,7 +157,7 @@ public class FhirResourceDaoDstu3ValueSetTest extends BaseJpaDstu3Test { */ expanded = myValueSetDao.expand(myExtensionalVsId, new ValueSetExpansionOptions().setFilter("systolic"), mySrd); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); //@formatter:off assertThat(resp, stringContainsInOrder( @@ -171,7 +171,7 @@ public class FhirResourceDaoDstu3ValueSetTest extends BaseJpaDstu3Test { @Disabled public void testExpandByIdentifier() { ValueSet expanded = myValueSetDao.expandByIdentifier("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2", new ValueSetExpansionOptions().setFilter("11378")); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); //@formatter:off assertThat(resp, stringContainsInOrder( @@ -190,7 +190,7 @@ public class FhirResourceDaoDstu3ValueSetTest extends BaseJpaDstu3Test { public void testExpandByValueSet() throws IOException { ValueSet toExpand = loadResourceFromClasspath(ValueSet.class, "/extensional-case-3-vs.xml"); ValueSet expanded = myValueSetDao.expand(toExpand, new ValueSetExpansionOptions().setFilter("11378")); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); //@formatter:off assertThat(resp, stringContainsInOrder( diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirSystemDaoDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirSystemDaoDstu3Test.java index 911f5055f32..d7a521fc882 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirSystemDaoDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirSystemDaoDstu3Test.java @@ -241,16 +241,16 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { private Bundle loadBundle(String theFileName) throws IOException { String req = IOUtils.toString(FhirSystemDaoDstu3Test.class.getResourceAsStream(theFileName), StandardCharsets.UTF_8); - return myFhirCtx.newXmlParser().parseResource(Bundle.class, req); + return myFhirContext.newXmlParser().parseResource(Bundle.class, req); } @Test public void testTransactionWithDuplicateConditionalCreates2() throws IOException { - Bundle request = myFhirCtx.newJsonParser().parseResource(Bundle.class, IOUtils.toString(FhirSystemDaoR4.class.getResourceAsStream("/dstu3/duplicate-conditional-create.json"), Constants.CHARSET_UTF8)); + Bundle request = myFhirContext.newJsonParser().parseResource(Bundle.class, IOUtils.toString(FhirSystemDaoR4.class.getResourceAsStream("/dstu3/duplicate-conditional-create.json"), Constants.CHARSET_UTF8)); Bundle response = mySystemDao.transaction(null, request); - ourLog.info("Response:\n{}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info("Response:\n{}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); List responseTypes = response .getEntry() @@ -289,7 +289,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { assertEquals("404 Not Found", response.getEntry().get(1).getResponse().getStatus()); OperationOutcome oo = (OperationOutcome) response.getEntry().get(1).getResponse().getOutcome(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(oo)); assertEquals(IssueSeverity.ERROR, oo.getIssue().get(0).getSeverity()); assertEquals(Msg.code(2001) + "Resource Patient/BABABABA is not known", oo.getIssue().get(0).getDiagnostics()); } @@ -323,7 +323,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { assertEquals("400 Bad Request", response.getEntry().get(1).getResponse().getStatus()); OperationOutcome oo = (OperationOutcome) response.getEntry().get(1).getResponse().getOutcome(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(oo)); assertEquals(IssueSeverity.ERROR, oo.getIssue().get(0).getSeverity()); assertThat(oo.getIssue().get(0).getDiagnostics(), containsString("Unknown search parameter")); } @@ -362,7 +362,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { .getRequest().setMethod(HTTPVerb.POST); Bundle resp = mySystemDao.transaction(mySrd, inputBundle); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); IdType epId = new IdType(resp.getEntry().get(0).getResponse().getLocation()); IdType condId = new IdType(resp.getEntry().get(1).getResponse().getLocation()); @@ -394,9 +394,9 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { .getRequest().setMethod(HTTPVerb.DELETE) .setUrl(condId.toUnqualifiedVersionless().getValue()); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(inputBundle)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(inputBundle)); resp = mySystemDao.transaction(mySrd, inputBundle); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); // They should now be deleted try { @@ -414,11 +414,11 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { public void testProcessCollectionAsBatch() throws IOException { byte[] inputBytes = IOUtils.toByteArray(getClass().getResourceAsStream("/dstu3/Reilly_Libby_73.json.gz")); String input = GZipUtil.decompress(inputBytes); - Bundle bundle = myFhirCtx.newJsonParser().setParserErrorHandler(new LenientErrorHandler()).parseResource(Bundle.class, input); + Bundle bundle = myFhirContext.newJsonParser().setParserErrorHandler(new LenientErrorHandler()).parseResource(Bundle.class, input); ourLog.info("Bundle has {} resources", bundle); Bundle output = mySystemDao.transaction(mySrd, bundle); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); } @@ -428,14 +428,14 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { @Test public void testContainedArePreservedForBug410() throws IOException { String input = IOUtils.toString(getClass().getResourceAsStream("/bug-410-bundle.xml"), StandardCharsets.UTF_8); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, input); Bundle output = mySystemDao.transaction(mySrd, bundle); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); IdType id = new IdType(output.getEntry().get(1).getResponse().getLocation()); MedicationRequest mo = myMedicationRequestDao.read(id); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(mo)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(mo)); } @Test @@ -547,7 +547,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { @Test public void testStructureDefinitionInBundle() throws IOException { String input = IOUtils.toString(FhirSystemDaoDstu3Test.class.getResourceAsStream("/bug1044-bundle.xml"), Charsets.UTF_8); - Bundle inputBundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + Bundle inputBundle = myFhirContext.newXmlParser().parseResource(Bundle.class, input); mySystemDao.transaction(mySrd, inputBundle); } @@ -630,10 +630,10 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { @Test public void testTransaction1() throws IOException { String inputBundleString = loadClasspath("/david-bundle-error.json"); - Bundle bundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, inputBundleString); + Bundle bundle = myFhirContext.newJsonParser().parseResource(Bundle.class, inputBundleString); Bundle resp = mySystemDao.transaction(mySrd, bundle); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); assertEquals("201 Created", resp.getEntry().get(0).getResponse().getStatus()); } @@ -654,7 +654,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { assertEquals(2, resp.getEntry().size()); assertEquals(BundleType.BATCHRESPONSE, resp.getTypeElement().getValue()); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); BundleEntryResponseComponent respEntry; // Bundle.entry[0] is create response @@ -974,7 +974,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { assertEquals("404 Not Found", response.getEntry().get(1).getResponse().getStatus()); OperationOutcome oo = (OperationOutcome) response.getEntry().get(1).getResponse().getOutcome(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(oo)); assertEquals(IssueSeverity.ERROR, oo.getIssue().get(0).getSeverity()); assertEquals(Msg.code(2001) + "Resource Patient/BABABABA is not known", oo.getIssue().get(0).getDiagnostics()); } @@ -1008,7 +1008,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { assertEquals("400 Bad Request", response.getEntry().get(1).getResponse().getStatus()); OperationOutcome oo = (OperationOutcome) response.getEntry().get(1).getResponse().getOutcome(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(oo)); assertEquals(IssueSeverity.ERROR, oo.getIssue().get(0).getSeverity()); assertThat(oo.getIssue().get(0).getDiagnostics(), containsString("Unknown search parameter")); } @@ -1424,12 +1424,12 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { fail(e.toString()); return; } - Bundle bundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, input); + Bundle bundle = myFhirContext.newJsonParser().parseResource(Bundle.class, input); mySystemDao.transaction(mySrd, bundle); IBundleProvider history = mySystemDao.history(null, null, null, null); Bundle list = toBundle(history); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(list)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(list)); assertEquals(6, list.getEntry().size()); @@ -1671,11 +1671,11 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/transaction_link_patient_eve.xml"); String bundleStr = IOUtils.toString(bundleRes, StandardCharsets.UTF_8); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, bundleStr); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, bundleStr); Bundle resp = mySystemDao.transaction(mySrd, bundle); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); assertThat(resp.getEntry().get(0).getResponse().getLocation(), startsWith("Patient/a555-44-4444/_history/")); assertThat(resp.getEntry().get(1).getResponse().getLocation(), startsWith("Patient/temp6789/_history/")); @@ -1688,10 +1688,10 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { @Test public void testTransactionFromBundle2() throws Exception { String input = IOUtils.toString(getClass().getResourceAsStream("/transaction-bundle.xml"), StandardCharsets.UTF_8); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, input); Bundle response = mySystemDao.transaction(mySrd, bundle); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); assertEquals("201 Created", response.getEntry().get(0).getResponse().getStatus()); assertThat(response.getEntry().get(0).getResponse().getLocation(), matchesPattern("Practitioner/[0-9]+/_history/1")); @@ -1699,10 +1699,10 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { * Now a second time */ - bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, input); response = mySystemDao.transaction(mySrd, bundle); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); assertEquals("200 OK", response.getEntry().get(0).getResponse().getStatus()); assertThat(response.getEntry().get(0).getResponse().getLocation(), matchesPattern("Practitioner/[0-9]+/_history/1")); @@ -1712,8 +1712,8 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { public void testTransactionFromBundle6() throws Exception { InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/simone_bundle3.xml"); String bundle = IOUtils.toString(bundleRes, StandardCharsets.UTF_8); - Bundle output = mySystemDao.transaction(mySrd, myFhirCtx.newXmlParser().parseResource(Bundle.class, bundle)); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + Bundle output = mySystemDao.transaction(mySrd, myFhirContext.newXmlParser().parseResource(Bundle.class, bundle)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); } @Test @@ -1721,11 +1721,11 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/josh-bundle.json"); String bundleStr = IOUtils.toString(bundleRes, StandardCharsets.UTF_8); - Bundle bundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, bundleStr); + Bundle bundle = myFhirContext.newJsonParser().parseResource(Bundle.class, bundleStr); Bundle resp = mySystemDao.transaction(mySrd, bundle); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); assertEquals("201 Created", resp.getEntry().get(0).getResponse().getStatus()); assertEquals("201 Created", resp.getEntry().get(1).getResponse().getStatus()); @@ -1759,7 +1759,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { params.put(Constants.PARAMETER_CASCADE_DELETE, new String[]{Constants.CASCADE_DELETE}); mySrd.setParameters(params); - CascadingDeleteInterceptor deleteInterceptor = new CascadingDeleteInterceptor(myFhirCtx, myDaoRegistry, myInterceptorBroadcaster); + CascadingDeleteInterceptor deleteInterceptor = new CascadingDeleteInterceptor(myFhirContext, myDaoRegistry, myInterceptorBroadcaster); myInterceptorBroadcaster.registerInterceptor(deleteInterceptor); @@ -1822,7 +1822,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { } private void testTransactionOrderingValidateResponse(int pass, Bundle resp) { - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); assertEquals(4, resp.getEntry().size()); assertEquals("200 OK", resp.getEntry().get(0).getResponse().getStatus()); if (pass == 0) { @@ -1857,13 +1857,13 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { Bundle inputBundle; Bundle outputBundle; - inputBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, input); + inputBundle = myFhirContext.newJsonParser().parseResource(Bundle.class, input); outputBundle = mySystemDao.transaction(mySrd, inputBundle); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outputBundle)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outputBundle)); - inputBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, input); + inputBundle = myFhirContext.newJsonParser().parseResource(Bundle.class, input); outputBundle = mySystemDao.transaction(mySrd, inputBundle); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outputBundle)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outputBundle)); IBundleProvider allPatients = myPatientDao.search(new SearchParameterMap()); assertEquals(1, allPatients.size().intValue()); @@ -2225,14 +2225,14 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/questionnaire-sdc-profile-example-ussg-fht.xml"); String bundleStr = IOUtils.toString(bundleRes, StandardCharsets.UTF_8); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, bundleStr); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, bundleStr); Bundle resp = mySystemDao.transaction(mySrd, bundle); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp); ourLog.info(encoded); - encoded = myFhirCtx.newJsonParser().setPrettyPrint(false).encodeResourceToString(resp); + encoded = myFhirContext.newJsonParser().setPrettyPrint(false).encodeResourceToString(resp); //@formatter:off assertThat(encoded, containsString("\"response\":{" + "\"status\":\"201 Created\"," + @@ -2245,10 +2245,10 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { resp = mySystemDao.transaction(mySrd, bundle); - encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp); + encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp); ourLog.info(encoded); - encoded = myFhirCtx.newJsonParser().setPrettyPrint(false).encodeResourceToString(resp); + encoded = myFhirContext.newJsonParser().setPrettyPrint(false).encodeResourceToString(resp); //@formatter:off assertThat(encoded, containsString("\"response\":{" + "\"status\":\"200 OK\"," + @@ -2422,10 +2422,10 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { myPatientDao.create(patient, mySrd); String input = IOUtils.toString(getClass().getResourceAsStream("/simone-conditional-url.xml"), StandardCharsets.UTF_8); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, input); Bundle response = mySystemDao.transaction(mySrd, bundle); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); } @@ -2442,7 +2442,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { myPatientDao.create(patient, mySrd); String input = IOUtils.toString(getClass().getResourceAsStream("/simone-conditional-url.xml"), StandardCharsets.UTF_8); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, input); try { mySystemDao.transaction(mySrd, bundle); @@ -2458,7 +2458,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { myDaoConfig.setAllowInlineMatchUrlReferences(true); String input = IOUtils.toString(getClass().getResourceAsStream("/simone-conditional-url.xml"), StandardCharsets.UTF_8); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, input); try { mySystemDao.transaction(mySrd, bundle); @@ -2488,10 +2488,10 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { @Test public void testTransactionWithMultiBundle() throws IOException { String inputBundleString = loadClasspath("/batch-error.xml"); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, inputBundleString); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, inputBundleString); Bundle resp = mySystemDao.transaction(mySrd, bundle); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); assertEquals("201 Created", resp.getEntry().get(0).getResponse().getStatus()); @@ -2555,7 +2555,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { //@formatter:on Bundle outputBundle = mySystemDao.transaction(mySrd, inputBundle); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(outputBundle)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(outputBundle)); assertEquals(3, outputBundle.getEntry().size()); IdDt id0 = new IdDt(outputBundle.getEntry().get(0).getResponse().getLocation()); @@ -2590,7 +2590,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { Bundle input2 = createInputTransactionWithPlaceholderIdInMatchUrl(HTTPVerb.POST); Bundle output2 = mySystemDao.transaction(null, input2); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output2)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output2)); assertEquals("200 OK", output2.getEntry().get(0).getResponse().getStatus()); assertEquals("200 OK", output2.getEntry().get(1).getResponse().getStatus()); @@ -2620,7 +2620,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { Bundle input2 = createInputTransactionWithPlaceholderIdInMatchUrl(HTTPVerb.PUT); Bundle output2 = mySystemDao.transaction(null, input2); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output2)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output2)); assertEquals("200 OK", output2.getEntry().get(0).getResponse().getStatus()); assertEquals("200 OK", output2.getEntry().get(1).getResponse().getStatus()); @@ -2637,9 +2637,9 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { // First bundle (name is Joshua) String input = IOUtils.toString(getClass().getResource("/dstu3-post1.xml"), StandardCharsets.UTF_8); - Bundle request = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + Bundle request = myFhirContext.newXmlParser().parseResource(Bundle.class, input); Bundle response = mySystemDao.transaction(mySrd, request); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); assertEquals(1, response.getEntry().size()); assertEquals("201 Created", response.getEntry().get(0).getResponse().getStatus()); @@ -2649,9 +2649,9 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { // Now the second (name is Adam, shouldn't get used) input = IOUtils.toString(getClass().getResource("/dstu3-post2.xml"), StandardCharsets.UTF_8); - request = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + request = myFhirContext.newXmlParser().parseResource(Bundle.class, input); response = mySystemDao.transaction(mySrd, request); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); assertEquals(1, response.getEntry().size()); assertEquals("200 OK", response.getEntry().get(0).getResponse().getStatus()); @@ -2660,7 +2660,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { assertEquals(id, id2); Patient patient = myPatientDao.read(new IdType(id), mySrd); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient)); assertEquals("Joshua", patient.getNameFirstRep().getGivenAsSingleString()); } @@ -2679,7 +2679,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { request.addEntry().setResource(o).getRequest().setMethod(HTTPVerb.POST); Bundle resp = mySystemDao.transaction(mySrd, request); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); String patientId = new IdType(resp.getEntry().get(0).getResponse().getLocation()).toUnqualifiedVersionless().getValue(); assertThat(patientId, startsWith("Patient/")); @@ -2706,10 +2706,10 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { mo.setMedication(new Reference(medId)); bundle.addEntry().setResource(mo).setFullUrl(mo.getIdElement().getValue()).getRequest().setMethod(HTTPVerb.POST); - ourLog.info("Request:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info("Request:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); Bundle outcome = mySystemDao.transaction(mySrd, bundle); - ourLog.info("Response:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info("Response:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); IdType medId1 = new IdType(outcome.getEntry().get(0).getResponse().getLocation()); IdType medOrderId1 = new IdType(outcome.getEntry().get(1).getResponse().getLocation()); @@ -2759,7 +2759,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { request.addEntry().setResource(o).getRequest().setMethod(HTTPVerb.POST); Bundle resp = mySystemDao.transaction(mySrd, request); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); String patientId = new IdType(resp.getEntry().get(0).getResponse().getLocation()).toUnqualifiedVersionless().getValue(); assertThat(patientId, startsWith("Patient/")); @@ -2793,7 +2793,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { Bundle resp = mySystemDao.transaction(mySrd, res); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); assertEquals(BundleType.TRANSACTIONRESPONSE, resp.getTypeElement().getValue()); assertEquals(3, resp.getEntry().size()); @@ -2834,7 +2834,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { Bundle resp = mySystemDao.transaction(mySrd, res); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); assertEquals(BundleType.TRANSACTIONRESPONSE, resp.getTypeElement().getValue()); assertEquals(3, resp.getEntry().size()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/expunge/DeleteExpungeDaoTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/expunge/DeleteExpungeDaoTest.java index 206509927a0..e0374be7000 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/expunge/DeleteExpungeDaoTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/expunge/DeleteExpungeDaoTest.java @@ -124,7 +124,7 @@ class DeleteExpungeDaoTest extends BaseJpaR4Test { //See https://github.com/hapifhir/hapi-fhir/issues/2661 // setup - BundleBuilder builder = new BundleBuilder(myFhirCtx); + BundleBuilder builder = new BundleBuilder(myFhirContext); for (int i = 0; i < 20; i++) { Organization o = new Organization(); o.setId("Organization/O-" + i); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseJpaR4SystemTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseJpaR4SystemTest.java index 81426ff66ed..aaaf618ed16 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseJpaR4SystemTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseJpaR4SystemTest.java @@ -21,7 +21,7 @@ public abstract class BaseJpaR4SystemTest extends BaseJpaR4Test { super.beforeInitMocks(); if (myServer == null) { - myServer = new RestfulServer(myFhirCtx, mySrdInterceptorService); + myServer = new RestfulServer(myFhirContext, mySrdInterceptorService); PatientResourceProvider patientRp = new PatientResourceProvider(); patientRp.setDao(myPatientDao); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseJpaR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseJpaR4Test.java index 90e7fe64406..75ee90a4a5a 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseJpaR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseJpaR4Test.java @@ -167,7 +167,6 @@ import org.hl7.fhir.r5.utils.validation.constants.BindingKind; import org.hl7.fhir.r5.utils.validation.constants.CodedContentValidationPolicy; import org.hl7.fhir.r5.utils.validation.constants.ContainedReferenceValidationPolicy; import org.hl7.fhir.r5.utils.validation.constants.ReferenceValidationPolicy; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.ExtendWith; @@ -316,7 +315,7 @@ public abstract class BaseJpaR4Test extends BaseJpaTest implements ITestDataBuil @Autowired protected EntityManager myEntityManager; @Autowired - protected FhirContext myFhirCtx; + protected FhirContext myFhirContext; @Autowired @Qualifier("myGroupDaoR4") protected IFhirResourceDao myGroupDao; @@ -566,7 +565,7 @@ public abstract class BaseJpaR4Test extends BaseJpaTest implements ITestDataBuil @BeforeEach public void beforeResetConfig() { - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); myValidationSettings.setLocalReferenceValidationDefaultPolicy(new ValidationSettings().getLocalReferenceValidationDefaultPolicy()); } @@ -583,17 +582,12 @@ public abstract class BaseJpaR4Test extends BaseJpaTest implements ITestDataBuil } protected String encode(IBaseResource theResource) { - return myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(theResource); + return myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(theResource); } @Override public FhirContext getFhirContext() { - return myFhirCtx; - } - - @Override - protected FhirContext getContext() { - return myFhirCtx; + return myFhirContext; } @Override @@ -602,25 +596,25 @@ public abstract class BaseJpaR4Test extends BaseJpaTest implements ITestDataBuil } protected T loadResourceFromClasspath(Class type, String resourceName) throws IOException { - return ClasspathUtil.loadResource(myFhirCtx, type, resourceName); + return ClasspathUtil.loadResource(myFhirContext, type, resourceName); } protected void validate(IBaseResource theResource) { - FhirValidator validatorModule = myFhirCtx.newValidator(); + FhirValidator validatorModule = myFhirContext.newValidator(); FhirInstanceValidator instanceValidator = new FhirInstanceValidator(myValidationSupport); instanceValidator.setBestPracticeWarningLevel(BestPracticeWarningLevel.Ignore); instanceValidator.setValidatorPolicyAdvisor(new ValidationPolicyAdvisor()); validatorModule.registerValidatorModule(instanceValidator); ValidationResult result = validatorModule.validateWithResult(theResource); if (!result.isSuccessful()) { - fail(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result.toOperationOutcome())); + fail(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(result.toOperationOutcome())); } } @SuppressWarnings("unchecked") protected void upload(String theClasspath) throws IOException { String resource = loadResource(theClasspath); - IParser parser = EncodingEnum.detectEncoding(resource).newParser(myFhirCtx); + IParser parser = EncodingEnum.detectEncoding(resource).newParser(myFhirContext); IBaseResource resourceParsed = parser.parseResource(resource); IFhirResourceDao dao = myDaoRegistry.getResourceDao(resourceParsed.getIdElement().getResourceType()); dao.update(resourceParsed); @@ -690,7 +684,7 @@ public abstract class BaseJpaR4Test extends BaseJpaTest implements ITestDataBuil Optional first = stream.findFirst(); if (!first.isPresent()) { - String expandedValueSetString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(theValueSet); + String expandedValueSetString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(theValueSet); String failureMessage = String.format("Expanded ValueSet %s did not contain concept [%s|%s|%s] with [%d] designations. Outcome:\n%s", theValueSet.getId(), theSystem, theCode, theDisplay, theDesignationCount, expandedValueSetString); fail(failureMessage); return null; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseR4SearchLastN.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseR4SearchLastN.java index 6b3163908d5..ad748a683c9 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseR4SearchLastN.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseR4SearchLastN.java @@ -94,7 +94,7 @@ abstract public class BaseR4SearchLastN extends BaseJpaTest { protected ElasticsearchSvcImpl myElasticsearchSvc; @Override - protected FhirContext getContext() { + protected FhirContext getFhirContext() { return myFhirCtx; } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/ChainingR4SearchTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/ChainingR4SearchTest.java index 69a825ec837..ab952ad670b 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/ChainingR4SearchTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/ChainingR4SearchTest.java @@ -57,7 +57,7 @@ public class ChainingR4SearchTest extends BaseJpaR4Test { @BeforeEach public void before() throws Exception { - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); myDaoConfig.setAllowMultipleDelete(true); myDaoConfig.setSearchPreFetchThresholds(new DaoConfig().getSearchPreFetchThresholds()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoCreatePlaceholdersR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoCreatePlaceholdersR4Test.java index c4f0ce43d08..6900a83ac4e 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoCreatePlaceholdersR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoCreatePlaceholdersR4Test.java @@ -34,7 +34,6 @@ import org.junit.jupiter.api.Test; import java.util.HashSet; import java.util.List; -import java.util.Optional; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.startsWith; @@ -211,7 +210,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { // Read the Observation Observation createdObs = myObservationDao.read(id); - ourLog.info("\nObservation created:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); + ourLog.info("\nObservation created:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); /* * Read the placeholder Patient referenced by the Observation @@ -219,7 +218,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { */ Patient placeholderPat = myPatientDao.read(new IdType(createdObs.getSubject().getReference())); IIdType placeholderPatId = placeholderPat.getIdElement(); - ourLog.info("\nPlaceholder Patient created:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(placeholderPat)); + ourLog.info("\nPlaceholder Patient created:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(placeholderPat)); assertEquals(0, placeholderPat.getIdentifier().size()); Extension extension = placeholderPat.getExtensionByUrl(HapiExtensions.EXT_RESOURCE_PLACEHOLDER); assertNotNull(extension); @@ -237,7 +236,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { * Placeholder extension should not exist */ Patient updatedPat = myPatientDao.read(updatedPatId); - ourLog.info("\nUpdated Patient:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedPat)); + ourLog.info("\nUpdated Patient:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedPat)); assertEquals(1, updatedPat.getIdentifier().size()); extension = updatedPat.getExtensionByUrl(HapiExtensions.EXT_RESOURCE_PLACEHOLDER); assertNull(extension); @@ -256,10 +255,10 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { IIdType id = myObservationDao.create(obsToCreate, mySrd).getId(); Observation createdObs = myObservationDao.read(id); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); Patient patient = myPatientDao.read(new IdType(createdObs.getSubject().getReference())); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); assertEquals(0, patient.getIdentifier().size()); } @@ -290,7 +289,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { //Read the Placeholder Patient Patient placeholderPat = myPatientDao.read(new IdType(createdObs.getSubject().getReference())); - ourLog.info("\nObservation created:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); + ourLog.info("\nObservation created:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); //Ensure the Obs has the right placeholder ID. IIdType placeholderPatId = placeholderPat.getIdElement(); @@ -299,7 +298,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { /* * Should have a single identifier populated. */ - ourLog.info("\nPlaceholder Patient created:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(placeholderPat)); + ourLog.info("\nPlaceholder Patient created:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(placeholderPat)); assertEquals(1, placeholderPat.getIdentifier().size()); List identifiers = placeholderPat.getIdentifier(); Identifier identifier = identifiers.get(0); @@ -335,7 +334,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { //Read the Placeholder Patient Patient placeholderPat = myPatientDao.read(new IdType(createdObs.getSubject().getReference())); - ourLog.info("\nObservation created:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); + ourLog.info("\nObservation created:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); //Ensure the Obs has the right placeholder ID. IIdType placeholderPatId = placeholderPat.getIdElement(); @@ -344,7 +343,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { /* * Should have a single identifier populated. */ - ourLog.info("\nPlaceholder Patient created:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(placeholderPat)); + ourLog.info("\nPlaceholder Patient created:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(placeholderPat)); assertEquals(1, placeholderPat.getIdentifier().size()); List identifiers = placeholderPat.getIdentifier(); Identifier identifier = identifiers.get(0); @@ -381,7 +380,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { //Read the Placeholder Patient Patient placeholderPat = myPatientDao.read(new IdType(createdObs.getSubject().getReference())); - ourLog.info("\nObservation created:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); + ourLog.info("\nObservation created:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); //Ensure the Obs has the right placeholder ID. IIdType placeholderPatId = placeholderPat.getIdElement(); @@ -390,7 +389,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { /* * Should have a single identifier populated. */ - ourLog.info("\nPlaceholder Patient created:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(placeholderPat)); + ourLog.info("\nPlaceholder Patient created:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(placeholderPat)); assertEquals(1, placeholderPat.getIdentifier().size()); List identifiers = placeholderPat.getIdentifier(); Identifier identifier = identifiers.get(0); @@ -428,7 +427,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { //Read the Placeholder Patient Patient placeholderPat = myPatientDao.read(new IdType(createdObs.getSubject().getReference())); - ourLog.info("\nObservation created:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); + ourLog.info("\nObservation created:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); //Ensure the Obs has the right placeholder ID. IIdType placeholderPatId = placeholderPat.getIdElement(); @@ -437,7 +436,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { /* * Placeholder Identifiers should both be populated since they were both provided, and did not match */ - ourLog.info("\nPlaceholder Patient created:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(placeholderPat)); + ourLog.info("\nPlaceholder Patient created:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(placeholderPat)); assertEquals(2, placeholderPat.getIdentifier().size()); List identifiers = placeholderPat.getIdentifier(); @@ -458,7 +457,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { // Read the conditionally updated Patient Patient conditionalUpdatePat = myPatientDao.read(conditionalUpdatePatId); - ourLog.info("\nConditionally updated Patient:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conditionalUpdatePat)); + ourLog.info("\nConditionally updated Patient:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conditionalUpdatePat)); assertEquals(1, conditionalUpdatePat.getIdentifier().size()); /* @@ -466,7 +465,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { * ID of placeholder Patient should match ID of conditionally updated Patient */ createdObs = myObservationDao.read(obsId); - ourLog.info("\nObservation read after Patient update:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); + ourLog.info("\nObservation read after Patient update:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); assertEquals(createdObs.getSubject().getReference(), conditionalUpdatePatId.toUnqualifiedVersionless().getValueAsString()); assertEquals(placeholderPatId.toUnqualifiedVersionless().getValueAsString(), conditionalUpdatePatId.toUnqualifiedVersionless().getValueAsString()); } @@ -488,7 +487,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { // Read the Observation Observation createdObs = myObservationDao.read(obsId); - ourLog.info("\nObservation created:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); + ourLog.info("\nObservation created:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); /* * Read the placeholder Patient referenced by the Observation @@ -496,7 +495,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { */ Patient placeholderPat = myPatientDao.read(new IdType(createdObs.getSubject().getReference())); IIdType placeholderPatId = placeholderPat.getIdElement(); - ourLog.info("\nPlaceholder Patient created:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(placeholderPat)); + ourLog.info("\nPlaceholder Patient created:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(placeholderPat)); assertEquals(1, placeholderPat.getIdentifier().size()); assertEquals(createdObs.getSubject().getReference(), placeholderPatId.toUnqualifiedVersionless().getValueAsString()); @@ -508,7 +507,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { // Read the conditionally updated Patient Patient conditionalUpdatePat = myPatientDao.read(conditionalUpdatePatId); - ourLog.info("\nConditionally updated Patient:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conditionalUpdatePat)); + ourLog.info("\nConditionally updated Patient:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conditionalUpdatePat)); assertEquals(1, conditionalUpdatePat.getIdentifier().size()); /* @@ -516,7 +515,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { * ID of placeholder Patient should match ID of conditionally updated Patient */ createdObs = myObservationDao.read(obsId); - ourLog.info("\nObservation read after Patient update:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); + ourLog.info("\nObservation read after Patient update:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); assertEquals(createdObs.getSubject().getReference(), conditionalUpdatePatId.toUnqualifiedVersionless().getValueAsString()); assertEquals(placeholderPatId.toUnqualifiedVersionless().getValueAsString(), conditionalUpdatePatId.toUnqualifiedVersionless().getValueAsString()); } @@ -533,10 +532,10 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { IIdType id = myObservationDao.create(obsToCreate, mySrd).getId(); Observation createdObs = myObservationDao.read(id); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); Patient patient = myPatientDao.read(new IdType(createdObs.getSubject().getReference())); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); assertEquals(1, patient.getIdentifier().size()); assertEquals("http://foo", patient.getIdentifier().get(0).getSystem()); assertEquals("123", patient.getIdentifier().get(0).getValue()); @@ -556,7 +555,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { IIdType id = myAuditEventDao.create(eventToCreate, mySrd).getId(); AuditEvent createdEvent = myAuditEventDao.read(id); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEvent)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEvent)); } @Test @@ -587,7 +586,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { obs.setId("Observation/DEF"); Reference patientRef = new Reference("Patient/RED"); obs.setSubject(patientRef); - BundleBuilder builder = new BundleBuilder(myFhirCtx); + BundleBuilder builder = new BundleBuilder(myFhirContext); builder.addTransactionUpdateEntry(obs); mySystemDao.transaction(new SystemRequestDetails(), (Bundle) builder.getBundle()); @@ -619,7 +618,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { obs.setId("Observation/DEF"); Reference patientRef = new Reference(patientId); obs.setSubject(patientRef); - BundleBuilder builder = new BundleBuilder(myFhirCtx); + BundleBuilder builder = new BundleBuilder(myFhirContext); builder.addTransactionUpdateEntry(obs); Bundle transaction = mySystemDao.transaction(new SystemRequestDetails(), (Bundle) builder.getBundle()); @@ -655,7 +654,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { obs.setId("Observation/DEF"); Reference patientRef = new Reference("Patient/" + ret.getId().getIdPart()); obs.setSubject(patientRef); - BundleBuilder builder = new BundleBuilder(myFhirCtx); + BundleBuilder builder = new BundleBuilder(myFhirContext); builder.addTransactionUpdateEntry(obs); Bundle transaction = mySystemDao.transaction(new SystemRequestDetails(), (Bundle) builder.getBundle()); @@ -680,7 +679,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { obs1.setId("Observation/DEF1"); Reference patientRef = new Reference("Patient/RED"); obs1.setSubject(patientRef); - BundleBuilder builder = new BundleBuilder(myFhirCtx); + BundleBuilder builder = new BundleBuilder(myFhirContext); Observation obs2 = new Observation(); obs2.setId("Observation/DEF2"); obs2.setSubject(patientRef); @@ -702,7 +701,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { obs1.setId("Observation/DEF1"); Reference patientRef = new Reference("Patient/RED"); obs1.setSubject(patientRef); - BundleBuilder builder = new BundleBuilder(myFhirCtx); + BundleBuilder builder = new BundleBuilder(myFhirContext); Observation obs2 = new Observation(); obs2.setId("Observation/DEF2"); obs2.setSubject(patientRef); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoCustomTypeR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoCustomTypeR4Test.java index a25f1d01248..f360879bb36 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoCustomTypeR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoCustomTypeR4Test.java @@ -4,9 +4,9 @@ import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.rest.api.server.IBundleProvider; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.model.StringType; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -17,7 +17,7 @@ public class FhirResourceDaoCustomTypeR4Test extends BaseJpaR4Test { @BeforeEach public void before() { - myFhirCtx.setDefaultTypeForProfile(CustomObservationR4.PROFILE, CustomObservationR4.class); + myFhirContext.setDefaultTypeForProfile(CustomObservationR4.PROFILE, CustomObservationR4.class); } @Test @@ -39,6 +39,6 @@ public class FhirResourceDaoCustomTypeR4Test extends BaseJpaR4Test { @AfterEach public void after() { - myFhirCtx.setDefaultTypeForProfile(CustomObservationR4.PROFILE, null); + myFhirContext.setDefaultTypeForProfile(CustomObservationR4.PROFILE, null); } } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoDocumentR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoDocumentR4Test.java index f1d181032b9..7021cb73f62 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoDocumentR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoDocumentR4Test.java @@ -1,10 +1,8 @@ package ca.uhn.fhir.jpa.dao.r4; import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome; -import ca.uhn.fhir.util.TestUtil; import org.apache.commons.io.IOUtils; import org.hl7.fhir.r4.model.Bundle; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Test; import java.nio.charset.StandardCharsets; @@ -16,7 +14,7 @@ public class FhirResourceDaoDocumentR4Test extends BaseJpaR4Test { @Test public void testPostDocument() throws Exception { String input = IOUtils.toString(getClass().getResourceAsStream("/sample-document.xml"), StandardCharsets.UTF_8); - Bundle inputBundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + Bundle inputBundle = myFhirContext.newXmlParser().parseResource(Bundle.class, input); DaoMethodOutcome responseBundle = myBundleDao.create(inputBundle, mySrd); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4CodeSystemTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4CodeSystemTest.java index 1db04635e74..2785e61acd7 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4CodeSystemTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4CodeSystemTest.java @@ -29,7 +29,7 @@ public class FhirResourceDaoR4CodeSystemTest extends BaseJpaR4Test { TermReindexingSvcImpl.setForceSaveDeferredAlwaysForUnitTest(true); String input = IOUtils.toString(getClass().getResource("/r4/codesystem_complete.json"), StandardCharsets.UTF_8); - CodeSystem cs = myFhirCtx.newJsonParser().parseResource(CodeSystem.class, input); + CodeSystem cs = myFhirContext.newJsonParser().parseResource(CodeSystem.class, input); myCodeSystemDao.create(cs, mySrd); myResourceReindexingSvc.markAllResourcesForReindexing(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ComboUniqueParamTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ComboUniqueParamTest.java index e11d7561c0a..e01990629d6 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ComboUniqueParamTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ComboUniqueParamTest.java @@ -492,7 +492,7 @@ public class FhirResourceDaoR4ComboUniqueParamTest extends BaseComboParamsR4Test .setValue(new BooleanType(true)); mySearchParameterDao.create(sp); mySearchParamRegistry.forceRefresh(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(sp)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(sp)); // Now create matching/non-matching resources Patient pt = new Patient(); @@ -977,11 +977,11 @@ public class FhirResourceDaoR4ComboUniqueParamTest extends BaseComboParamsR4Test " ]\n" + "}"; - Bundle inputBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, input); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inputBundle)); + Bundle inputBundle = myFhirContext.newJsonParser().parseResource(Bundle.class, input); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inputBundle)); mySystemDao.transaction(mySrd, inputBundle); - inputBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, input); + inputBundle = myFhirContext.newJsonParser().parseResource(Bundle.class, input); mySystemDao.transaction(mySrd, inputBundle); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ConceptMapTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ConceptMapTest.java index fb6ed0ccf65..2036fb1da3a 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ConceptMapTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ConceptMapTest.java @@ -81,7 +81,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testTranslateByCodeSystemsAndSourceCodeOneToMany() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -125,7 +125,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testTranslateByCodeSystemsAndSourceCodeOneToOne() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -160,7 +160,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testTranslateByCodeSystemsAndSourceCodeUnmapped() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -187,7 +187,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testTranslateUsingPredicatesWithCodeOnly() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -238,7 +238,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testTranslateUsingPredicatesWithSourceAndTargetSystem2() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -277,7 +277,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testTranslateUsingPredicatesWithSourceAndTargetSystem3() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -324,7 +324,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testTranslateUsingPredicatesWithSourceSystem() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -377,7 +377,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testTranslateUsingPredicatesWithSourceSystemAndVersion1() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -416,7 +416,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testTranslateUsingPredicatesWithSourceSystemAndVersion3() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -463,7 +463,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testTranslateUsingPredicatesWithSourceValueSet() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -516,7 +516,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testTranslateUsingPredicatesWithTargetValueSet() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -569,7 +569,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testTranslateWithReverse() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -717,7 +717,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testTranslateWithReverseHavingEquivalence() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -758,7 +758,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testTranslateWithReverseByCodeSystemsAndSourceCodeUnmapped() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -786,7 +786,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testTranslateWithReverseUsingPredicatesWithCodeOnly() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -831,7 +831,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testTranslateWithReverseUsingPredicatesWithSourceAndTargetSystem1() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -872,7 +872,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testTranslateWithReverseUsingPredicatesWithSourceAndTargetSystem4() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -913,7 +913,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testTranslateWithReverseUsingPredicatesWithSourceSystem() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -960,7 +960,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testTranslateWithReverseUsingPredicatesWithSourceSystemAndVersion() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -1009,7 +1009,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testTranslateWithReverseUsingPredicatesWithSourceValueSet() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -1056,7 +1056,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testTranslateWithReverseUsingPredicatesWithTargetValueSet() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ConcurrentWriteTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ConcurrentWriteTest.java index 714c6b70b9f..e255ec4bf69 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ConcurrentWriteTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ConcurrentWriteTest.java @@ -72,7 +72,7 @@ public class FhirResourceDaoR4ConcurrentWriteTest extends BaseJpaR4Test { myRetryInterceptor = new UserRequestRetryVersionConflictsInterceptor(); myConcurrencySemaphoreInterceptor = new TransactionConcurrencySemaphoreInterceptor(myMemoryCacheService); - RestfulServer server = new RestfulServer(myFhirCtx); + RestfulServer server = new RestfulServer(myFhirContext); when(mySrd.getServer()).thenReturn(server); } @@ -215,7 +215,7 @@ public class FhirResourceDaoR4ConcurrentWriteTest extends BaseJpaR4Test { myConcurrencySemaphoreInterceptor.setLogWaits(true); Runnable creator = ()->{ - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); Patient patient1 = new Patient(); patient1.addIdentifier().setSystem("http://foo").setValue("1"); @@ -276,7 +276,7 @@ public class FhirResourceDaoR4ConcurrentWriteTest extends BaseJpaR4Test { @Nonnull private Runnable newTransactionTaskWithUpdatesAndConditionalUpdates(AtomicInteger theSetCounter, AtomicInteger theFuzzCounter) { Runnable creator = () -> { - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); String patientId = "Patient/PT" + theSetCounter.get(); IdType practitionerId = IdType.newRandomUuid(); IdType practitionerId2 = IdType.newRandomUuid(); @@ -358,7 +358,7 @@ public class FhirResourceDaoR4ConcurrentWriteTest extends BaseJpaR4Test { // Make sure we saved the object Patient patient = myPatientDao.read(new IdType("Patient/ABC")); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); assertEquals(true, patient.getActive()); } @@ -391,7 +391,7 @@ public class FhirResourceDaoR4ConcurrentWriteTest extends BaseJpaR4Test { // Make sure we saved the object Patient patient = myPatientDao.read(new IdType("Patient/ABC")); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); assertEquals(true, patient.getActive()); } @@ -424,7 +424,7 @@ public class FhirResourceDaoR4ConcurrentWriteTest extends BaseJpaR4Test { // Make sure we saved the object Patient patient = myPatientDao.read(new IdType("Patient/ABC")); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); assertEquals(true, patient.getActive()); } @@ -578,7 +578,7 @@ public class FhirResourceDaoR4ConcurrentWriteTest extends BaseJpaR4Test { // Make sure we saved the object Patient patient = myPatientDao.read(new IdType("Patient/ABC")); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); assertEquals(true, patient.getActive()); } @@ -614,7 +614,7 @@ public class FhirResourceDaoR4ConcurrentWriteTest extends BaseJpaR4Test { // Make sure we saved the object Patient patient = myPatientDao.read(new IdType("Patient/ABC")); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); assertEquals(true, patient.getActive()); } @@ -654,7 +654,7 @@ public class FhirResourceDaoR4ConcurrentWriteTest extends BaseJpaR4Test { // Make sure we saved the object Patient patient = myPatientDao.read(new IdType("Patient/ABC")); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); assertEquals(true, patient.getActive()); } @@ -707,7 +707,7 @@ public class FhirResourceDaoR4ConcurrentWriteTest extends BaseJpaR4Test { // Make sure we saved the object Patient patient = myPatientDao.read(pId); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); assertEquals("6", patient.getMeta().getVersionId()); } @@ -721,7 +721,7 @@ public class FhirResourceDaoR4ConcurrentWriteTest extends BaseJpaR4Test { String value = UserRequestRetryVersionConflictsInterceptor.RETRY + "; " + UserRequestRetryVersionConflictsInterceptor.MAX_RETRIES + "=10"; when(srd.getHeaders(eq(UserRequestRetryVersionConflictsInterceptor.HEADER_NAME))).thenReturn(Collections.singletonList(value)); when(srd.getUserData()).thenReturn(new HashMap<>()); - when(srd.getServer()).thenReturn(new RestfulServer(myFhirCtx)); + when(srd.getServer()).thenReturn(new RestfulServer(myFhirContext)); when(srd.getInterceptorBroadcaster()).thenReturn(new InterceptorService()); List> futures = new ArrayList<>(); @@ -759,7 +759,7 @@ public class FhirResourceDaoR4ConcurrentWriteTest extends BaseJpaR4Test { // Make sure we saved the object Patient patient = myPatientDao.read(new IdType("Patient/ABC")); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); assertEquals(true, patient.getActive()); } @@ -774,7 +774,7 @@ public class FhirResourceDaoR4ConcurrentWriteTest extends BaseJpaR4Test { String value = UserRequestRetryVersionConflictsInterceptor.RETRY + "; " + UserRequestRetryVersionConflictsInterceptor.MAX_RETRIES + "=10"; when(srd.getHeaders(eq(UserRequestRetryVersionConflictsInterceptor.HEADER_NAME))).thenReturn(Collections.singletonList(value)); when(srd.getUserData()).thenReturn(new HashMap<>()); - when(srd.getServer()).thenReturn(new RestfulServer(myFhirCtx)); + when(srd.getServer()).thenReturn(new RestfulServer(myFhirContext)); when(srd.getInterceptorBroadcaster()).thenReturn(new InterceptorService()); List> futures = new ArrayList<>(); @@ -783,7 +783,7 @@ public class FhirResourceDaoR4ConcurrentWriteTest extends BaseJpaR4Test { String patientId = "PATIENT" + i; Runnable task = () -> { - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); Patient p = new Patient(); p.setId(patientId); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ContainedTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ContainedTest.java index b5aa3a1c381..13d29540fd1 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ContainedTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ContainedTest.java @@ -2,7 +2,6 @@ package ca.uhn.fhir.jpa.dao.r4; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; -import ca.uhn.fhir.rest.api.SearchContainedModeEnum; import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.param.ReferenceParam; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; @@ -57,13 +56,13 @@ public class FhirResourceDaoR4ContainedTest extends BaseJpaR4Test { obs.getCode().setText("Some Observation"); obs.setSubject(new Reference(p)); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); IIdType id = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); Observation createdObs = myObservationDao.read(id); - ourLog.info("Output: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); + ourLog.info("Output: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); runInTransaction(()->{ ourLog.info("String indexes:\n * {}", myResourceIndexedSearchParamStringDao.findAll().stream().map(t->t.toString()).collect(Collectors.joining("\n * "))); @@ -93,13 +92,13 @@ public class FhirResourceDaoR4ContainedTest extends BaseJpaR4Test { obs.getContained().add(p); obs.getSubject().setReference("#fooId"); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); IIdType id = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); Observation createdObs = myObservationDao.read(id); - ourLog.info("Output: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); + ourLog.info("Output: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); runInTransaction(()->{ Long i = myEntityManager @@ -153,13 +152,13 @@ public class FhirResourceDaoR4ContainedTest extends BaseJpaR4Test { patient.addGeneralPractitioner().setReference("#org1"); patient.getManagingOrganization().setReference("#org2"); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); IIdType id = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless(); Patient createdPatient = myPatientDao.read(id); - ourLog.info("Output: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdPatient)); + ourLog.info("Output: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdPatient)); runInTransaction(()->{ Long i = myEntityManager @@ -224,13 +223,13 @@ public class FhirResourceDaoR4ContainedTest extends BaseJpaR4Test { encounter.addReasonReference().setReference("#obs1"); encounter.getContained().add(obs); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); IIdType id = myEncounterDao.create(encounter, mySrd).getId().toUnqualifiedVersionless(); Encounter createdEncounter = myEncounterDao.read(id); - ourLog.info("Output: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEncounter)); + ourLog.info("Output: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEncounter)); runInTransaction(()->{ // The practitioner diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4CreateTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4CreateTest.java index b44f9cf4f66..bfd84b16f0e 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4CreateTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4CreateTest.java @@ -67,7 +67,6 @@ import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.matchesPattern; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; @@ -340,7 +339,7 @@ public class FhirResourceDaoR4CreateTest extends BaseJpaR4Test { */ @Test public void testConditionalCreateFailsIfMatchUrlDoesntMatch_InTransaction() { - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); Patient patient = new Patient(); patient.setId(IdType.newRandomUuid()); @@ -363,7 +362,7 @@ public class FhirResourceDaoR4CreateTest extends BaseJpaR4Test { @Test public void testCreateResourceWithKoreanText() throws IOException { String input = loadClasspath("/r4/bug832-korean-text.xml"); - Patient p = myFhirCtx.newXmlParser().parseResource(Patient.class, input); + Patient p = myFhirContext.newXmlParser().parseResource(Patient.class, input); String id = myPatientDao.create(p).getId().toUnqualifiedVersionless().getValue(); SearchParameterMap map = new SearchParameterMap(); @@ -619,11 +618,11 @@ public class FhirResourceDaoR4CreateTest extends BaseJpaR4Test { .getRequest() .setMethod(Bundle.HTTPVerb.POST); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(input)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(input)); Bundle output = mySystemDao.transaction(mySrd, input); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); assertThat(output.getEntry().get(0).getResponse().getLocation(), matchesPattern("Organization/[a-z0-9]{8}-.*")); assertThat(output.getEntry().get(1).getResponse().getLocation(), matchesPattern("Patient/[a-z0-9]{8}-.*")); @@ -640,7 +639,7 @@ public class FhirResourceDaoR4CreateTest extends BaseJpaR4Test { o.getMeta().addTag("http://foo", "bar", "FOOBAR"); p.getManagingOrganization().setResource(o); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(p); ourLog.info("Input: {}", encoded); assertThat(encoded, containsString("#1")); @@ -648,7 +647,7 @@ public class FhirResourceDaoR4CreateTest extends BaseJpaR4Test { p = myPatientDao.read(id); - encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p); + encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(p); ourLog.info("Output: {}", encoded); assertThat(encoded, containsString("#1")); @@ -691,7 +690,7 @@ public class FhirResourceDaoR4CreateTest extends BaseJpaR4Test { q.setCode("cm"); obs.setValue(q); - ourLog.info("Observation1: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation1: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); assertTrue(myObservationDao.create(obs).getCreated()); @@ -731,7 +730,7 @@ public class FhirResourceDaoR4CreateTest extends BaseJpaR4Test { q.setCode("mm"); obs.setValue(q); - ourLog.info("Observation1: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation1: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); myCaptureQueriesListener.clear(); assertTrue(myObservationDao.create(obs).getCreated()); @@ -808,7 +807,7 @@ public class FhirResourceDaoR4CreateTest extends BaseJpaR4Test { q.setCode("mm"); obs.setValue(q); - ourLog.info("Observation1: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation1: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); assertTrue(myObservationDao.create(obs).getCreated()); @@ -843,7 +842,7 @@ public class FhirResourceDaoR4CreateTest extends BaseJpaR4Test { assertEquals(1, ids.size()); - ourLog.info("Observation2: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(resources.get(0))); + ourLog.info("Observation2: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resources.get(0))); } @@ -860,7 +859,7 @@ public class FhirResourceDaoR4CreateTest extends BaseJpaR4Test { q.setCode("kg/dL"); obs.setValue(q); - ourLog.info("Observation1: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation1: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); assertTrue(myObservationDao.create(obs).getCreated()); @@ -900,7 +899,7 @@ public class FhirResourceDaoR4CreateTest extends BaseJpaR4Test { q.setCode("kg/dL"); obs.setValue(q); - ourLog.info("Observation1: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation1: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); assertTrue(myObservationDao.create(obs).getCreated()); @@ -947,7 +946,7 @@ public class FhirResourceDaoR4CreateTest extends BaseJpaR4Test { q.setCode("mm"); obs.setValue(q); - ourLog.info("Observation1: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation1: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); myCaptureQueriesListener.clear(); assertTrue(myObservationDao.create(obs).getCreated()); @@ -1080,7 +1079,7 @@ public class FhirResourceDaoR4CreateTest extends BaseJpaR4Test { q.setCode("mm"); obs.setValue(q); - ourLog.info("Observation1: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation1: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); myCaptureQueriesListener.clear(); assertTrue(myObservationDao.create(obs).getCreated()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4DeleteTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4DeleteTest.java index 0975a01f676..9c68174d289 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4DeleteTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4DeleteTest.java @@ -7,24 +7,19 @@ import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException; import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException; import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException; -import ca.uhn.fhir.util.TestUtil; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.IdType; import org.hl7.fhir.r4.model.Organization; import org.hl7.fhir.r4.model.Patient; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.IOException; - import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; public class FhirResourceDaoR4DeleteTest extends BaseJpaR4Test { @@ -128,7 +123,7 @@ public class FhirResourceDaoR4DeleteTest extends BaseJpaR4Test { .setUrl("Organization"); Bundle createResponse = mySystemDao.transaction(mySrd, createTransaction); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createResponse)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createResponse)); IdType orgId1 = new IdType(createResponse.getEntry().get(0).getResponse().getLocation()).toUnqualifiedVersionless(); IdType orgId2 = new IdType(createResponse.getEntry().get(1).getResponse().getLocation()).toUnqualifiedVersionless(); @@ -158,7 +153,7 @@ public class FhirResourceDaoR4DeleteTest extends BaseJpaR4Test { .getRequest() .setMethod(Bundle.HTTPVerb.DELETE) .setUrl(orgId2.getValue()); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(deleteTransaction)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(deleteTransaction)); mySystemDao.transaction(mySrd, deleteTransaction); // Make sure they were deleted diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4InterceptorTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4InterceptorTest.java index eba2178e567..587dcde48e2 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4InterceptorTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4InterceptorTest.java @@ -26,11 +26,11 @@ import org.mockito.stubbing.Answer; import java.util.ArrayList; import java.util.List; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.inOrder; @@ -249,7 +249,7 @@ public class FhirResourceDaoR4InterceptorTest extends BaseJpaR4Test { }).when(interceptor).resourceDeleted(any(), any()); DeleteMethodOutcome outcome = myPatientDao.deleteByUrl("Patient?name=PATIENT", mySrd); - String oo = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(outcome.getOperationOutcome()); + String oo = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(outcome.getOperationOutcome()); ourLog.info(oo); assertThat(oo, containsString("deleted 2 resource(s)")); @@ -368,7 +368,7 @@ public class FhirResourceDaoR4InterceptorTest extends BaseJpaR4Test { .setMethod(HTTPVerb.DELETE); Bundle resp = mySystemDao.transaction(mySrd, xactBundle); - String oo = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp); + String oo = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp); ourLog.info(oo); assertThat(oo, containsString("deleted 2 resource(s)")); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4LegacySearchBuilderTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4LegacySearchBuilderTest.java index 9e0ac937f0f..ead3915c91f 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4LegacySearchBuilderTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4LegacySearchBuilderTest.java @@ -234,7 +234,7 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { myConditionDao.create(condition); { String criteria = "_has:Condition:subject:onset-age=gt20"; - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Patient.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Patient.class)); map.setLoadSynchronous(true); @@ -245,7 +245,7 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { } { String criteria = "_has:Condition:subject:onset-age=lt20"; - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Patient.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Patient.class)); map.setLoadSynchronous(true); @@ -266,7 +266,7 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { myConditionDao.create(condition); String criteria = "_has:Condition:subject:code=http://snomed.info/sct|55822004"; - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Patient.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Patient.class)); map.setLoadSynchronous(true); @@ -287,7 +287,7 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { myConditionDao.create(condition); String criteria = "_has:Condition:subject:code=http://snomed.info/sct|55822003,http://snomed.info/sct|55822004"; - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Patient.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Patient.class)); map.setLoadSynchronous(true); @@ -314,7 +314,7 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { String criteria = "_has:Condition:subject:code=http://snomed.info/sct|55822003,http://snomed.info/sct|55822004&" + "_has:Condition:asserter:code=http://snomed.info/sct|55822003,http://snomed.info/sct|55822005"; - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Patient.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Patient.class)); map.setLoadSynchronous(true); @@ -341,7 +341,7 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { String criteria = "_has:Condition:subject:code=http://snomed.info/sct|55822003,http://snomed.info/sct|55822005&" + "_has:Condition:asserter:code=http://snomed.info/sct|55822003,http://snomed.info/sct|55822004"; - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Patient.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Patient.class)); map.setLoadSynchronous(true); @@ -363,7 +363,7 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { myConditionDao.create(condition); String criteria = "gender=male&birthdate=gt1950-07-01&birthdate=lt1960-07-01&_has:Condition:subject:code=http://snomed.info/sct|55822004"; - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Patient.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Patient.class)); map.setLoadSynchronous(true); @@ -384,7 +384,7 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { myConditionDao.create(condition); String criteria = "_has:Condition:asserter:code=http://snomed.info/sct|55822004"; - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Patient.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Patient.class)); map.setLoadSynchronous(true); @@ -954,10 +954,10 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { @Test @Disabled public void testEverythingWithLargeSet() throws Exception { - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); String inputString = IOUtils.toString(getClass().getResourceAsStream("/david_big_bundle.json"), StandardCharsets.UTF_8); - Bundle inputBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, inputString); + Bundle inputBundle = myFhirContext.newJsonParser().parseResource(Bundle.class, inputString); inputBundle.setType(BundleType.TRANSACTION); Set allIds = new TreeSet<>(); @@ -1058,7 +1058,7 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { myProvenanceDao.create(provenance); String criteria = "_has:Provenance:target:agent=" + deviceId.getValue(); - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Encounter.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Encounter.class)); map.setLoadSynchronous(true); @@ -1496,7 +1496,7 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { public void testIndexWithUtf8Chars() throws IOException { String input = IOUtils.toString(getClass().getResourceAsStream("/bug454_utf8.json"), StandardCharsets.UTF_8); - CodeSystem cs = (CodeSystem) myFhirCtx.newJsonParser().parseResource(input); + CodeSystem cs = (CodeSystem) myFhirContext.newJsonParser().parseResource(input); myCodeSystemDao.create(cs); } @@ -2679,7 +2679,7 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { { String criteria = "_tag:not=http://system|tag0"; - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Patient.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Patient.class)); map.setLoadSynchronous(true); @@ -2692,7 +2692,7 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { } { String criteria = "_tag:not=http://system|tag0,http://system|tag1"; - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Patient.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Patient.class)); map.setLoadSynchronous(true); @@ -2786,7 +2786,7 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { @Test public void testSearchOnCodesWithBelow() { - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); CodeSystem cs = new CodeSystem(); cs.setUrl("http://foo"); @@ -3517,7 +3517,7 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { String url = "Procedure?_count=300&_format=json&_include%3Arecurse=*&category=CANN&encounter.identifier=A1057852019&status%3Anot=entered-in-error"; - RuntimeResourceDefinition def = myFhirCtx.getResourceDefinition("Procedure"); + RuntimeResourceDefinition def = myFhirContext.getResourceDefinition("Procedure"); SearchParameterMap sp = myMatchUrlService.translateMatchUrl(url, def); @@ -4598,7 +4598,7 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { value = myDeviceDao.search(new SearchParameterMap()); if (value.size() > 0) { ourLog.info("Found: " + (value.getResources(0, 1).get(0).getIdElement())); - fail(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(value.getResources(0, 1).get(0))); + fail(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(value.getResources(0, 1).get(0))); } assertEquals(0, value.size().intValue()); @@ -4894,7 +4894,7 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { @Test public void testSearchWithUriParamBelow() throws Exception { - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); Class type = ValueSet.class; String resourceName = "/valueset-dstu2.json"; @@ -4991,7 +4991,7 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { sp.addExtension() .setUrl(HapiExtensions.EXT_SEARCHPARAM_TOKEN_SUPPRESS_TEXT_INDEXING) .setValue(new BooleanType(true)); - ourLog.info("SP:\n{}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(sp)); + ourLog.info("SP:\n{}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(sp)); mySearchParameterDao.update(sp); mySearchParamRegistry.forceRefresh(); } @@ -5232,11 +5232,11 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { // Matches Encounter e1 = new Encounter(); e1.setPeriod(new Period().setStartElement(new DateTimeType("2020-09-14T12:00:00Z")).setEndElement(new DateTimeType("2020-09-14T12:00:00Z"))); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e1)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e1)); String e1Id = myEncounterDao.create(e1).getId().toUnqualifiedVersionless().getValue(); Communication c1 = new Communication(); c1.getEncounter().setReference(e1Id); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(c1)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(c1)); String c1Id = myCommunicationDao.create(c1).getId().toUnqualifiedVersionless().getValue(); // Doesn't match (wrong date) diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4LuceneDisabledStandardQueries.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4LuceneDisabledStandardQueries.java index 709463c4fa8..1fe3d954cc4 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4LuceneDisabledStandardQueries.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4LuceneDisabledStandardQueries.java @@ -42,7 +42,7 @@ public class FhirResourceDaoR4LuceneDisabledStandardQueries extends BaseJpaTest } @Override - protected FhirContext getContext() { + protected FhirContext getFhirContext() { return myFhirCtx; } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4MetaTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4MetaTest.java index a58e93f417a..0b5bdb79535 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4MetaTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4MetaTest.java @@ -1,24 +1,19 @@ package ca.uhn.fhir.jpa.dao.r4; -import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome; -import ca.uhn.fhir.jpa.dao.BaseHapiFhirDao; -import ca.uhn.fhir.jpa.model.entity.TagDefinition; -import ca.uhn.fhir.jpa.model.entity.TagTypeEnum; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; -import ca.uhn.fhir.jpa.util.MemoryCacheService; +import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.param.TokenParam; -import org.apache.commons.lang3.tuple.Pair; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.InstantType; import org.hl7.fhir.r4.model.Meta; import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.StringType; -import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import java.util.ArrayList; import java.util.List; @@ -37,8 +32,17 @@ import static org.junit.jupiter.api.Assertions.fail; public class FhirResourceDaoR4MetaTest extends BaseJpaR4Test { private static final Logger ourLog = LoggerFactory.getLogger(FhirResourceDaoR4MetaTest.class); - @Autowired - private MemoryCacheService myMemoryCacheService; + + // TODO testConcurrentAddTag() can deadlock if we don't increase this + @BeforeAll + public static void beforeAll() { + System.setProperty("unlimited_db_connection", "true"); + } + + @AfterAll + public static void afterAll() { + System.clearProperty("unlimited_db_connection"); + } /** * See #1731 @@ -76,7 +80,7 @@ public class FhirResourceDaoR4MetaTest extends BaseJpaR4Test { IIdType id = myBundleDao.create(bundle).getId(); bundle = myBundleDao.read(id); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); patient = (Patient) bundle.getEntryFirstRep().getResource(); assertTrue(patient.getActive()); assertEquals(1, patient.getMeta().getExtensionsByUrl("http://foo").size()); @@ -143,18 +147,25 @@ public class FhirResourceDaoR4MetaTest extends BaseJpaR4Test { List> futures = new ArrayList<>(); for (int i = 0; i < 10; i++) { + final int index = i; Runnable task = () -> { Patient patient = new Patient(); patient.getMeta().addTag().setSystem("http://foo").setCode("bar"); patient.setActive(true); + ourLog.info("creating patient {}", index); myPatientDao.create(patient); }; - futures.add(pool.submit(task)); + ourLog.info("Submitting task {}...", index); + Future future = pool.submit(task); + ourLog.info("...done submitting task {}", index); + futures.add(future); } // Wait for the tasks to complete, should not throw any exception + int count = 0; for (Future next : futures) { try { + ourLog.info("Getting future {}", count); next.get(); } catch (Exception e) { ourLog.error("Failure", e); @@ -166,8 +177,10 @@ public class FhirResourceDaoR4MetaTest extends BaseJpaR4Test { ourLog.info("Tag definitions:\n * {}", myTagDefinitionDao.findAll().stream().map(t -> t.toString()).collect(Collectors.joining("\n * "))); }); - assertEquals(10, myPatientDao.search(SearchParameterMap.newSynchronous()).sizeOrThrowNpe()); - assertEquals(10, myPatientDao.search(SearchParameterMap.newSynchronous(PARAM_TAG, new TokenParam("http://foo", "bar"))).sizeOrThrowNpe()); + IBundleProvider bundle = myPatientDao.search(SearchParameterMap.newSynchronous()); + assertEquals(10, bundle.sizeOrThrowNpe()); + IBundleProvider tagBundle = myPatientDao.search(SearchParameterMap.newSynchronous(PARAM_TAG, new TokenParam("http://foo", "bar"))); + assertEquals(10, tagBundle.sizeOrThrowNpe()); } } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4QueryCountTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4QueryCountTest.java index be4c6f76ec3..1809df9f091 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4QueryCountTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4QueryCountTest.java @@ -61,7 +61,6 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Supplier; import java.util.stream.Collectors; -import static org.awaitility.Awaitility.await; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.containsString; @@ -85,7 +84,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myDaoConfig.setMassIngestionMode(new DaoConfig().isMassIngestionMode()); myModelConfig.setAutoVersionReferenceAtPaths(new ModelConfig().getAutoVersionReferenceAtPaths()); myModelConfig.setRespectVersionsForSearchIncludes(new ModelConfig().isRespectVersionsForSearchIncludes()); - myFhirCtx.getParserOptions().setStripVersionsFromReferences(true); + myFhirContext.getParserOptions().setStripVersionsFromReferences(true); myDaoConfig.setTagStorageMode(new DaoConfig().getTagStorageMode()); myDaoConfig.setAutoCreatePlaceholderReferenceTargets(new DaoConfig().isAutoCreatePlaceholderReferenceTargets()); myDaoConfig.setPopulateIdentifierInAutoCreatedPlaceholderReferenceTargets(new DaoConfig().isPopulateIdentifierInAutoCreatedPlaceholderReferenceTargets()); @@ -184,7 +183,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test cs.addConcept().setCode("bar-1").setDisplay("Bar 1"); cs.addConcept().setCode("bar-2").setDisplay("Bar 2"); myCodeSystemDao.create(cs); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(cs)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(cs)); Observation obs = new Observation(); // obs.getMeta().addProfile("http://example.com/fhir/StructureDefinition/vitalsigns-2"); @@ -196,7 +195,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test obs.setStatus(Observation.ObservationStatus.FINAL); obs.setValue(new StringType("This is the value")); obs.getCode().addCoding().setSystem("http://foo/cs").setCode("bar-1"); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); // Validate once myCaptureQueriesListener.clear(); @@ -977,7 +976,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test @Nonnull private Bundle createTransactionWithCreatesAndOneMatchUrl() { - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); Patient p = new Patient(); p.setId(IdType.newRandomUuid()); @@ -1050,7 +1049,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test @Test public void testTransactionWithTwoCreates() { - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); Patient pt = new Patient(); pt.setId(IdType.newRandomUuid()); @@ -1068,7 +1067,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); Bundle outcome = mySystemDao.transaction(mySrd, (Bundle) bb.getBundle()); - ourLog.info("Resp: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info("Resp: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); myCaptureQueriesListener.logSelectQueries(); assertEquals(0, myCaptureQueriesListener.countSelectQueries()); myCaptureQueriesListener.logInsertQueries(); @@ -1085,7 +1084,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test AtomicInteger counter = new AtomicInteger(0); Supplier input = () -> { - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); Patient pt = new Patient(); pt.setId("Patient/A"); @@ -1115,7 +1114,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); Bundle outcome = mySystemDao.transaction(mySrd, input.get()); - ourLog.info("Resp: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info("Resp: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); myCaptureQueriesListener.logSelectQueries(); assertEquals(1, myCaptureQueriesListener.countSelectQueries()); myCaptureQueriesListener.logInsertQueries(); @@ -1130,7 +1129,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); outcome = mySystemDao.transaction(mySrd, input.get()); - ourLog.info("Resp: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info("Resp: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); myCaptureQueriesListener.logSelectQueries(); assertEquals(10, myCaptureQueriesListener.countSelectQueries()); myCaptureQueriesListener.logInsertQueries(); @@ -1146,7 +1145,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); outcome = mySystemDao.transaction(mySrd, input.get()); - ourLog.info("Resp: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info("Resp: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); myCaptureQueriesListener.logSelectQueries(); assertEquals(7, myCaptureQueriesListener.countSelectQueries()); myCaptureQueriesListener.logInsertQueries(); @@ -1169,7 +1168,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test loc.addIdentifier().setSystem("http://foo").setValue("123"); myLocationDao.update(loc, mySrd); - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); for (int i = 0; i < 5; i++) { Encounter enc = new Encounter(); enc.addLocation().setLocation(new Reference("Location?identifier=http://foo|123")); @@ -1185,7 +1184,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test // Second identical pass - bb = new BundleBuilder(myFhirCtx); + bb = new BundleBuilder(myFhirContext); for (int i = 0; i < 5; i++) { Encounter enc = new Encounter(); enc.addLocation().setLocation(new Reference("Location?identifier=http://foo|123")); @@ -1213,7 +1212,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test loc.addIdentifier().setSystem("http://foo").setValue("123"); myLocationDao.update(loc, mySrd); - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); for (int i = 0; i < 5; i++) { Encounter enc = new Encounter(); enc.addLocation().setLocation(new Reference("Location?identifier=http://foo|123")); @@ -1232,7 +1231,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test // Second identical pass - bb = new BundleBuilder(myFhirCtx); + bb = new BundleBuilder(myFhirContext); for (int i = 0; i < 5; i++) { Encounter enc = new Encounter(); enc.addLocation().setLocation(new Reference("Location?identifier=http://foo|123")); @@ -1268,7 +1267,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myMemoryCacheService.invalidateAllCaches(); - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); for (int i = 0; i < 5; i++) { Encounter enc = new Encounter(); enc.setSubject(new Reference(pt.getId())); @@ -1285,7 +1284,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test // Second identical pass - bb = new BundleBuilder(myFhirCtx); + bb = new BundleBuilder(myFhirContext); for (int i = 0; i < 5; i++) { Encounter enc = new Encounter(); enc.setSubject(new Reference(pt.getId())); @@ -1320,7 +1319,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myMemoryCacheService.invalidateAllCaches(); - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); for (int i = 0; i < 5; i++) { Encounter enc = new Encounter(); enc.setSubject(new Reference(pt.getId())); @@ -1337,7 +1336,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test // Second identical pass - bb = new BundleBuilder(myFhirCtx); + bb = new BundleBuilder(myFhirContext); for (int i = 0; i < 5; i++) { Encounter enc = new Encounter(); enc.setSubject(new Reference(pt.getId())); @@ -1360,7 +1359,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test AtomicInteger counter = new AtomicInteger(0); Supplier input = () -> { - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); Patient pt = new Patient(); pt.setId(IdType.newRandomUuid()); @@ -1406,7 +1405,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); Bundle outcome = mySystemDao.transaction(mySrd, input.get()); - ourLog.info("Resp: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info("Resp: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); myCaptureQueriesListener.logSelectQueries(); assertEquals(1, myCaptureQueriesListener.countSelectQueries()); myCaptureQueriesListener.logInsertQueries(); @@ -1421,7 +1420,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); outcome = mySystemDao.transaction(mySrd, input.get()); - ourLog.info("Resp: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info("Resp: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); myCaptureQueriesListener.logSelectQueries(); assertEquals(11, myCaptureQueriesListener.countSelectQueries()); myCaptureQueriesListener.logInsertQueries(); @@ -1438,7 +1437,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); outcome = mySystemDao.transaction(mySrd, input.get()); - ourLog.info("Resp: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info("Resp: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); myCaptureQueriesListener.logSelectQueries(); assertEquals(6, myCaptureQueriesListener.countSelectQueries()); myCaptureQueriesListener.logInsertQueries(); @@ -1453,7 +1452,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); outcome = mySystemDao.transaction(mySrd, input.get()); - ourLog.info("Resp: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info("Resp: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); myCaptureQueriesListener.logSelectQueries(); assertEquals(5, myCaptureQueriesListener.countSelectQueries()); myCaptureQueriesListener.logInsertQueries(); @@ -1469,7 +1468,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myDaoConfig.setMatchUrlCacheEnabled(true); Supplier bundleCreator = () -> { - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); Patient pt = new Patient(); pt.setId(IdType.newRandomUuid()); @@ -1530,7 +1529,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test public void testTransactionWithConditionalCreate_MatchUrlCacheNotEnabled() { Supplier bundleCreator = () -> { - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); Patient pt = new Patient(); pt.setId(IdType.newRandomUuid()); @@ -1621,7 +1620,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); Bundle output = mySystemDao.transaction(mySrd, input); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); myCaptureQueriesListener.logSelectQueriesForCurrentThread(); assertEquals(1, myCaptureQueriesListener.countSelectQueriesForCurrentThread()); @@ -1657,7 +1656,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); output = mySystemDao.transaction(mySrd, input); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); myCaptureQueriesListener.logSelectQueriesForCurrentThread(); assertEquals(3, myCaptureQueriesListener.countSelectQueriesForCurrentThread()); @@ -1725,7 +1724,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); Bundle output = mySystemDao.transaction(mySrd, input); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); myCaptureQueriesListener.logSelectQueriesForCurrentThread(); assertEquals(0, myCaptureQueriesListener.countSelectQueriesForCurrentThread()); @@ -1780,7 +1779,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); Bundle output = mySystemDao.transaction(mySrd, input); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); // Lookup the two existing IDs to make sure they are legit myCaptureQueriesListener.logSelectQueriesForCurrentThread(); @@ -1818,7 +1817,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); output = mySystemDao.transaction(mySrd, input); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); // Lookup the two existing IDs to make sure they are legit myCaptureQueriesListener.logSelectQueriesForCurrentThread(); @@ -1868,7 +1867,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); Bundle output = mySystemDao.transaction(mySrd, input); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); // Lookup the two existing IDs to make sure they are legit myCaptureQueriesListener.logInsertQueriesForCurrentThread(); @@ -1907,7 +1906,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); output = mySystemDao.transaction(mySrd, input); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); // Lookup the two existing IDs to make sure they are legit myCaptureQueriesListener.logSelectQueriesForCurrentThread(); @@ -1960,7 +1959,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); Bundle output = mySystemDao.transaction(mySrd, input); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); // Lookup the two existing IDs to make sure they are legit myCaptureQueriesListener.logSelectQueriesForCurrentThread(); @@ -1998,7 +1997,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); output = mySystemDao.transaction(mySrd, input); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); // We do not need to resolve the target IDs a second time assertEquals(0, myCaptureQueriesListener.countSelectQueriesForCurrentThread()); @@ -2048,7 +2047,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); Bundle output = mySystemDao.transaction(mySrd, input); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); // Lookup the two existing IDs to make sure they are legit myCaptureQueriesListener.logSelectQueriesForCurrentThread(); @@ -2086,7 +2085,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); output = mySystemDao.transaction(mySrd, input); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); // We do not need to resolve the target IDs a second time myCaptureQueriesListener.logSelectQueriesForCurrentThread(); @@ -2161,7 +2160,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); Bundle output = mySystemDao.transaction(mySrd, input); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); // Lookup the two existing IDs to make sure they are legit myCaptureQueriesListener.logSelectQueriesForCurrentThread(); @@ -2220,7 +2219,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); output = mySystemDao.transaction(mySrd, input); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); // Lookup the two existing IDs to make sure they are legit myCaptureQueriesListener.logSelectQueriesForCurrentThread(); @@ -2299,7 +2298,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); ValueSet expansion = (ValueSet) myValidationSupport.expandValueSet(new ValidationSupportContext(myValidationSupport), new ValueSetExpansionOptions(), valueSet).getValueSet(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); assertEquals(7, expansion.getExpansion().getContains().size()); assertEquals(1, expansion.getExpansion().getContains().stream().filter(t->t.getCode().equals("A")).findFirst().orElseThrow(()->new IllegalArgumentException()).getDesignation().size()); myCaptureQueriesListener.logSelectQueriesForCurrentThread(); @@ -2313,7 +2312,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test // Second time - Should reuse cache myCaptureQueriesListener.clear(); expansion = (ValueSet) myValidationSupport.expandValueSet(new ValidationSupportContext(myValidationSupport), new ValueSetExpansionOptions(), valueSet).getValueSet(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); assertEquals(7, expansion.getExpansion().getContains().size()); assertEquals(1, expansion.getExpansion().getContains().stream().filter(t->t.getCode().equals("A")).findFirst().orElseThrow(()->new IllegalArgumentException()).getDesignation().size()); myCaptureQueriesListener.logSelectQueriesForCurrentThread(); @@ -2339,7 +2338,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); ValueSet expansion = (ValueSet) myValidationSupport.expandValueSet(new ValidationSupportContext(myValidationSupport), new ValueSetExpansionOptions(), valueSet).getValueSet(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); assertEquals(7, expansion.getExpansion().getContains().size()); assertEquals(1, expansion.getExpansion().getContains().stream().filter(t->t.getCode().equals("A")).findFirst().orElseThrow(()->new IllegalArgumentException()).getDesignation().size()); myCaptureQueriesListener.logSelectQueriesForCurrentThread(); @@ -2353,7 +2352,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test // Second time - Should reuse cache myCaptureQueriesListener.clear(); expansion = (ValueSet) myValidationSupport.expandValueSet(new ValidationSupportContext(myValidationSupport), new ValueSetExpansionOptions(), valueSet).getValueSet(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); assertEquals(7, expansion.getExpansion().getContains().size()); assertEquals(1, expansion.getExpansion().getContains().stream().filter(t->t.getCode().equals("A")).findFirst().orElseThrow(()->new IllegalArgumentException()).getDesignation().size()); myCaptureQueriesListener.logSelectQueriesForCurrentThread(); @@ -2383,7 +2382,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myCaptureQueriesListener.clear(); ValueSet expansion = (ValueSet) myValidationSupport.expandValueSet(new ValidationSupportContext(myValidationSupport), new ValueSetExpansionOptions(), valueSet).getValueSet(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); assertEquals(7, expansion.getExpansion().getContains().size()); assertEquals(1, expansion.getExpansion().getContains().stream().filter(t->t.getCode().equals("A")).findFirst().orElseThrow(()->new IllegalArgumentException()).getDesignation().size()); myCaptureQueriesListener.logSelectQueriesForCurrentThread(); @@ -2397,7 +2396,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test // Second time - Should reuse cache myCaptureQueriesListener.clear(); expansion = (ValueSet) myValidationSupport.expandValueSet(new ValidationSupportContext(myValidationSupport), new ValueSetExpansionOptions(), valueSet).getValueSet(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); assertEquals(7, expansion.getExpansion().getContains().size()); assertEquals(1, expansion.getExpansion().getContains().stream().filter(t->t.getCode().equals("A")).findFirst().orElseThrow(()->new IllegalArgumentException()).getDesignation().size()); myCaptureQueriesListener.logSelectQueriesForCurrentThread(); @@ -2414,7 +2413,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myDaoConfig.setDeleteEnabled(false); myDaoConfig.setMatchUrlCacheEnabled(true); myDaoConfig.setMassIngestionMode(true); - myFhirCtx.getParserOptions().setStripVersionsFromReferences(false); + myFhirContext.getParserOptions().setStripVersionsFromReferences(false); myModelConfig.setRespectVersionsForSearchIncludes(true); myModelConfig.setAutoVersionReferenceAtPaths( "ExplanationOfBenefit.patient", @@ -2428,7 +2427,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test AtomicInteger ai = new AtomicInteger(0); Supplier supplier = () -> { - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); Coverage coverage = new Coverage(); coverage.getMeta().addProfile("http://foo"); @@ -2478,7 +2477,7 @@ public class FhirResourceDaoR4QueryCountTest extends BaseResourceProviderR4Test myDaoConfig.setDeleteEnabled(false); myDaoConfig.setMatchUrlCacheEnabled(true); myDaoConfig.setMassIngestionMode(true); - myFhirCtx.getParserOptions().setStripVersionsFromReferences(false); + myFhirContext.getParserOptions().setStripVersionsFromReferences(false); myModelConfig.setRespectVersionsForSearchIncludes(true); myDaoConfig.setTagStorageMode(DaoConfig.TagStorageModeEnum.NON_VERSIONED); myModelConfig.setAutoVersionReferenceAtPaths( diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchCustomSearchParamTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchCustomSearchParamTest.java index aa3334932fb..0561da7a1bc 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchCustomSearchParamTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchCustomSearchParamTest.java @@ -1,8 +1,8 @@ package ca.uhn.fhir.jpa.dao.r4; import ca.uhn.fhir.context.RuntimeSearchParam; -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.phonetic.PhoneticEncoderEnum; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.interceptor.api.HookParams; import ca.uhn.fhir.interceptor.api.IAnonymousInterceptor; import ca.uhn.fhir.interceptor.api.Pointcut; @@ -12,7 +12,6 @@ import ca.uhn.fhir.jpa.model.entity.NormalizedQuantitySearchLevel; import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamToken; import ca.uhn.fhir.jpa.model.search.StorageProcessingMessage; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; -import ca.uhn.fhir.model.api.IQueryParameterType; import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.param.DateParam; @@ -57,7 +56,6 @@ import org.hl7.fhir.r4.model.ServiceRequest; import org.hl7.fhir.r4.model.Specimen; import org.hl7.fhir.r4.model.StringType; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -290,7 +288,7 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test fooSp.setXpathUsage(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL); fooSp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(fooSp)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(fooSp)); mySearchParameterDao.create(fooSp, mySrd); mySearchParamRegistry.forceRefresh(); @@ -306,7 +304,7 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test bundle.setType(Bundle.BundleType.DOCUMENT); bundle.addEntry().setResource(composition); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); String bundleId = myBundleDao.create(bundle).getId().toUnqualifiedVersionless().getValue(); SearchParameterMap map; @@ -475,7 +473,7 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test pract.addName().setFamily("PRACT"); myPractitionerDao.update(pract); - Patient pat = myFhirCtx.newJsonParser().parseResource(Patient.class, loadClasspath("/r4/custom_resource_patient.json")); + Patient pat = myFhirContext.newJsonParser().parseResource(Patient.class, loadClasspath("/r4/custom_resource_patient.json")); IIdType pid = myPatientDao.create(pat, mySrd).getId().toUnqualifiedVersionless(); SearchParameterMap params = new SearchParameterMap(); @@ -499,7 +497,7 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test sp.setExpression("Bundle.entry.resource.as(MessageHeader).id"); sp.setXpathUsage(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL); sp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(sp)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(sp)); mySearchParameterDao.create(sp); mySearchParamRegistry.forceRefresh(); @@ -512,7 +510,7 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test bundle.addEntry() .setResource(messageHeader); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); myBundleDao.create(bundle); SearchParameterMap params = new SearchParameterMap(); @@ -1481,7 +1479,7 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test sp.setExpression("Observation.specimen.resolve().receivedTime"); sp.setXpathUsage(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL); sp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(sp)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(sp)); mySearchParameterDao.create(sp); mySearchParamRegistry.forceRefresh(); @@ -1494,7 +1492,7 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test o.getContained().add(specimen); o.setStatus(Observation.ObservationStatus.FINAL); o.setSpecimen(new Reference("#FOO")); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(o)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(o)); myObservationDao.update(o); specimen = new Specimen(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchDistanceTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchDistanceTest.java index d4a4341dffb..d1169b0df8f 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchDistanceTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchDistanceTest.java @@ -11,8 +11,8 @@ import org.springframework.beans.factory.annotation.Autowired; import java.util.List; import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.Matchers.contains; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.contains; public class FhirResourceDaoR4SearchDistanceTest extends BaseJpaR4Test { @BeforeEach @@ -35,7 +35,7 @@ public class FhirResourceDaoR4SearchDistanceTest extends BaseJpaR4Test { SearchParameterMap map = myMatchUrlService.translateMatchUrl( "Location?" + Location.SP_NEAR + "=" + latitude + "|" + longitude, - myFhirCtx.getResourceDefinition("Location")); + myFhirContext.getResourceDefinition("Location")); List ids = toUnqualifiedVersionlessIdValues(myLocationDao.search(map)); assertThat(ids, contains(locId)); @@ -53,7 +53,7 @@ public class FhirResourceDaoR4SearchDistanceTest extends BaseJpaR4Test { SearchParameterMap map = myMatchUrlService.translateMatchUrl( "Location?" + Location.SP_NEAR + "=" + latitude + "|" + longitude + "|0", - myFhirCtx.getResourceDefinition("Location")); + myFhirContext.getResourceDefinition("Location")); List ids = toUnqualifiedVersionlessIdValues(myLocationDao.search(map)); assertThat(ids, contains(locId)); @@ -62,7 +62,7 @@ public class FhirResourceDaoR4SearchDistanceTest extends BaseJpaR4Test { SearchParameterMap map = myMatchUrlService.translateMatchUrl( "Location?" + Location.SP_NEAR + "=" + latitude + "|" + longitude + "|0.0", - myFhirCtx.getResourceDefinition("Location")); + myFhirContext.getResourceDefinition("Location")); List ids = toUnqualifiedVersionlessIdValues(myLocationDao.search(map)); assertThat(ids, contains(locId)); @@ -84,7 +84,7 @@ public class FhirResourceDaoR4SearchDistanceTest extends BaseJpaR4Test { "Location?" + Location.SP_NEAR + "=" + CoordCalculatorTest.LATITUDE_CHIN + "|" + CoordCalculatorTest.LONGITUDE_CHIN + "|" + - bigEnoughDistance, myFhirCtx.getResourceDefinition("Location")); + bigEnoughDistance, myFhirContext.getResourceDefinition("Location")); List ids = toUnqualifiedVersionlessIdValues(myLocationDao.search(map)); assertThat(ids, contains(locId)); @@ -96,7 +96,7 @@ public class FhirResourceDaoR4SearchDistanceTest extends BaseJpaR4Test { "Location?" + Location.SP_NEAR + "=" + CoordCalculatorTest.LATITUDE_CHIN + "|" + CoordCalculatorTest.LONGITUDE_CHIN + "|" + - tooSmallDistance, myFhirCtx.getResourceDefinition("Location")); + tooSmallDistance, myFhirContext.getResourceDefinition("Location")); List ids = toUnqualifiedVersionlessIdValues(myLocationDao.search(map)); assertThat(ids.size(), is(0)); @@ -119,7 +119,7 @@ public class FhirResourceDaoR4SearchDistanceTest extends BaseJpaR4Test { "Location?" + Location.SP_NEAR + "=" + CoordCalculatorTest.LATITUDE_TAVEUNI + "|" + CoordCalculatorTest.LONGITIDE_TAVEUNI + "|" + - bigEnoughDistance, myFhirCtx.getResourceDefinition("Location")); + bigEnoughDistance, myFhirContext.getResourceDefinition("Location")); List ids = toUnqualifiedVersionlessIdValues(myLocationDao.search(map)); assertThat(ids, contains(locId)); @@ -130,7 +130,7 @@ public class FhirResourceDaoR4SearchDistanceTest extends BaseJpaR4Test { "Location?" + Location.SP_NEAR + "=" + CoordCalculatorTest.LATITUDE_CHIN + "|" + CoordCalculatorTest.LONGITUDE_CHIN + "|" + - tooSmallDistance, myFhirCtx.getResourceDefinition("Location")); + tooSmallDistance, myFhirContext.getResourceDefinition("Location")); List ids = toUnqualifiedVersionlessIdValues(myLocationDao.search(map)); assertThat(ids.size(), is(0)); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchNoFtTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchNoFtTest.java index 17d462cf291..6b43abbf19d 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchNoFtTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchNoFtTest.java @@ -296,7 +296,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { myConditionDao.create(condition); { String criteria = "_has:Condition:subject:onset-age=gt20"; - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Patient.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Patient.class)); map.setLoadSynchronous(true); @@ -307,7 +307,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { } { String criteria = "_has:Condition:subject:onset-age=lt20"; - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Patient.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Patient.class)); map.setLoadSynchronous(true); @@ -328,7 +328,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { myConditionDao.create(condition); String criteria = "_has:Condition:subject:code=http://snomed.info/sct|55822004"; - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Patient.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Patient.class)); map.setLoadSynchronous(true); @@ -349,7 +349,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { myConditionDao.create(condition); String criteria = "_has:Condition:subject:code=http://snomed.info/sct|55822003,http://snomed.info/sct|55822004"; - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Patient.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Patient.class)); map.setLoadSynchronous(true); @@ -376,7 +376,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { String criteria = "_has:Condition:subject:code=http://snomed.info/sct|55822003,http://snomed.info/sct|55822004&" + "_has:Condition:asserter:code=http://snomed.info/sct|55822003,http://snomed.info/sct|55822005"; - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Patient.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Patient.class)); map.setLoadSynchronous(true); @@ -403,7 +403,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { String criteria = "_has:Condition:subject:code=http://snomed.info/sct|55822003,http://snomed.info/sct|55822005&" + "_has:Condition:asserter:code=http://snomed.info/sct|55822003,http://snomed.info/sct|55822004"; - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Patient.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Patient.class)); map.setLoadSynchronous(true); @@ -425,7 +425,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { myConditionDao.create(condition); String criteria = "gender=male&birthdate=gt1950-07-01&birthdate=lt1960-07-01&_has:Condition:subject:code=http://snomed.info/sct|55822004"; - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Patient.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Patient.class)); map.setLoadSynchronous(true); @@ -446,7 +446,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { myConditionDao.create(condition); String criteria = "_has:Condition:asserter:code=http://snomed.info/sct|55822004"; - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Patient.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Patient.class)); map.setLoadSynchronous(true); @@ -675,7 +675,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { ourLog.info("Resources:\n * {}", myResourceTableDao.findAll().stream().map(t -> t.toString()).collect(Collectors.joining("\n * "))); }); - RuntimeResourceDefinition resDef = myFhirCtx.getResourceDefinition("DiagnosticReport"); + RuntimeResourceDefinition resDef = myFhirContext.getResourceDefinition("DiagnosticReport"); map = myMatchUrlService.translateMatchUrl("Organization?_lastUpdated=gt" + yesterday + "&_lastUpdated=lt" + tomorrow, resDef); map.setLoadSynchronous(true); myCaptureQueriesListener.clear(); @@ -863,10 +863,10 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { @Disabled @Test public void testEverythingWithLargeSet() throws Exception { - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); String inputString = IOUtils.toString(getClass().getResourceAsStream("/david_big_bundle.json"), StandardCharsets.UTF_8); - Bundle inputBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, inputString); + Bundle inputBundle = myFhirContext.newJsonParser().parseResource(Bundle.class, inputString); inputBundle.setType(BundleType.TRANSACTION); Set allIds = new TreeSet<>(); @@ -967,7 +967,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { myProvenanceDao.create(provenance); String criteria = "_has:Provenance:target:agent=" + deviceId.getValue(); - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Encounter.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Encounter.class)); map.setLoadSynchronous(true); @@ -1425,11 +1425,11 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { @DisplayName("Duplicate Conditional Creates all resolve to the same match") public void testDuplicateConditionalCreatesOnToken() throws IOException { String inputString = IOUtils.toString(getClass().getResourceAsStream("/duplicate-conditional-create.json"), StandardCharsets.UTF_8); - Bundle firstBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, inputString); + Bundle firstBundle = myFhirContext.newJsonParser().parseResource(Bundle.class, inputString); //Before you ask, yes, this has to be separately parsed. The reason for this is that the parameters passed to mySystemDao.transaction are _not_ immutable, so we cannot //simply reuse the original bundle object. - Bundle duplicateBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, inputString); + Bundle duplicateBundle = myFhirContext.newJsonParser().parseResource(Bundle.class, inputString); Bundle bundleResponse = mySystemDao.transaction(new SystemRequestDetails(), firstBundle); bundleResponse.getEntry() @@ -1504,7 +1504,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { public void testIndexWithUtf8Chars() throws IOException { String input = IOUtils.toString(getClass().getResourceAsStream("/bug454_utf8.json"), StandardCharsets.UTF_8); - CodeSystem cs = (CodeSystem) myFhirCtx.newJsonParser().parseResource(input); + CodeSystem cs = (CodeSystem) myFhirContext.newJsonParser().parseResource(input); myCodeSystemDao.create(cs); } @@ -2862,7 +2862,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { { String criteria = "_tag:not=http://system|tag0"; - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Patient.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Patient.class)); map.setLoadSynchronous(true); @@ -2875,7 +2875,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { } { String criteria = "_tag:not=http://system|tag0,http://system|tag1"; - SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Patient.class)); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(criteria, myFhirContext.getResourceDefinition(Patient.class)); map.setLoadSynchronous(true); @@ -2968,7 +2968,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { @Test public void testSearchOnCodesWithBelow() { - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); CodeSystem cs = new CodeSystem(); cs.setUrl("http://foo"); @@ -3719,7 +3719,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { String url = "Procedure?_count=300&_format=json&_include%3Arecurse=*&category=CANN&encounter.identifier=A1057852019&status%3Anot=entered-in-error"; - RuntimeResourceDefinition def = myFhirCtx.getResourceDefinition("Procedure"); + RuntimeResourceDefinition def = myFhirContext.getResourceDefinition("Procedure"); SearchParameterMap sp = myMatchUrlService.translateMatchUrl(url, def); @@ -4805,7 +4805,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { value = myDeviceDao.search(new SearchParameterMap()); if (value.size() > 0) { ourLog.info("Found: " + (value.getResources(0, 1).get(0).getIdElement())); - fail(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(value.getResources(0, 1).get(0))); + fail(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(value.getResources(0, 1).get(0))); } assertEquals(0, value.size().intValue()); @@ -5101,7 +5101,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { @Test public void testSearchWithUriParamBelow() throws Exception { - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); Class type = ValueSet.class; String resourceName = "/valueset-dstu2.json"; @@ -5260,7 +5260,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { sp.addExtension() .setUrl(HapiExtensions.EXT_SEARCHPARAM_TOKEN_SUPPRESS_TEXT_INDEXING) .setValue(new BooleanType(true)); - ourLog.info("SP:\n{}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(sp)); + ourLog.info("SP:\n{}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(sp)); mySearchParameterDao.update(sp); mySearchParamRegistry.forceRefresh(); } @@ -5494,11 +5494,11 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { // Matches Encounter e1 = new Encounter(); e1.setPeriod(new Period().setStartElement(new DateTimeType("2020-09-14T12:00:00Z")).setEndElement(new DateTimeType("2020-09-14T12:00:00Z"))); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e1)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e1)); String e1Id = myEncounterDao.create(e1).getId().toUnqualifiedVersionless().getValue(); Communication c1 = new Communication(); c1.getEncounter().setReference(e1Id); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(c1)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(c1)); String c1Id = myCommunicationDao.create(c1).getId().toUnqualifiedVersionless().getValue(); // Doesn't match (wrong date) diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchNoHashesTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchNoHashesTest.java index e479dbcccc8..4017f6bc12a 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchNoHashesTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchNoHashesTest.java @@ -396,10 +396,10 @@ public class FhirResourceDaoR4SearchNoHashesTest extends BaseJpaR4Test { @Test @Disabled public void testEverythingWithLargeSet() throws Exception { - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); String inputString = IOUtils.toString(getClass().getResourceAsStream("/david_big_bundle.json"), StandardCharsets.UTF_8); - Bundle inputBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, inputString); + Bundle inputBundle = myFhirContext.newJsonParser().parseResource(Bundle.class, inputString); inputBundle.setType(BundleType.TRANSACTION); Set allIds = new TreeSet<>(); @@ -886,7 +886,7 @@ public class FhirResourceDaoR4SearchNoHashesTest extends BaseJpaR4Test { public void testIndexWithUtf8Chars() throws IOException { String input = IOUtils.toString(getClass().getResourceAsStream("/bug454_utf8.json"), StandardCharsets.UTF_8); - CodeSystem cs = (CodeSystem) myFhirCtx.newJsonParser().parseResource(input); + CodeSystem cs = (CodeSystem) myFhirContext.newJsonParser().parseResource(input); myCodeSystemDao.create(cs); } @@ -2961,7 +2961,7 @@ public class FhirResourceDaoR4SearchNoHashesTest extends BaseJpaR4Test { value = myDeviceDao.search(new SearchParameterMap()); if (value.size() > 0) { ourLog.info("Found: " + (value.getResources(0, 1).get(0).getIdElement())); - fail(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(value.getResources(0, 1).get(0))); + fail(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(value.getResources(0, 1).get(0))); } assertEquals(0, value.size().intValue()); @@ -3253,7 +3253,7 @@ public class FhirResourceDaoR4SearchNoHashesTest extends BaseJpaR4Test { @Test public void testSearchWithUriParamBelow() throws Exception { - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); Class type = ValueSet.class; String resourceName = "/valueset-dstu2.json"; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchOptimizedTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchOptimizedTest.java index e863d2327c6..68635efa24b 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchOptimizedTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchOptimizedTest.java @@ -802,7 +802,7 @@ public class FhirResourceDaoR4SearchOptimizedTest extends BaseJpaR4Test { public void testChainedSearchUsesJoinNotSubselect() { myCaptureQueriesListener.clear(); - RuntimeResourceDefinition resourceDef = myFhirCtx.getResourceDefinition("Observation"); + RuntimeResourceDefinition resourceDef = myFhirContext.getResourceDefinition("Observation"); SearchParameterMap params = myMatchUrlService.translateMatchUrl("/Observation?subject:patient.identifier=urn:oid:ZOOP.MRN.OID|1234", resourceDef, null); params.setLoadSynchronous(true); myObservationDao.search(params); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchSqlTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchSqlTest.java index c5b72ace4ce..1836d982d61 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchSqlTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchSqlTest.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.dao.r4; import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.jpa.dao.BaseJpaTest; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.server.IBundleProvider; @@ -17,7 +16,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.test.context.TestPropertySource; import java.util.UUID; @@ -107,7 +105,7 @@ public class FhirResourceDaoR4SearchSqlTest extends BaseJpaR4Test { myDaoConfig.setTagStorageMode(DaoConfig.TagStorageModeEnum.INLINE); SearchParameter searchParameter = FhirResourceDaoR4TagsTest.createSearchParamForInlineResourceProfile(); - ourLog.info("SearchParam:\n{}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(searchParameter)); + ourLog.info("SearchParam:\n{}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(searchParameter)); mySearchParameterDao.update(searchParameter, mySrd); mySearchParamRegistry.forceRefresh(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithElasticSearchIT.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithElasticSearchIT.java index e894bb17d13..9ed51354ce3 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithElasticSearchIT.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithElasticSearchIT.java @@ -139,7 +139,7 @@ public class FhirResourceDaoR4SearchWithElasticSearchIT extends BaseJpaTest { } @Override - protected FhirContext getContext() { + protected FhirContext getFhirContext() { return myFhirCtx; } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithLuceneDisabledTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithLuceneDisabledTest.java index 4d841064146..2aac22a2ddd 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithLuceneDisabledTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithLuceneDisabledTest.java @@ -16,10 +16,9 @@ import ca.uhn.fhir.jpa.dao.BaseJpaTest; import ca.uhn.fhir.jpa.dao.dstu2.FhirResourceDaoDstu2SearchNoFtTest; import ca.uhn.fhir.jpa.search.reindex.IResourceReindexingSvc; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; -import ca.uhn.fhir.jpa.util.ValueSetTestUtil; -import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import ca.uhn.fhir.jpa.sp.ISearchParamPresenceSvc; import ca.uhn.fhir.jpa.term.api.ITermReadSvc; +import ca.uhn.fhir.jpa.util.ValueSetTestUtil; import ca.uhn.fhir.parser.IParser; import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.api.server.IBundleProvider; @@ -27,6 +26,7 @@ import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.rest.param.TokenParamModifier; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; +import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import org.apache.commons.io.IOUtils; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; @@ -160,7 +160,7 @@ public class FhirResourceDaoR4SearchWithLuceneDisabledTest extends BaseJpaTest { } @Override - protected FhirContext getContext() { + protected FhirContext getFhirContext() { return myFhirCtx; } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4StructureDefinitionTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4StructureDefinitionTest.java index 4fbec4009ee..53bdc7c4cfb 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4StructureDefinitionTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4StructureDefinitionTest.java @@ -1,13 +1,11 @@ package ca.uhn.fhir.jpa.dao.r4; -import ca.uhn.fhir.context.support.ValidationSupportContext; -import ca.uhn.fhir.util.TestUtil; import ca.uhn.fhir.context.support.DefaultProfileValidationSupport; +import ca.uhn.fhir.context.support.ValidationSupportContext; import org.hl7.fhir.common.hapi.validation.support.SnapshotGeneratingValidationSupport; import org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain; import org.hl7.fhir.r4.model.StructureDefinition; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -31,8 +29,8 @@ public class FhirResourceDaoR4StructureDefinitionTest extends BaseJpaR4Test { // Create a validation chain that includes default validation support and a // snapshot generator - DefaultProfileValidationSupport defaultSupport = new DefaultProfileValidationSupport(myFhirCtx); - SnapshotGeneratingValidationSupport snapshotGenerator = new SnapshotGeneratingValidationSupport(myFhirCtx); + DefaultProfileValidationSupport defaultSupport = new DefaultProfileValidationSupport(myFhirContext); + SnapshotGeneratingValidationSupport snapshotGenerator = new SnapshotGeneratingValidationSupport(myFhirContext); ValidationSupportChain chain = new ValidationSupportChain(defaultSupport, snapshotGenerator); // Generate the snapshot @@ -42,7 +40,7 @@ public class FhirResourceDaoR4StructureDefinitionTest extends BaseJpaR4Test { String webUrl = null; String name = "Foo Profile"; StructureDefinition output = myStructureDefinitionDao.generateSnapshot(differential, url, webUrl, name); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); assertEquals(54, output.getSnapshot().getElement().size()); } @@ -61,7 +59,7 @@ public class FhirResourceDaoR4StructureDefinitionTest extends BaseJpaR4Test { myStructureDefinitionDao.update(sd2); StructureDefinition snapshotted = myStructureDefinitionDao.generateSnapshot(sd2, null, null, null); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(snapshotted)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(snapshotted)); assertTrue(snapshotted.getSnapshot().getElement().size() > 0); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TagsTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TagsTest.java index 033f340e44b..4c3bd92d10a 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TagsTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TagsTest.java @@ -1,13 +1,11 @@ package ca.uhn.fhir.jpa.dao.r4; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.provider.r4.BaseResourceProviderR4Test; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.gclient.TokenClientParam; -import ca.uhn.fhir.rest.param.TokenParam; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.Enumerations; import org.hl7.fhir.r4.model.IdType; @@ -213,7 +211,7 @@ public class FhirResourceDaoR4TagsTest extends BaseResourceProviderR4Test { myDaoConfig.setTagStorageMode(DaoConfig.TagStorageModeEnum.INLINE); SearchParameter searchParameter = createResourceTagSearchParameter(); - ourLog.info("SearchParam:\n{}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(searchParameter)); + ourLog.info("SearchParam:\n{}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(searchParameter)); mySearchParameterDao.update(searchParameter, mySrd); mySearchParamRegistry.forceRefresh(); @@ -233,7 +231,7 @@ public class FhirResourceDaoR4TagsTest extends BaseResourceProviderR4Test { myDaoConfig.setTagStorageMode(DaoConfig.TagStorageModeEnum.INLINE); SearchParameter searchParameter = createSearchParamForInlineResourceProfile(); - ourLog.info("SearchParam:\n{}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(searchParameter)); + ourLog.info("SearchParam:\n{}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(searchParameter)); mySearchParameterDao.update(searchParameter, mySrd); mySearchParamRegistry.forceRefresh(); @@ -253,7 +251,7 @@ public class FhirResourceDaoR4TagsTest extends BaseResourceProviderR4Test { SearchParameter searchParameter = new SearchParameter(); searchParameter.setId("SearchParameter/resource-security"); - for (String next : myFhirCtx.getResourceTypes().stream().sorted().collect(Collectors.toList())) { + for (String next : myFhirContext.getResourceTypes().stream().sorted().collect(Collectors.toList())) { searchParameter.addBase(next); } searchParameter.setStatus(Enumerations.PublicationStatus.ACTIVE); @@ -261,7 +259,7 @@ public class FhirResourceDaoR4TagsTest extends BaseResourceProviderR4Test { searchParameter.setCode("_security"); searchParameter.setName("Security"); searchParameter.setExpression("meta.security"); - ourLog.info("SearchParam:\n{}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(searchParameter)); + ourLog.info("SearchParam:\n{}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(searchParameter)); mySearchParameterDao.update(searchParameter, mySrd); mySearchParamRegistry.forceRefresh(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyElasticsearchIT.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyElasticsearchIT.java index 9a8e4daa00b..412cc94cd58 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyElasticsearchIT.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyElasticsearchIT.java @@ -147,7 +147,7 @@ public class FhirResourceDaoR4TerminologyElasticsearchIT extends BaseJpaTest { @Override - protected FhirContext getContext() { + protected FhirContext getFhirContext() { return myFhirContext; } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyTest.java index f064888489f..f4b19fff1df 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyTest.java @@ -195,11 +195,11 @@ public class FhirResourceDaoR4TerminologyTest extends BaseJpaR4Test { } private void logAndValidateValueSet(ValueSet theResult) { - IParser parser = myFhirCtx.newXmlParser().setPrettyPrint(true); + IParser parser = myFhirContext.newXmlParser().setPrettyPrint(true); String encoded = parser.encodeResourceToString(theResult); ourLog.info(encoded); - FhirValidator validator = myFhirCtx.newValidator(); + FhirValidator validator = myFhirContext.newValidator(); validator.setValidateAgainstStandardSchema(true); validator.setValidateAgainstStandardSchematron(true); ValidationResult result = validator.validateWithResult(theResult); @@ -637,7 +637,7 @@ public class FhirResourceDaoR4TerminologyTest extends BaseJpaR4Test { ValueSet result = myValueSetDao.expandByIdentifier("http://hl7.org/fhir/ValueSet/doc-typecodes", new ValueSetExpansionOptions().setFilter("")); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(result)); } @Test @@ -817,7 +817,7 @@ public class FhirResourceDaoR4TerminologyTest extends BaseJpaR4Test { assertEquals(4, result.getExpansion().getContains().size()); - String encoded = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result); + String encoded = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(result); assertThat(encoded, containsStringIgnoringCase("")); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4Test.java index 1f93a943d26..3575f6f19fd 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4Test.java @@ -46,7 +46,6 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; -import ca.uhn.fhir.test.utilities.BatchJobHelper; import com.google.common.base.Charsets; import com.google.common.collect.Lists; import org.apache.commons.io.IOUtils; @@ -111,7 +110,6 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.support.TransactionCallbackWithoutResult; @@ -320,7 +318,7 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test { patient = myPatientDao.read(id); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); assertEquals(2, patient.getContained().size()); @@ -839,11 +837,11 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test { String vsContents; vsContents = IOUtils.toString(FhirResourceDaoR4Test.class.getResourceAsStream("/org/hl7/fhir/r4/model/profile/" + name + ".xml"), "UTF-8"); - bundle = myFhirCtx.newXmlParser().parseResource(org.hl7.fhir.r4.model.Bundle.class, vsContents); + bundle = myFhirContext.newXmlParser().parseResource(org.hl7.fhir.r4.model.Bundle.class, vsContents); for (BundleEntryComponent i : bundle.getEntry()) { org.hl7.fhir.r4.model.Resource next = i.getResource(); - ourLog.debug(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(next)); + ourLog.debug(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(next)); if (next instanceof StructureDefinition) { myStructureDefinitionDao.update((StructureDefinition) next, mySrd); } else if (next instanceof CompartmentDefinition) { @@ -990,7 +988,7 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test { " \n" + " "; - NamingSystem res = myFhirCtx.newXmlParser().parseResource(NamingSystem.class, input); + NamingSystem res = myFhirContext.newXmlParser().parseResource(NamingSystem.class, input); IIdType id = myNamingSystemDao.create(res, mySrd).getId().toUnqualifiedVersionless(); SearchParameterMap params = new SearchParameterMap(NamingSystem.SP_NAME, new StringParam("NDF")).setLoadSynchronous(true); @@ -1032,7 +1030,7 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test { @Test public void testCreateOperationOutcomeError() { JpaResourceDao dao = new JpaResourceDao(); - dao.setContext(myFhirCtx); + dao.setContext(myFhirContext); OperationOutcome oo = (OperationOutcome) dao.createErrorOperationOutcome("my message", "incomplete"); assertEquals(IssueSeverity.ERROR.toCode(), oo.getIssue().get(0).getSeverity().toCode()); assertEquals("my message", oo.getIssue().get(0).getDiagnostics()); @@ -1042,7 +1040,7 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test { @Test public void testCreateOperationOutcomeInfo() { JpaResourceDao dao = new JpaResourceDao(); - dao.setContext(myFhirCtx); + dao.setContext(myFhirContext); OperationOutcome oo = (OperationOutcome) dao.createInfoOperationOutcome("my message"); assertEquals(IssueSeverity.INFORMATION.toCode(), oo.getIssue().get(0).getSeverity().toCode()); assertEquals("my message", oo.getIssue().get(0).getDiagnostics()); @@ -2486,7 +2484,7 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test { Set val = myOrganizationDao.searchForIds(new SearchParameterMap("name", new StringParam("P")), null); int initial = val.size(); - Organization org = myFhirCtx.newJsonParser().parseResource(Organization.class, inputStr); + Organization org = myFhirContext.newJsonParser().parseResource(Organization.class, inputStr); myOrganizationDao.create(org, mySrd); val = myOrganizationDao.searchForIds(new SearchParameterMap("name", new StringParam("P")), null); @@ -2910,7 +2908,7 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test { @Override protected void doInTransactionWithoutResult(TransactionStatus theStatus) { ResourceHistoryTable table = myResourceHistoryTableDao.findForIdAndVersionAndFetchProvenance(id.getIdPartAsLong(), 1L); - String newContent = myFhirCtx.newJsonParser().encodeResourceToString(p); + String newContent = myFhirContext.newJsonParser().encodeResourceToString(p); newContent = newContent.replace("male", "foo"); table.setResource(newContent.getBytes(Charsets.UTF_8)); table.setEncoding(ResourceEncodingEnum.JSON); @@ -2919,7 +2917,7 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test { }); Patient read = myPatientDao.read(id); - String string = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(read); + String string = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(read); ourLog.info(string); assertThat(string, containsString("value=\"foo\"")); } @@ -3155,12 +3153,12 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test { @Test public void testSaveAndReturnCollectionBundle() throws IOException { String input = IOUtils.toString(FhirResourceDaoR4Test.class.getResourceAsStream("/r4/collection-bundle.json")); - Bundle inputBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, input); + Bundle inputBundle = myFhirContext.newJsonParser().parseResource(Bundle.class, input); myBundleDao.update(inputBundle); Bundle outputBundle = myBundleDao.read(new IdType("cftest")); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(outputBundle)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(outputBundle)); for (BundleEntryComponent next : outputBundle.getEntry()) { assertTrue(next.getResource().getIdElement().hasIdPart()); @@ -3190,7 +3188,7 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test { oid1 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -3202,7 +3200,7 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test { oid2 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -3214,7 +3212,7 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test { oid3 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -3226,7 +3224,7 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test { oid4 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } @@ -3900,7 +3898,7 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test { IIdType orgId = myOrganizationDao.create(org, mySrd).getId(); Organization returned = myOrganizationDao.read(orgId, mySrd); - String val = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned); + String val = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned); ourLog.info(val); assertThat(val, containsString("")); @@ -4174,7 +4172,7 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test { public void testDontReuseErrorSearches() { SearchParameterMap map = new SearchParameterMap(); map.add("subject", new ReferenceParam("Patient/123")); - String normalized = map.toNormalizedQueryString(myFhirCtx); + String normalized = map.toNormalizedQueryString(myFhirContext); String uuid = UUID.randomUUID().toString(); runInTransaction(() -> { diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ValidateTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ValidateTest.java index d2c1ebf2732..d1dc4f006f1 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ValidateTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ValidateTest.java @@ -120,7 +120,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { BaseTermReadSvcImpl.setInvokeOnNextCallForUnitTest(null); myValidationSettings.setLocalReferenceValidationDefaultPolicy(ReferenceValidationPolicy.IGNORE); - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); myUnknownCodeSystemWarningValidationSupport.setNonExistentCodeSystemSeverity(UnknownCodeSystemWarningValidationSupport.DEFAULT_SEVERITY); } @@ -333,7 +333,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { // Use a code that's in the ValueSet { outcome = (OperationOutcome) myObservationDao.validate(loadResourceFromClasspath(Observation.class, "/r4/bl/bb-obs-code-in-valueset.json"), null, null, null, null, null, mySrd).getOperationOutcome(); - String outcomeStr = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info("Validation outcome: {}", outcomeStr); assertThat(outcomeStr, not(containsString("\"error\""))); } @@ -341,12 +341,12 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { // Use a code that's not in the ValueSet try { outcome = (OperationOutcome) myObservationDao.validate(loadResourceFromClasspath(Observation.class, "/r4/bl/bb-obs-code-not-in-valueset.json"), null, null, null, null, null, mySrd).getOperationOutcome(); - String outcomeStr = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info("Validation outcome: {}", outcomeStr); fail(); } catch (PreconditionFailedException e) { outcome = (OperationOutcome) e.getOperationOutcome(); - String outcomeStr = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info("Validation outcome: {}", outcomeStr); assertThat(outcomeStr, containsString("The code provided (http://unitsofmeasure.org#cm) is not in the value set https://bb/ValueSet/BBDemographicAgeUnit, and a code from this value set is required")); } @@ -367,7 +367,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { // Use a code that's in the ValueSet { outcome = (OperationOutcome) myObservationDao.validate(loadResourceFromClasspath(Observation.class, "/r4/bl/bb-obs-code-in-valueset.json"), null, null, null, null, null, mySrd).getOperationOutcome(); - String outcomeStr = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info("Validation outcome: {}", outcomeStr); assertThat(outcomeStr, not(containsString("\"error\""))); } @@ -375,12 +375,12 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { // Use a code that's not in the ValueSet try { outcome = (OperationOutcome) myObservationDao.validate(loadResourceFromClasspath(Observation.class, "/r4/bl/bb-obs-code-not-in-valueset.json"), null, null, null, null, null, mySrd).getOperationOutcome(); - String outcomeStr = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info("Validation outcome: {}", outcomeStr); fail(); } catch (PreconditionFailedException e) { outcome = (OperationOutcome) e.getOperationOutcome(); - String outcomeStr = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info("Validation outcome: {}", outcomeStr); assertThat(outcomeStr, containsString("The code provided (http://unitsofmeasure.org#cm) is not in the value set https://bb/ValueSet/BBDemographicAgeUnit, and a code from this value set is required: Unknown code 'http://unitsofmeasure.org#cm'")); } @@ -402,30 +402,30 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { // Use the wrong datatype try { - myFhirCtx.setParserErrorHandler(new LenientErrorHandler()); + myFhirContext.setParserErrorHandler(new LenientErrorHandler()); Observation resource = loadResourceFromClasspath(Observation.class, "/r4/bl/bb-obs-value-is-not-quantity2.json"); outcome = (OperationOutcome) myObservationDao.validate(resource, null, null, null, null, null, mySrd).getOperationOutcome(); - String outcomeStr = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info("Validation outcome: {}", outcomeStr); fail(); } catch (PreconditionFailedException e) { outcome = (OperationOutcome) e.getOperationOutcome(); - String outcomeStr = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info("Validation outcome: {}", outcomeStr); assertThat(outcomeStr, containsString("\"error\"")); } // Use the wrong datatype try { - myFhirCtx.setParserErrorHandler(new LenientErrorHandler()); + myFhirContext.setParserErrorHandler(new LenientErrorHandler()); Observation resource = loadResourceFromClasspath(Observation.class, "/r4/bl/bb-obs-value-is-not-quantity.json"); outcome = (OperationOutcome) myObservationDao.validate(resource, null, null, null, null, null, mySrd).getOperationOutcome(); - String outcomeStr = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info("Validation outcome: {}", outcomeStr); fail(); } catch (PreconditionFailedException e) { outcome = (OperationOutcome) e.getOperationOutcome(); - String outcomeStr = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info("Validation outcome: {}", outcomeStr); assertThat(outcomeStr, containsString("The Profile 'https://bb/StructureDefinition/BBDemographicAge' definition allows for the type Quantity but found type string")); } @@ -582,19 +582,19 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { // Non-existent target obs.setSubject(new Reference("Group/123")); oo = validateAndReturnOutcome(obs); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); assertEquals("Unable to resolve resource 'Group/123'", oo.getIssueFirstRep().getDiagnostics(), encode(oo)); // Target of wrong type obs.setSubject(new Reference("Group/ABC")); oo = validateAndReturnOutcome(obs); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); assertEquals("Invalid Resource target type. Found Group, but expected one of ([Patient])", oo.getIssueFirstRep().getDiagnostics(), encode(oo)); // Target of right type obs.setSubject(new Reference("Patient/DEF")); oo = validateAndReturnOutcome(obs); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); assertEquals("No issues detected during validation", oo.getIssueFirstRep().getDiagnostics(), encode(oo)); } @@ -649,19 +649,19 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { // Non-existent target obs.setSubject(new Reference("Group/123")); oo = validateAndReturnOutcome(obs); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); assertEquals("Unable to resolve resource 'Group/123'", oo.getIssueFirstRep().getDiagnostics(), encode(oo)); // Target of wrong type obs.setSubject(new Reference("Group/ABC")); oo = validateAndReturnOutcome(obs); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); assertEquals("Unable to find a match for profile Group/ABC (by type) among choices: ; [CanonicalType[http://hl7.org/fhir/StructureDefinition/Patient]]", oo.getIssueFirstRep().getDiagnostics(), encode(oo)); // Target of right type obs.setSubject(new Reference("Patient/DEF")); oo = validateAndReturnOutcome(obs); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); assertEquals("No issues detected during validation", oo.getIssueFirstRep().getDiagnostics(), encode(oo)); } @@ -715,19 +715,19 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { // Non-existent target obs.setSubject(new Reference("Group/123")); OperationOutcome oo = validateAndReturnOutcome(obs); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); assertEquals("Unable to resolve resource 'Group/123'", oo.getIssueFirstRep().getDiagnostics(), encode(oo)); // Target of wrong type obs.setSubject(new Reference("Group/ABC")); oo = validateAndReturnOutcome(obs); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); assertEquals("No issues detected during validation", oo.getIssueFirstRep().getDiagnostics(), encode(oo)); // Target of right type obs.setSubject(new Reference("Patient/DEF")); oo = validateAndReturnOutcome(obs); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); assertEquals("No issues detected during validation", oo.getIssueFirstRep().getDiagnostics(), encode(oo)); } @@ -778,9 +778,9 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { " }\n" + "}"; - ValueSet vs = myFhirCtx.newJsonParser().parseResource(ValueSet.class, input); + ValueSet vs = myFhirContext.newJsonParser().parseResource(ValueSet.class, input); OperationOutcome oo = validateAndReturnOutcome(vs); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); assertEquals("The code 123 is not valid in the system https://bb", oo.getIssue().get(0).getDiagnostics()); } @@ -798,7 +798,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { MethodOutcome outcome = myLocationDao.validate(location, null, null, null, ValidationModeEnum.CREATE, null, null); OperationOutcome oo = (OperationOutcome) outcome.getOperationOutcome(); - String ooString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); + String ooString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); ourLog.info(ooString); assertThat(ooString, containsString("Unknown code in fragment CodeSystem 'http://example.com/codesystem#foo'")); @@ -836,7 +836,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { obs.getCode().getCodingFirstRep().setCode("foo-foo"); obs.getCode().getCodingFirstRep().setDisplay("Some Code"); outcome = (OperationOutcome) myObservationDao.validate(obs, null, null, null, ValidationModeEnum.CREATE, "http://example.com/structuredefinition", mySrd).getOperationOutcome(); - ourLog.info("Outcome: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info("Outcome: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); assertEquals("Unknown code in fragment CodeSystem 'http://example.com/codesystem#foo-foo' for in-memory expansion of ValueSet 'http://example.com/valueset'", outcome.getIssueFirstRep().getDiagnostics()); assertEquals(OperationOutcome.IssueSeverity.WARNING, outcome.getIssueFirstRep().getSeverity()); @@ -845,7 +845,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { obs.getCode().getCodingFirstRep().setCode("some-code"); obs.getCode().getCodingFirstRep().setDisplay("Some Code"); outcome = (OperationOutcome) myObservationDao.validate(obs, null, null, null, ValidationModeEnum.CREATE, "http://example.com/structuredefinition", mySrd).getOperationOutcome(); - ourLog.info("Outcome: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info("Outcome: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); assertEquals("No issues detected during validation", outcome.getIssueFirstRep().getDiagnostics()); assertEquals(OperationOutcome.IssueSeverity.INFORMATION, outcome.getIssueFirstRep().getSeverity()); @@ -855,13 +855,13 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { obs.getCode().getCodingFirstRep().setDisplay("Some Code"); try { outcome = (OperationOutcome) myObservationDao.validate(obs, null, null, null, ValidationModeEnum.CREATE, "http://example.com/structuredefinition", mySrd).getOperationOutcome(); - ourLog.info("Outcome: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info("Outcome: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); assertEquals("", outcome.getIssueFirstRep().getDiagnostics()); assertEquals(OperationOutcome.IssueSeverity.INFORMATION, outcome.getIssueFirstRep().getSeverity()); fail(); } catch (PreconditionFailedException e) { outcome = (OperationOutcome) e.getOperationOutcome(); - ourLog.info("Outcome: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info("Outcome: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); assertEquals("None of the codings provided are in the value set 'MessageCategory' (http://example.com/valueset), and a coding from this value set is required) (codes = http://example.com/foo-foo#some-code)", outcome.getIssueFirstRep().getDiagnostics()); assertEquals(OperationOutcome.IssueSeverity.ERROR, outcome.getIssueFirstRep().getSeverity()); } @@ -980,7 +980,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { } return null; }); - when(validationSupport.getFhirContext()).thenReturn(myFhirCtx); + when(validationSupport.getFhirContext()).thenReturn(myFhirContext); myJpaValidationSupportChain.addValidationSupport(0, validationSupport); try { @@ -1071,7 +1071,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { obs.getCode().getCodingFirstRep().setSystem("http://FOO").setCode("CODE99999").setDisplay("Display 3"); OperationOutcome oo = validateAndReturnOutcome(obs); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); assertEquals("Error MY ERROR validating Coding: java.lang.NullPointerException: MY ERROR", oo.getIssueFirstRep().getDiagnostics()); assertEquals(OperationOutcome.IssueSeverity.ERROR, oo.getIssueFirstRep().getSeverity()); } @@ -1088,7 +1088,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { .setText("This is text") .setAuthor(new Reference("Patient/123")); - ourLog.info(myFhirCtx.newJsonParser().encodeResourceToString(allergy)); + ourLog.info(myFhirContext.newJsonParser().encodeResourceToString(allergy)); OperationOutcome oo = validateAndReturnOutcome(allergy); assertThat(encode(oo), containsString("None of the codings provided are in the value set 'AllergyIntolerance Clinical Status Codes' (http://hl7.org/fhir/ValueSet/allergyintolerance-clinical|4.0.1)")); @@ -1109,14 +1109,14 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { @Test public void testValidateStructureDefinition() throws Exception { String input = IOUtils.toString(getClass().getResourceAsStream("/r4/sd-david-dhtest7.json"), StandardCharsets.UTF_8); - StructureDefinition sd = myFhirCtx.newJsonParser().parseResource(StructureDefinition.class, input); + StructureDefinition sd = myFhirContext.newJsonParser().parseResource(StructureDefinition.class, input); ourLog.info("Starting validation"); try { myStructureDefinitionDao.validate(sd, null, null, null, ValidationModeEnum.UPDATE, null, mySrd); } catch (PreconditionFailedException e) { - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); } ourLog.info("Done validation"); @@ -1134,14 +1134,14 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { @Test public void testValidateDocument() throws Exception { String input = IOUtils.toString(getClass().getResourceAsStream("/r4/document-bundle.json"), StandardCharsets.UTF_8); - Bundle document = myFhirCtx.newJsonParser().parseResource(Bundle.class, input); + Bundle document = myFhirContext.newJsonParser().parseResource(Bundle.class, input); ourLog.info("Starting validation"); try { MethodOutcome outcome = myBundleDao.validate(document, null, null, null, ValidationModeEnum.CREATE, null, mySrd); } catch (PreconditionFailedException e) { - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); } ourLog.info("Done validation"); @@ -1153,7 +1153,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { String methodName = "testValidateResourceContainingProfileDeclarationJson"; OperationOutcome outcome = doTestValidateResourceContainingProfileDeclaration(methodName, EncodingEnum.JSON); - String ooString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String ooString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(ooString); assertThat(ooString, containsString("Element '.subject': minimum required = 1, but only found 0")); assertThat(ooString, containsString("Element encounter @ : max allowed = 0, but found 1")); @@ -1166,7 +1166,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { String methodName = "testValidateResourceContainingProfileDeclarationXml"; OperationOutcome outcome = doTestValidateResourceContainingProfileDeclaration(methodName, EncodingEnum.XML); - String ooString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String ooString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(ooString); assertThat(ooString, containsString("Element '/f:Observation.subject': minimum required = 1, but only found 0")); assertThat(ooString, containsString("Element encounter @ /f:Observation: max allowed = 0, but found 1")); @@ -1197,11 +1197,11 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { .setCode("bar"); MethodOutcome outcome = myPatientDao.validate(patient, null, encode(patient), EncodingEnum.JSON, ValidationModeEnum.CREATE, null, mySrd); IBaseOperationOutcome oo = outcome.getOperationOutcome(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); // It would be ok for this to produce 0 issues, or just an information message too - assertEquals(1, OperationOutcomeUtil.getIssueCount(myFhirCtx, oo)); - assertEquals("None of the codings provided are in the value set 'IdentifierType' (http://hl7.org/fhir/ValueSet/identifier-type), and a coding should come from this value set unless it has no suitable code (note that the validator cannot judge what is suitable) (codes = http://foo#bar)", OperationOutcomeUtil.getFirstIssueDetails(myFhirCtx, oo)); + assertEquals(1, OperationOutcomeUtil.getIssueCount(myFhirContext, oo)); + assertEquals("None of the codings provided are in the value set 'IdentifierType' (http://hl7.org/fhir/ValueSet/identifier-type), and a coding should come from this value set unless it has no suitable code (note that the validator cannot judge what is suitable) (codes = http://foo#bar)", OperationOutcomeUtil.getFirstIssueDetails(myFhirContext, oo)); } @@ -1235,7 +1235,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { ValidationModeEnum mode = ValidationModeEnum.CREATE; switch (enc) { case JSON: - encoded = myFhirCtx.newJsonParser().encodeResourceToString(input); + encoded = myFhirContext.newJsonParser().encodeResourceToString(input); try { myObservationDao.validate(input, null, encoded, EncodingEnum.JSON, mode, null, mySrd); fail(); @@ -1244,7 +1244,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { } break; case XML: - encoded = myFhirCtx.newXmlParser().encodeResourceToString(input); + encoded = myFhirContext.newXmlParser().encodeResourceToString(input); try { myObservationDao.validate(input, null, encoded, EncodingEnum.XML, mode, null, mySrd); fail(); @@ -1271,14 +1271,14 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { input.getCode().addCoding().setSystem("http://loinc.org").setCode("12345"); ValidationModeEnum mode = ValidationModeEnum.CREATE; - String encoded = myFhirCtx.newJsonParser().encodeResourceToString(input); + String encoded = myFhirContext.newJsonParser().encodeResourceToString(input); try { myObservationDao.validate(input, null, encoded, EncodingEnum.JSON, mode, null, mySrd); fail(); } catch (PreconditionFailedException e) { org.hl7.fhir.r4.model.OperationOutcome oo = (org.hl7.fhir.r4.model.OperationOutcome) e.getOperationOutcome(); - String outputString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); + String outputString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); ourLog.info(outputString); assertThat(outputString, containsString("Profile reference 'http://example.com/StructureDefinition/testValidateResourceContainingProfileDeclarationInvalid' has not been checked because it is unknown")); } @@ -1306,7 +1306,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { .setMethod(Bundle.HTTPVerb.POST); ValidationModeEnum mode = ValidationModeEnum.CREATE; - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(input); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(input); ourLog.info(encoded); try { @@ -1314,7 +1314,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { fail(); } catch (PreconditionFailedException e) { org.hl7.fhir.r4.model.OperationOutcome oo = (org.hl7.fhir.r4.model.OperationOutcome) e.getOperationOutcome(); - String outputString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); + String outputString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); ourLog.info(outputString); assertThat(outputString, containsString("Profile reference 'http://example.com/StructureDefinition/testValidateResourceContainingProfileDeclarationInvalid' has not been checked because it is unknown")); } @@ -1355,11 +1355,11 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { try { MethodOutcome outcome = myQuestionnaireResponseDao.validate(qr, null, null, null, ValidationModeEnum.CREATE, null, mySrd); OperationOutcome oo = (OperationOutcome) outcome.getOperationOutcome(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); fail(); } catch (PreconditionFailedException e) { OperationOutcome oo = (OperationOutcome) e.getOperationOutcome(); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); ourLog.info(encoded); assertThat(encoded, containsString("is not in the options value set")); } @@ -1390,7 +1390,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { myCapabilityStatementDao.validate(cs, null, null, null, ValidationModeEnum.CREATE, null, mySrd); fail(); } catch (PreconditionFailedException e) { - String oo = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome()); + String oo = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome()); ourLog.info(oo); assertThat(oo, oo, containsString("Type mismatch - SearchParameter 'http://example.com/name' type is string, but type here is date")); } @@ -1483,7 +1483,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { outcome = (OperationOutcome) e.getOperationOutcome(); } - String ooString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String ooString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(ooString); assertThat(ooString, containsString("Unable to delete Organization")); @@ -1492,7 +1492,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { myPatientDao.update(pat, mySrd); outcome = (OperationOutcome) myOrganizationDao.validate(null, orgId, null, null, ValidationModeEnum.DELETE, null, mySrd).getOperationOutcome(); - ooString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + ooString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(ooString); assertThat(ooString, containsString("Ok to delete")); @@ -1559,36 +1559,36 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { { String resource = loadResource("/r4/uscore/patient-resource-badcode.json"); - IBaseResource parsedResource = myFhirCtx.newJsonParser().parseResource(resource); + IBaseResource parsedResource = myFhirContext.newJsonParser().parseResource(resource); try { myPatientDao.validate((Patient) parsedResource, null, resource, null, null, null, mySrd); fail(); } catch (PreconditionFailedException e) { OperationOutcome oo = (OperationOutcome) e.getOperationOutcome(); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); ourLog.info("Outcome:\n{}", encoded); assertThat(encoded, containsString("Unable to validate code urn:oid:2.16.840.1.113883.6.238#2106-3AAA")); } } { String resource = loadResource("/r4/uscore/patient-resource-good.json"); - IBaseResource parsedResource = myFhirCtx.newJsonParser().parseResource(resource); + IBaseResource parsedResource = myFhirContext.newJsonParser().parseResource(resource); try { MethodOutcome outcome = myPatientDao.validate((Patient) parsedResource, null, resource, null, null, null, mySrd); OperationOutcome oo = (OperationOutcome) outcome.getOperationOutcome(); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); ourLog.info("Outcome:\n{}", encoded); assertThat(encoded, containsString("No issues detected")); } catch (PreconditionFailedException e) { - fail(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); + fail(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); } } { String resource = loadResource("/r4/uscore/observation-resource-good.json"); - IBaseResource parsedResource = myFhirCtx.newJsonParser().parseResource(resource); + IBaseResource parsedResource = myFhirContext.newJsonParser().parseResource(resource); MethodOutcome outcome = myObservationDao.validate((Observation) parsedResource, null, resource, null, null, null, mySrd); OperationOutcome oo = (OperationOutcome) outcome.getOperationOutcome(); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); ourLog.info("Outcome:\n{}", encoded); assertThat(encoded, not(containsString("error"))); } @@ -1673,7 +1673,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { OperationOutcome oo = (OperationOutcome) validationOutcome.getOperationOutcome(); assertEquals("The questionnaire 'http://foo/Questionnaire/DOES_NOT_EXIST' could not be resolved, so no validation can be performed against the base questionnaire", oo.getIssueFirstRep().getDiagnostics()); } catch (PreconditionFailedException e) { - fail(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); + fail(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); } } @@ -1687,7 +1687,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { fail(); } catch (PreconditionFailedException e) { OperationOutcome oo = (OperationOutcome) e.getOperationOutcome(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); assertThat(oo.getIssueFirstRep().getDiagnostics(), containsString("None of the codings provided are in the value set 'Condition Clinical Status Codes' (http://hl7.org/fhir/ValueSet/condition-clinical|4.0.1), and a coding from this value set is required) (codes = http://terminology.hl7.org/CodeSystem/condition-clinical/wrong-system#notrealcode)")); } @@ -1718,10 +1718,10 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { try { MethodOutcome results = myQuestionnaireDao.validate(null, null, input, EncodingEnum.XML, ValidationModeEnum.UPDATE, null, mySrd); OperationOutcome oo = (OperationOutcome) results.getOperationOutcome(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); } catch (PreconditionFailedException e) { // this is a failure of the test - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); throw e; } } @@ -1737,10 +1737,10 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { p.getMeta().addProfile("http://example.com/fhir/StructureDefinition/patient-1a-extensions"); p.setActive(true); - String raw = myFhirCtx.newJsonParser().encodeResourceToString(p); + String raw = myFhirContext.newJsonParser().encodeResourceToString(p); MethodOutcome outcome = myPatientDao.validate(p, null, raw, EncodingEnum.JSON, null, null, mySrd); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getOperationOutcome()); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getOperationOutcome()); ourLog.info("OO: {}", encoded); assertThat(encoded, containsString("No issues detected")); } @@ -1762,7 +1762,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { ValueSetExpansionOptions options = ValueSetExpansionOptions.forOffsetAndCount(0, 10000); ValueSet expansion = myValueSetDao.expand(id, options, mySrd); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); assertEquals(2, expansion.getExpansion().getContains().size()); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ValueSetTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ValueSetTest.java index 101592ea625..2bcaab67c38 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ValueSetTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ValueSetTest.java @@ -206,7 +206,7 @@ public class FhirResourceDaoR4ValueSetTest extends BaseJpaR4Test { String resp; ValueSet expanded = myValueSetDao.expand(myExtensionalVsId, null, mySrd); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, containsString("")); @@ -227,7 +227,7 @@ public class FhirResourceDaoR4ValueSetTest extends BaseJpaR4Test { */ expanded = myValueSetDao.expand(myExtensionalVsId, new ValueSetExpansionOptions().setFilter("systolic"), mySrd); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); //@formatter:off assertThat(resp, stringContainsInOrder( @@ -312,7 +312,7 @@ public class FhirResourceDaoR4ValueSetTest extends BaseJpaR4Test { assertTrue(outcome.isOk()); ValueSet expansion = myValueSetDao.expand(new IdType("ValueSet/vaccinecode"), new ValueSetExpansionOptions(), mySrd); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4VersionedReferenceTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4VersionedReferenceTest.java index 2722cb4238c..08fade9894b 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4VersionedReferenceTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4VersionedReferenceTest.java @@ -53,8 +53,8 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { @AfterEach public void afterEach() { - myFhirCtx.getParserOptions().setStripVersionsFromReferences(true); - myFhirCtx.getParserOptions().getDontStripVersionsFromReferencesAtPaths().clear(); + myFhirContext.getParserOptions().setStripVersionsFromReferences(true); + myFhirContext.getParserOptions().getDontStripVersionsFromReferencesAtPaths().clear(); myDaoConfig.setDeleteEnabled(new DaoConfig().isDeleteEnabled()); myModelConfig.setRespectVersionsForSearchIncludes(new ModelConfig().isRespectVersionsForSearchIncludes()); myModelConfig.setAutoVersionReferenceAtPaths(new ModelConfig().getAutoVersionReferenceAtPaths()); @@ -62,14 +62,14 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { @Test public void testCreateAndUpdateVersionedReferencesInTransaction_VersionedReferenceToUpsertWithNop() { - myFhirCtx.getParserOptions().setStripVersionsFromReferences(false); + myFhirContext.getParserOptions().setStripVersionsFromReferences(false); myModelConfig.setAutoVersionReferenceAtPaths("ExplanationOfBenefit.patient"); // We'll submit the same bundle twice. It has an UPSERT (with no changes // the second time) on a Patient, and a CREATE on an ExplanationOfBenefit // referencing that Patient. Supplier supplier = () -> { - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); Patient patient = new Patient(); patient.setId("Patient/A"); @@ -105,7 +105,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { @Test public void testCreateAndUpdateVersionedReferencesInTransaction_VersionedReferenceToVersionedReferenceToUpsertWithNop() { - myFhirCtx.getParserOptions().setStripVersionsFromReferences(false); + myFhirContext.getParserOptions().setStripVersionsFromReferences(false); myModelConfig.setAutoVersionReferenceAtPaths( "Patient.managingOrganization", "ExplanationOfBenefit.patient" @@ -115,7 +115,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { // the second time) on a Patient, and a CREATE on an ExplanationOfBenefit // referencing that Patient. Supplier supplier = () -> { - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); Organization organization = new Organization(); organization.setId("Organization/O"); @@ -165,7 +165,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { @Test public void testCreateAndUpdateVersionedReferencesInTransaction_VersionedReferenceToVersionedReferenceToUpsertWithChange() { - myFhirCtx.getParserOptions().setStripVersionsFromReferences(false); + myFhirContext.getParserOptions().setStripVersionsFromReferences(false); myModelConfig.setAutoVersionReferenceAtPaths( "Patient.managingOrganization", "ExplanationOfBenefit.patient" @@ -173,7 +173,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { AtomicInteger counter = new AtomicInteger(); Supplier supplier = () -> { - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); Organization organization = new Organization(); organization.setId("Organization/O"); @@ -222,7 +222,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { @Test public void testStoreAndRetrieveVersionedReference() { - myFhirCtx.getParserOptions().setStripVersionsFromReferences(false); + myFhirContext.getParserOptions().setStripVersionsFromReferences(false); Patient p = new Patient(); p.setActive(true); @@ -242,7 +242,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { @Test public void testDontOverwriteExistingVersion() { - myFhirCtx.getParserOptions().setStripVersionsFromReferences(false); + myFhirContext.getParserOptions().setStripVersionsFromReferences(false); Patient p = new Patient(); p.setActive(true); @@ -266,7 +266,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { @Test public void testInsertVersionedReferenceAtPath() { - myFhirCtx.getParserOptions().setStripVersionsFromReferences(false); + myFhirContext.getParserOptions().setStripVersionsFromReferences(false); myModelConfig.setAutoVersionReferenceAtPaths("Observation.subject"); Patient p = new Patient(); @@ -304,10 +304,10 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { @Test public void testInsertVersionedReferenceAtPath_InTransaction_SourceAndTargetBothCreated() { - myFhirCtx.getParserOptions().setStripVersionsFromReferences(false); + myFhirContext.getParserOptions().setStripVersionsFromReferences(false); myModelConfig.setAutoVersionReferenceAtPaths("Observation.subject"); - BundleBuilder builder = new BundleBuilder(myFhirCtx); + BundleBuilder builder = new BundleBuilder(myFhirContext); Patient patient = new Patient(); patient.setId(IdType.newRandomUuid()); @@ -325,7 +325,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { builder.addTransactionCreateEntry(observation); Bundle outcome = mySystemDao.transaction(mySrd, (Bundle) builder.getBundle()); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); IdType patientId = new IdType(outcome.getEntry().get(0).getResponse().getLocation()); IdType encounterId = new IdType(outcome.getEntry().get(1).getResponse().getLocation()); IdType observationId = new IdType(outcome.getEntry().get(2).getResponse().getLocation()); @@ -341,7 +341,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { @Test public void testInsertVersionedReferenceAtPath_InTransaction_TargetConditionalCreatedNop() { - myFhirCtx.getParserOptions().setStripVersionsFromReferences(false); + myFhirContext.getParserOptions().setStripVersionsFromReferences(false); myModelConfig.setAutoVersionReferenceAtPaths("Observation.subject"); { @@ -365,7 +365,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { // Verify Patient Version assertEquals("2", myPatientDao.search(SearchParameterMap.newSynchronous("active", new TokenParam("false"))).getResources(0, 1).get(0).getIdElement().getVersionIdPart()); - BundleBuilder builder = new BundleBuilder(myFhirCtx); + BundleBuilder builder = new BundleBuilder(myFhirContext); Patient patient = new Patient(); patient.setId(IdType.newRandomUuid()); @@ -383,7 +383,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { builder.addTransactionCreateEntry(observation); Bundle outcome = mySystemDao.transaction(mySrd, (Bundle) builder.getBundle()); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); assertEquals("200 OK", outcome.getEntry().get(0).getResponse().getStatus()); assertEquals("200 OK", outcome.getEntry().get(1).getResponse().getStatus()); assertEquals("201 Created", outcome.getEntry().get(2).getResponse().getStatus()); @@ -404,7 +404,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { @Test public void testInsertVersionedReferenceAtPath_InTransaction_TargetUpdate() { - myFhirCtx.getParserOptions().setStripVersionsFromReferences(false); + myFhirContext.getParserOptions().setStripVersionsFromReferences(false); myDaoConfig.setDeleteEnabled(false); myModelConfig.setAutoVersionReferenceAtPaths("Observation.subject"); @@ -420,7 +420,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { myPatientDao.update(patient); } - BundleBuilder builder = new BundleBuilder(myFhirCtx); + BundleBuilder builder = new BundleBuilder(myFhirContext); Patient patient = new Patient(); patient.setId("Patient/PATIENT"); @@ -433,7 +433,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { myCaptureQueriesListener.clear(); Bundle outcome = mySystemDao.transaction(mySrd, (Bundle) builder.getBundle()); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); assertEquals("200 OK", outcome.getEntry().get(0).getResponse().getStatus()); assertEquals("201 Created", outcome.getEntry().get(1).getResponse().getStatus()); IdType patientId = new IdType(outcome.getEntry().get(0).getResponse().getLocation()); @@ -453,7 +453,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { @Test public void testInsertVersionedReferenceAtPath_InTransaction_TargetUpdateConditional() { - myFhirCtx.getParserOptions().setStripVersionsFromReferences(false); + myFhirContext.getParserOptions().setStripVersionsFromReferences(false); myModelConfig.setAutoVersionReferenceAtPaths("Observation.subject"); { @@ -468,7 +468,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { myPatientDao.update(patient); } - BundleBuilder builder = new BundleBuilder(myFhirCtx); + BundleBuilder builder = new BundleBuilder(myFhirContext); Patient patient = new Patient(); patient.setId(IdType.newRandomUuid()); @@ -485,7 +485,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { myCaptureQueriesListener.clear(); Bundle outcome = mySystemDao.transaction(mySrd, (Bundle) builder.getBundle()); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); assertEquals("200 OK", outcome.getEntry().get(0).getResponse().getStatus()); assertEquals("201 Created", outcome.getEntry().get(1).getResponse().getStatus()); IdType patientId = new IdType(outcome.getEntry().get(0).getResponse().getLocation()); @@ -503,7 +503,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { @Test public void testSearchAndIncludeVersionedReference_Asynchronous() { - myFhirCtx.getParserOptions().setStripVersionsFromReferences(false); + myFhirContext.getParserOptions().setStripVersionsFromReferences(false); myModelConfig.setRespectVersionsForSearchIncludes(true); // Create the patient @@ -544,7 +544,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { @Test public void testSearchAndIncludeVersionedReference_Synchronous() { - myFhirCtx.getParserOptions().setStripVersionsFromReferences(false); + myFhirContext.getParserOptions().setStripVersionsFromReferences(false); myModelConfig.setRespectVersionsForSearchIncludes(true); // Create the patient @@ -587,9 +587,9 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { public void testSearchAndIncludeVersionedReference_WhenOnlyOneVersionExists() { HashSet refPaths = new HashSet(); refPaths.add("Task.basedOn"); - myFhirCtx.getParserOptions().setDontStripVersionsFromReferencesAtPaths(refPaths); + myFhirContext.getParserOptions().setDontStripVersionsFromReferencesAtPaths(refPaths); myModelConfig.setRespectVersionsForSearchIncludes(true); - myFhirCtx.getParserOptions().setStripVersionsFromReferences(false); + myFhirContext.getParserOptions().setStripVersionsFromReferences(false); // Create a Condition Condition condition = new Condition(); @@ -627,9 +627,9 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { public void testSearchAndIncludeVersionedReference_WhenMultipleVersionsExist() { HashSet refPaths = new HashSet(); refPaths.add("Task.basedOn"); - myFhirCtx.getParserOptions().setDontStripVersionsFromReferencesAtPaths(refPaths); + myFhirContext.getParserOptions().setDontStripVersionsFromReferencesAtPaths(refPaths); myModelConfig.setRespectVersionsForSearchIncludes(true); - myFhirCtx.getParserOptions().setStripVersionsFromReferences(false); + myFhirContext.getParserOptions().setStripVersionsFromReferences(false); // Create a Condition Condition condition = new Condition(); @@ -662,9 +662,9 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { public void testSearchAndIncludeVersionedReference_WhenPreviouslyReferencedVersionOne() { HashSet refPaths = new HashSet(); refPaths.add("Task.basedOn"); - myFhirCtx.getParserOptions().setDontStripVersionsFromReferencesAtPaths(refPaths); + myFhirContext.getParserOptions().setDontStripVersionsFromReferencesAtPaths(refPaths); myModelConfig.setRespectVersionsForSearchIncludes(true); - myFhirCtx.getParserOptions().setStripVersionsFromReferences(false); + myFhirContext.getParserOptions().setStripVersionsFromReferences(false); // Create a Condition Condition condition = new Condition(); @@ -704,7 +704,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { @Test public void testSearchAndIncludeUnersionedReference_Asynchronous() { - myFhirCtx.getParserOptions().setStripVersionsFromReferences(true); + myFhirContext.getParserOptions().setStripVersionsFromReferences(true); myModelConfig.setRespectVersionsForSearchIncludes(true); // Create the patient @@ -745,7 +745,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { @Test public void testSearchAndIncludeUnversionedReference_Synchronous() { - myFhirCtx.getParserOptions().setStripVersionsFromReferences(true); + myFhirContext.getParserOptions().setStripVersionsFromReferences(true); myModelConfig.setRespectVersionsForSearchIncludes(true); // Create the patient @@ -800,7 +800,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { ); myModelConfig.setAutoVersionReferenceAtPaths(new HashSet<>(strings)); - Bundle bundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, + Bundle bundle = myFhirContext.newJsonParser().parseResource(Bundle.class, new InputStreamReader( FhirResourceDaoR4VersionedReferenceTest.class.getResourceAsStream("/npe-causing-bundle.json"))); @@ -893,7 +893,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { obs.setId("Observation/DEF"); Reference patientRef = new Reference(patientId); obs.setSubject(patientRef); - BundleBuilder builder = new BundleBuilder(myFhirCtx); + BundleBuilder builder = new BundleBuilder(myFhirContext); builder.addTransactionUpdateEntry(obs); Bundle submitted = (Bundle)builder.getBundle(); @@ -917,7 +917,7 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { obs.setId("Observation/DEF"); Reference patientRef = new Reference("Patient/RED"); obs.setSubject(patientRef); - BundleBuilder builder = new BundleBuilder(myFhirCtx); + BundleBuilder builder = new BundleBuilder(myFhirContext); builder.addTransactionUpdateEntry(obs); Bundle submitted = (Bundle)builder.getBundle(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoSearchListTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoSearchListTest.java index 093b06805e5..5837b58d666 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoSearchListTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoSearchListTest.java @@ -52,7 +52,7 @@ public class FhirResourceDaoSearchListTest extends BaseJpaR4Test { private void testQuery(String theQueryString, IIdType... theExpectedPatientIds) { - SearchParameterMap map = myMatchUrlService.translateMatchUrl(theQueryString, myFhirCtx.getResourceDefinition("List")); + SearchParameterMap map = myMatchUrlService.translateMatchUrl(theQueryString, myFhirContext.getResourceDefinition("List")); IBundleProvider bundle = myPatientDao.search(map); List resources = bundle.getResources(0, theExpectedPatientIds.length); assertThat(resources, hasSize(theExpectedPatientIds.length)); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java index cc62811b4db..817c0e233b9 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java @@ -136,7 +136,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { myDaoConfig.setBundleBatchMaxPoolSize(new DaoConfig().getBundleBatchMaxPoolSize()); myDaoConfig.setAutoCreatePlaceholderReferenceTargets(new DaoConfig().isAutoCreatePlaceholderReferenceTargets()); myModelConfig.setAutoVersionReferenceAtPaths(new ModelConfig().getAutoVersionReferenceAtPaths()); - myFhirCtx.getParserOptions().setAutoContainReferenceTargetsWithNoId(true); + myFhirContext.getParserOptions().setAutoContainReferenceTargetsWithNoId(true); } @BeforeEach @@ -365,7 +365,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { assertEquals("404 Not Found", response.getEntry().get(1).getResponse().getStatus()); OperationOutcome oo = (OperationOutcome) response.getEntry().get(1).getResponse().getOutcome(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(oo)); assertEquals(IssueSeverity.ERROR, oo.getIssue().get(0).getSeverity()); assertEquals(Msg.code(2001) + "Resource Patient/BABABABA is not known", oo.getIssue().get(0).getDiagnostics()); } @@ -399,7 +399,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { assertEquals("400 Bad Request", response.getEntry().get(1).getResponse().getStatus()); OperationOutcome oo = (OperationOutcome) response.getEntry().get(1).getResponse().getOutcome(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(oo)); assertEquals(IssueSeverity.ERROR, oo.getIssue().get(0).getSeverity()); assertThat(oo.getIssue().get(0).getDiagnostics(), containsString("Unknown search parameter")); } @@ -438,7 +438,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { .getRequest().setMethod(HTTPVerb.POST); Bundle resp = mySystemDao.transaction(mySrd, inputBundle); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); IdType epId = new IdType(resp.getEntry().get(0).getResponse().getLocation()); IdType condId = new IdType(resp.getEntry().get(1).getResponse().getLocation()); @@ -470,9 +470,9 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { .getRequest().setMethod(HTTPVerb.DELETE) .setUrl(condId.toUnqualifiedVersionless().getValue()); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(inputBundle)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(inputBundle)); resp = mySystemDao.transaction(mySrd, inputBundle); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); // They should now be deleted try { @@ -490,14 +490,14 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { @Test public void testContainedArePreservedForBug410() throws IOException { String input = ClasspathUtil.loadResource("/r4/bug-410-bundle.xml"); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, input); Bundle output = mySystemDao.transaction(mySrd, bundle); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); IdType id = new IdType(output.getEntry().get(1).getResponse().getLocation()); MedicationRequest mo = myMedicationRequestDao.read(id); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(mo)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(mo)); } @Test @@ -829,10 +829,10 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { @Test public void testTransaction1() throws IOException { String inputBundleString = loadClasspath("/david-bundle-error.json"); - Bundle bundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, inputBundleString); + Bundle bundle = myFhirContext.newJsonParser().parseResource(Bundle.class, inputBundleString); Bundle resp = mySystemDao.transaction(mySrd, bundle); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); assertEquals("201 Created", resp.getEntry().get(0).getResponse().getStatus()); } @@ -877,7 +877,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { assertEquals(2, resp.getEntry().size()); assertEquals(BundleType.BATCHRESPONSE, resp.getTypeElement().getValue()); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); BundleEntryResponseComponent respEntry; // Bundle.entry[0] is create response @@ -906,7 +906,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { @Test public void testTransactionWithConditionalCreates_IdenticalMatchUrlsDifferentTypes_Unqualified() { - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); Patient pt = new Patient(); pt.addIdentifier().setSystem("foo").setValue("bar"); bb.addTransactionCreateEntry(pt).conditional("identifier=foo|bar"); @@ -922,7 +922,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { // Take 2 - bb = new BundleBuilder(myFhirCtx); + bb = new BundleBuilder(myFhirContext); pt = new Patient(); pt.addIdentifier().setSystem("foo").setValue("bar"); bb.addTransactionCreateEntry(pt).conditional("identifier=foo|bar"); @@ -941,7 +941,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { @Test public void testTransactionWithConditionalCreates_IdenticalMatchUrlsDifferentTypes_Qualified() { - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); Patient pt = new Patient(); pt.addIdentifier().setSystem("foo").setValue("bar"); bb.addTransactionCreateEntry(pt).conditional("Patient?identifier=foo|bar"); @@ -957,7 +957,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { // Take 2 - bb = new BundleBuilder(myFhirCtx); + bb = new BundleBuilder(myFhirContext); pt = new Patient(); pt.addIdentifier().setSystem("foo").setValue("bar"); bb.addTransactionCreateEntry(pt).conditional("Patient?identifier=foo|bar"); @@ -976,7 +976,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { @Test public void testTransactionWithConditionalCreate_NoResourceTypeInUrl() { - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); Patient pt = new Patient(); pt.setActive(true); bb.addTransactionCreateEntry(pt).conditional("active=true"); @@ -990,7 +990,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { // Take 2 - bb = new BundleBuilder(myFhirCtx); + bb = new BundleBuilder(myFhirContext); pt = new Patient(); pt.setActive(true); bb.addTransactionCreateEntry(pt).conditional("active=true"); @@ -1009,7 +1009,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { // Take 3 - bb = new BundleBuilder(myFhirCtx); + bb = new BundleBuilder(myFhirContext); pt = new Patient(); pt.setActive(true); bb.addTransactionCreateEntry(pt).conditional("?active=true"); @@ -1045,7 +1045,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { @Test public void testTransactionNoContainedRedux_ContainedProcessingDisabled() throws IOException { - myFhirCtx.getParserOptions().setAutoContainReferenceTargetsWithNoId(false); + myFhirContext.getParserOptions().setAutoContainReferenceTargetsWithNoId(false); //Pre-create the patient, which will cause the ifNoneExist to prevent a new creation during bundle transaction Patient patient = loadResourceFromClasspath(Patient.class, "/r4/preexisting-patient.json"); @@ -1073,13 +1073,13 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { request = loadResourceFromClasspath(Bundle.class, "/r4/transaction-no-contained.json"); Bundle outcome = mySystemDao.transaction(mySrd, request); - ourLog.info("Outcome: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info("Outcome: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); IdType communicationId = new IdType(outcome.getEntry().get(1).getResponse().getLocation()); Communication communication = myCommunicationDao.read(communicationId, mySrd); assertThat(communication.getSubject().getReference(), matchesPattern("Patient/[0-9]+")); - ourLog.info("Outcome: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(communication)); + ourLog.info("Outcome: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(communication)); } @@ -1153,7 +1153,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { .setUrl("Patient/"); Bundle outcome = mySystemDao.transaction(mySrd, request); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); assertEquals("400 Bad Request", outcome.getEntry().get(0).getResponse().getStatus()); assertEquals(IssueSeverity.ERROR, ((OperationOutcome) outcome.getEntry().get(0).getResponse().getOutcome()).getIssueFirstRep().getSeverity()); assertEquals(Msg.code(543) + "Missing required resource in Bundle.entry[0].resource for operation POST", ((OperationOutcome) outcome.getEntry().get(0).getResponse().getOutcome()).getIssueFirstRep().getDiagnostics()); @@ -1172,7 +1172,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { .setUrl("Patient/123"); Bundle outcome = mySystemDao.transaction(mySrd, request); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); assertEquals("400 Bad Request", outcome.getEntry().get(0).getResponse().getStatus()); assertEquals(IssueSeverity.ERROR, ((OperationOutcome) outcome.getEntry().get(0).getResponse().getOutcome()).getIssueFirstRep().getSeverity()); assertEquals(Msg.code(543) + "Missing required resource in Bundle.entry[0].resource for operation PUT", ((OperationOutcome) outcome.getEntry().get(0).getResponse().getOutcome()).getIssueFirstRep().getDiagnostics()); @@ -1190,7 +1190,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { .setMethod(HTTPVerb.POST); Bundle outcome = mySystemDao.transaction(mySrd, request); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); assertEquals("201 Created", outcome.getEntry().get(0).getResponse().getStatus()); validate(outcome); } @@ -1229,7 +1229,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { .setUrl("/Observation?subject=" + patient.getIdElement().toUnqualifiedVersionless().toString()); ourLog.info("Patient TEMP UUID: {}", patient.getId()); - String s = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(transactionBundle); + String s = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(transactionBundle); System.out.println(s); Bundle outcome = mySystemDao.transaction(null, transactionBundle); String patientLocation = outcome.getEntry().get(0).getResponse().getLocation(); @@ -1610,7 +1610,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { Bundle response = mySystemDao.transaction(null, request); - ourLog.info("Response:\n{}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info("Response:\n{}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); List responseTypes = response .getEntry() @@ -1670,7 +1670,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { Bundle response = mySystemDao.transaction(null, request); - ourLog.info("Response:\n{}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info("Response:\n{}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); List responseTypes = response .getEntry() @@ -1727,7 +1727,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { Bundle response = mySystemDao.transaction(null, request); - ourLog.info("Response:\n{}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info("Response:\n{}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); List responseTypes = response .getEntry() @@ -1962,7 +1962,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { assertEquals("404 Not Found", response.getEntry().get(1).getResponse().getStatus()); OperationOutcome oo = (OperationOutcome) response.getEntry().get(1).getResponse().getOutcome(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(oo)); assertEquals(IssueSeverity.ERROR, oo.getIssue().get(0).getSeverity()); assertEquals(Msg.code(2001) + "Resource Patient/BABABABA is not known", oo.getIssue().get(0).getDiagnostics()); } @@ -1996,7 +1996,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { assertEquals("400 Bad Request", response.getEntry().get(1).getResponse().getStatus()); OperationOutcome oo = (OperationOutcome) response.getEntry().get(1).getResponse().getOutcome(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(oo)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(oo)); assertEquals(IssueSeverity.ERROR, oo.getIssue().get(0).getSeverity()); assertThat(oo.getIssue().get(0).getDiagnostics(), containsString("Unknown search parameter")); } @@ -2162,7 +2162,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { @Test public void testTransactionCreateWithPutUsingUrl2() throws Exception { String req = IOUtils.toString(FhirSystemDaoR4Test.class.getResourceAsStream("/r4/bundle.xml"), StandardCharsets.UTF_8); - Bundle request = myFhirCtx.newXmlParser().parseResource(Bundle.class, req); + Bundle request = myFhirContext.newXmlParser().parseResource(Bundle.class, req); mySystemDao.transaction(mySrd, request); } @@ -2455,12 +2455,12 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { fail(e.toString()); return; } - Bundle bundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, input); + Bundle bundle = myFhirContext.newJsonParser().parseResource(Bundle.class, input); mySystemDao.transaction(mySrd, bundle); IBundleProvider history = mySystemDao.history(null, null, null, null); Bundle list = toBundleR4(history); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(list)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(list)); assertEquals(6, list.getEntry().size()); @@ -2730,11 +2730,11 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/transaction_link_patient_eve.xml"); String bundleStr = IOUtils.toString(bundleRes, StandardCharsets.UTF_8); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, bundleStr); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, bundleStr); Bundle resp = mySystemDao.transaction(mySrd, bundle); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); assertThat(resp.getEntry().get(0).getResponse().getLocation(), startsWith("Patient/a555-44-4444/_history/")); assertThat(resp.getEntry().get(1).getResponse().getLocation(), startsWith("Patient/temp6789/_history/")); @@ -2747,10 +2747,10 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { @Test public void testTransactionFromBundle2() throws Exception { String input = IOUtils.toString(getClass().getResourceAsStream("/transaction-bundle.xml"), StandardCharsets.UTF_8); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, input); Bundle response = mySystemDao.transaction(mySrd, bundle); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); assertEquals("201 Created", response.getEntry().get(0).getResponse().getStatus()); assertThat(response.getEntry().get(0).getResponse().getLocation(), matchesPattern("Practitioner/[0-9]+/_history/1")); @@ -2758,10 +2758,10 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { * Now a second time */ - bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, input); response = mySystemDao.transaction(mySrd, bundle); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); assertEquals("200 OK", response.getEntry().get(0).getResponse().getStatus()); assertThat(response.getEntry().get(0).getResponse().getLocation(), matchesPattern("Practitioner/[0-9]+/_history/1")); @@ -2771,8 +2771,8 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { public void testTransactionFromBundle6() throws Exception { InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/simone_bundle3.xml"); String bundle = IOUtils.toString(bundleRes, StandardCharsets.UTF_8); - Bundle output = mySystemDao.transaction(mySrd, myFhirCtx.newXmlParser().parseResource(Bundle.class, bundle)); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + Bundle output = mySystemDao.transaction(mySrd, myFhirContext.newXmlParser().parseResource(Bundle.class, bundle)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); } @Test @@ -2780,11 +2780,11 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/josh-bundle.json"); String bundleStr = IOUtils.toString(bundleRes, StandardCharsets.UTF_8); - Bundle bundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, bundleStr); + Bundle bundle = myFhirContext.newJsonParser().parseResource(Bundle.class, bundleStr); Bundle resp = mySystemDao.transaction(mySrd, bundle); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); assertEquals("201 Created", resp.getEntry().get(0).getResponse().getStatus()); assertEquals("201 Created", resp.getEntry().get(1).getResponse().getStatus()); @@ -2845,7 +2845,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { } private void testTransactionOrderingValidateResponse(int pass, Bundle resp) { - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); assertEquals(4, resp.getEntry().size()); assertEquals("200 OK", resp.getEntry().get(0).getResponse().getStatus()); if (pass == 0) { @@ -2880,13 +2880,13 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { Bundle inputBundle; Bundle outputBundle; - inputBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, input); + inputBundle = myFhirContext.newJsonParser().parseResource(Bundle.class, input); outputBundle = mySystemDao.transaction(mySrd, inputBundle); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outputBundle)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outputBundle)); - inputBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, input); + inputBundle = myFhirContext.newJsonParser().parseResource(Bundle.class, input); outputBundle = mySystemDao.transaction(mySrd, inputBundle); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outputBundle)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outputBundle)); IBundleProvider allPatients = myPatientDao.search(new SearchParameterMap()); assertEquals(1, allPatients.size().intValue()); @@ -3035,7 +3035,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { Patient patient = new Patient(); patient.getManagingOrganization().setResource(organization); - BundleBuilder bundleBuilder = new BundleBuilder(myFhirCtx); + BundleBuilder bundleBuilder = new BundleBuilder(myFhirContext); bundleBuilder.addTransactionCreateEntry(patient); Bundle outcome = mySystemDao.transaction(null, (Bundle) bundleBuilder.getBundle()); @@ -3470,14 +3470,14 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/questionnaire-sdc-profile-example-ussg-fht.xml"); String bundleStr = IOUtils.toString(bundleRes, StandardCharsets.UTF_8); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, bundleStr); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, bundleStr); Bundle resp = mySystemDao.transaction(mySrd, bundle); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp); ourLog.info(encoded); - encoded = myFhirCtx.newJsonParser().setPrettyPrint(false).encodeResourceToString(resp); + encoded = myFhirContext.newJsonParser().setPrettyPrint(false).encodeResourceToString(resp); //@formatter:off assertThat(encoded, containsString("\"response\":{" + "\"status\":\"201 Created\"," + @@ -3490,10 +3490,10 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { resp = mySystemDao.transaction(mySrd, bundle); - encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp); + encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp); ourLog.info(encoded); - encoded = myFhirCtx.newJsonParser().setPrettyPrint(false).encodeResourceToString(resp); + encoded = myFhirContext.newJsonParser().setPrettyPrint(false).encodeResourceToString(resp); //@formatter:off assertThat(encoded, containsString("\"response\":{" + "\"status\":\"200 OK\"," + @@ -3813,10 +3813,10 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { myPatientDao.create(patient, mySrd); String input = IOUtils.toString(getClass().getResourceAsStream("/simone-conditional-url.xml"), StandardCharsets.UTF_8); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, input); Bundle response = mySystemDao.transaction(mySrd, bundle); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); } @@ -3833,7 +3833,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { myPatientDao.create(patient, mySrd); String input = IOUtils.toString(getClass().getResourceAsStream("/simone-conditional-url.xml"), StandardCharsets.UTF_8); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, input); try { mySystemDao.transaction(mySrd, bundle); @@ -3849,7 +3849,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { myDaoConfig.setAllowInlineMatchUrlReferences(true); String input = IOUtils.toString(getClass().getResourceAsStream("/simone-conditional-url.xml"), StandardCharsets.UTF_8); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, input); try { mySystemDao.transaction(mySrd, bundle); @@ -3883,7 +3883,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { @Disabled public void testTransactionWithMatchUrlToReferenceInSameBundle() throws IOException { String input = IOUtils.toString(getClass().getResourceAsStream("/r4/bug801.json"), StandardCharsets.UTF_8); - Bundle bundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, input); + Bundle bundle = myFhirContext.newJsonParser().parseResource(Bundle.class, input); try { mySystemDao.transaction(mySrd, bundle); @@ -3896,10 +3896,10 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { @Test public void testTransactionWithMultiBundle() throws IOException { String inputBundleString = loadClasspath("/r4/batch-error.xml"); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, inputBundleString); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, inputBundleString); Bundle resp = mySystemDao.transaction(mySrd, bundle); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); assertEquals("201 Created", resp.getEntry().get(0).getResponse().getStatus()); @@ -3963,7 +3963,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { //@formatter:on Bundle outputBundle = mySystemDao.transaction(mySrd, inputBundle); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(outputBundle)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(outputBundle)); assertEquals(3, outputBundle.getEntry().size()); IdDt id0 = new IdDt(outputBundle.getEntry().get(0).getResponse().getLocation()); @@ -3998,7 +3998,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { Bundle input2 = createInputTransactionWithPlaceholderIdInMatchUrl(HTTPVerb.POST); Bundle output2 = mySystemDao.transaction(null, input2); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output2)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output2)); assertEquals("200 OK", output2.getEntry().get(0).getResponse().getStatus()); assertEquals("200 OK", output2.getEntry().get(1).getResponse().getStatus()); @@ -4028,7 +4028,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { Bundle input2 = createInputTransactionWithPlaceholderIdInMatchUrl(HTTPVerb.PUT); Bundle output2 = mySystemDao.transaction(null, input2); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output2)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output2)); assertEquals("200 OK", output2.getEntry().get(0).getResponse().getStatus()); assertEquals("200 OK", output2.getEntry().get(1).getResponse().getStatus()); @@ -4045,9 +4045,9 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { // First bundle (name is Joshua) String input = IOUtils.toString(getClass().getResource("/r4/post1.xml"), StandardCharsets.UTF_8); - Bundle request = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + Bundle request = myFhirContext.newXmlParser().parseResource(Bundle.class, input); Bundle response = mySystemDao.transaction(mySrd, request); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); assertEquals(1, response.getEntry().size()); assertEquals("201 Created", response.getEntry().get(0).getResponse().getStatus()); @@ -4057,9 +4057,9 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { // Now the second (name is Adam, shouldn't get used) input = IOUtils.toString(getClass().getResource("/r4/post2.xml"), StandardCharsets.UTF_8); - request = myFhirCtx.newXmlParser().parseResource(Bundle.class, input); + request = myFhirContext.newXmlParser().parseResource(Bundle.class, input); response = mySystemDao.transaction(mySrd, request); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); assertEquals(1, response.getEntry().size()); assertEquals("200 OK", response.getEntry().get(0).getResponse().getStatus()); @@ -4068,7 +4068,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { assertEquals(id, id2); Patient patient = myPatientDao.read(new IdType(id), mySrd); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient)); assertEquals("Joshua", patient.getNameFirstRep().getGivenAsSingleString()); } @@ -4087,7 +4087,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { request.addEntry().setResource(o).getRequest().setMethod(HTTPVerb.POST); Bundle resp = mySystemDao.transaction(mySrd, request); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); String patientId = new IdType(resp.getEntry().get(0).getResponse().getLocation()).toUnqualifiedVersionless().getValue(); assertThat(patientId, startsWith("Patient/")); @@ -4114,10 +4114,10 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { mo.setMedication(new Reference(medId)); bundle.addEntry().setResource(mo).setFullUrl(mo.getIdElement().getValue()).getRequest().setMethod(HTTPVerb.POST); - ourLog.info("Request:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info("Request:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); Bundle outcome = mySystemDao.transaction(mySrd, bundle); - ourLog.info("Response:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info("Response:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); IdType medId1 = new IdType(outcome.getEntry().get(0).getResponse().getLocation()); IdType medOrderId1 = new IdType(outcome.getEntry().get(1).getResponse().getLocation()); @@ -4167,7 +4167,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { request.addEntry().setResource(o).getRequest().setMethod(HTTPVerb.POST); Bundle resp = mySystemDao.transaction(mySrd, request); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); String patientId = new IdType(resp.getEntry().get(0).getResponse().getLocation()).toUnqualifiedVersionless().getValue(); assertThat(patientId, startsWith("Patient/")); @@ -4201,7 +4201,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { Bundle resp = mySystemDao.transaction(mySrd, res); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); assertEquals(BundleType.TRANSACTIONRESPONSE, resp.getTypeElement().getValue()); assertEquals(3, resp.getEntry().size()); @@ -4344,7 +4344,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { Bundle resp = mySystemDao.transaction(mySrd, res); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); assertEquals(BundleType.TRANSACTIONRESPONSE, resp.getTypeElement().getValue()); assertEquals(3, resp.getEntry().size()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/JpaHistoryR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/JpaHistoryR4Test.java index 096e37a461b..c9da8603cc8 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/JpaHistoryR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/JpaHistoryR4Test.java @@ -272,7 +272,7 @@ public class JpaHistoryR4Test extends BaseJpaR4SystemTest { } private void create20Patients() { - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); int count = 20; for (int i = 0; i < count; i++) { Patient p = new Patient(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/PartitioningSqlR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/PartitioningSqlR4Test.java index b472c6f99e9..8ee92550ea3 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/PartitioningSqlR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/PartitioningSqlR4Test.java @@ -649,7 +649,7 @@ public class PartitioningSqlR4Test extends BasePartitioningR4Test { .setResource(p) .getRequest().setUrl("Patient").setMethod(Bundle.HTTPVerb.POST); Bundle output = mySystemDao.transaction(mySrd, input); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); Long patientId = new IdType(output.getEntry().get(1).getResponse().getLocation()).getIdPartAsLong(); runInTransaction(() -> { @@ -2685,7 +2685,7 @@ public class PartitioningSqlR4Test extends BasePartitioningR4Test { AtomicInteger counter = new AtomicInteger(0); Supplier input = () -> { - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); Patient pt = new Patient(); pt.setId(IdType.newRandomUuid()); @@ -2738,7 +2738,7 @@ public class PartitioningSqlR4Test extends BasePartitioningR4Test { myCaptureQueriesListener.clear(); Bundle outcome = mySystemDao.transaction(mySrd, input.get()); - ourLog.info("Resp: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info("Resp: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); myCaptureQueriesListener.logSelectQueries(); assertEquals(1, myCaptureQueriesListener.countSelectQueries()); assertThat(myCaptureQueriesListener.getSelectQueries().get(0).getSql(true, false), containsString("resourcein0_.HASH_SYS_AND_VALUE='-4132452001562191669' and (resourcein0_.PARTITION_ID in ('1'))")); @@ -2754,7 +2754,7 @@ public class PartitioningSqlR4Test extends BasePartitioningR4Test { myCaptureQueriesListener.clear(); outcome = mySystemDao.transaction(mySrd, input.get()); - ourLog.info("Resp: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info("Resp: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); myCaptureQueriesListener.logSelectQueries(); assertEquals(11, myCaptureQueriesListener.countSelectQueries()); myCaptureQueriesListener.logInsertQueries(); @@ -2771,7 +2771,7 @@ public class PartitioningSqlR4Test extends BasePartitioningR4Test { myCaptureQueriesListener.clear(); outcome = mySystemDao.transaction(mySrd, input.get()); - ourLog.info("Resp: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info("Resp: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); myCaptureQueriesListener.logSelectQueries(); assertEquals(6, myCaptureQueriesListener.countSelectQueries()); myCaptureQueriesListener.logInsertQueries(); @@ -2786,7 +2786,7 @@ public class PartitioningSqlR4Test extends BasePartitioningR4Test { myCaptureQueriesListener.clear(); outcome = mySystemDao.transaction(mySrd, input.get()); - ourLog.info("Resp: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + ourLog.info("Resp: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); myCaptureQueriesListener.logSelectQueries(); assertEquals(5, myCaptureQueriesListener.countSelectQueries()); myCaptureQueriesListener.logInsertQueries(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/SyntheaPerfTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/SyntheaPerfTest.java index 0949333fcb3..d62479993e4 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/SyntheaPerfTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/SyntheaPerfTest.java @@ -65,7 +65,7 @@ public class SyntheaPerfTest extends BaseJpaTest { @AfterEach public void afterEach() { - myCtx.getParserOptions().setAutoContainReferenceTargetsWithNoId(true); + myFhirContext.getParserOptions().setAutoContainReferenceTargetsWithNoId(true); } private static final Logger ourLog = LoggerFactory.getLogger(SyntheaPerfTest.class); @@ -73,7 +73,7 @@ public class SyntheaPerfTest extends BaseJpaTest { public static final String PATH_TO_SYNTHEA_OUTPUT = "../../synthea/output/fhir/"; public static final int CONCURRENCY = 4; @Autowired - private FhirContext myCtx; + private FhirContext myFhirContext; @Autowired private PlatformTransactionManager myTxManager; @Autowired @@ -88,7 +88,7 @@ public class SyntheaPerfTest extends BaseJpaTest { myDaoConfig.setTagStorageMode(DaoConfig.TagStorageModeEnum.INLINE); myDaoConfig.setMatchUrlCacheEnabled(true); myDaoConfig.setDeleteEnabled(false); - myCtx.getParserOptions().setAutoContainReferenceTargetsWithNoId(false); + myFhirContext.getParserOptions().setAutoContainReferenceTargetsWithNoId(false); myDaoConfig.setInlineResourceTextBelowSize(4000); assertTrue(myDaoConfig.isMassIngestionMode()); @@ -112,8 +112,8 @@ public class SyntheaPerfTest extends BaseJpaTest { } @Override - protected FhirContext getContext() { - return myCtx; + public FhirContext getFhirContext() { + return myFhirContext; } @Override diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/TestContextLoads.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/TestContextLoads.java new file mode 100644 index 00000000000..fee3b3ec724 --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/TestContextLoads.java @@ -0,0 +1,14 @@ +package ca.uhn.fhir.jpa.dao.r4; + +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TestContextLoads extends BaseJpaR4Test { + private static final Logger ourLog = LoggerFactory.getLogger(TestContextLoads.class); + + @Test + public void testContextLoads() { + ourLog.info("Yay it loads!"); + } +} diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r5/BaseJpaR5Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r5/BaseJpaR5Test.java index eb73e9ebfc6..2678243f65a 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r5/BaseJpaR5Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r5/BaseJpaR5Test.java @@ -131,7 +131,6 @@ import org.hl7.fhir.r5.model.Task; import org.hl7.fhir.r5.model.UriType; import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.utils.validation.constants.BestPracticeWarningLevel; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.ExtendWith; @@ -489,11 +488,6 @@ public abstract class BaseJpaR5Test extends BaseJpaTest implements ITestDataBuil myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); } - @Override - protected FhirContext getContext() { - return myFhirCtx; - } - @Override protected PlatformTransactionManager getTxManager() { return myTxManager; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/delete/job/ReindexJobTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/delete/job/ReindexJobTest.java index 8df82b52b93..66e00e37816 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/delete/job/ReindexJobTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/delete/job/ReindexJobTest.java @@ -49,7 +49,7 @@ public class ReindexJobTest extends BaseJpaR4Test { @PostConstruct public void postConstruct() { - myReindexTestHelper = new ReindexTestHelper(myFhirCtx, myDaoRegistry, mySearchParamRegistry); + myReindexTestHelper = new ReindexTestHelper(myFhirContext, myDaoRegistry, mySearchParamRegistry); } @Test diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/CascadingDeleteInterceptorTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/CascadingDeleteInterceptorTest.java index 4a55e6bbb63..d35ab0477e6 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/CascadingDeleteInterceptorTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/CascadingDeleteInterceptorTest.java @@ -106,7 +106,7 @@ public class CascadingDeleteInterceptorTest extends BaseResourceProviderR4Test { DaoRegistry mockDaoRegistry = mock(DaoRegistry.class); IFhirResourceDao mockResourceDao = mock (IFhirResourceDao.class); IBaseResource mockResource = mock(IBaseResource.class); - CascadingDeleteInterceptor aDeleteInterceptor = new CascadingDeleteInterceptor(myFhirCtx, mockDaoRegistry, myInterceptorBroadcaster); + CascadingDeleteInterceptor aDeleteInterceptor = new CascadingDeleteInterceptor(myFhirContext, mockDaoRegistry, myInterceptorBroadcaster); ourRestServer.getInterceptorService().unregisterInterceptor(myDeleteInterceptor); ourRestServer.getInterceptorService().registerInterceptor(aDeleteInterceptor); when(mockDaoRegistry.getResourceDao(any(String.class))).thenReturn(mockResourceDao); @@ -143,7 +143,7 @@ public class CascadingDeleteInterceptorTest extends BaseResourceProviderR4Test { fail(); } catch (ResourceVersionConflictException e) { // good - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); } } @@ -171,7 +171,7 @@ public class CascadingDeleteInterceptorTest extends BaseResourceProviderR4Test { myClient.delete().resourceById(myPatientId).execute(); fail(); } catch (ResourceVersionConflictException e) { - String output = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome()); + String output = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome()); ourLog.info(output); assertThat(output, containsString("Note that cascading deletes are not active for this request. You can enable cascading deletes")); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/PatientIdPartitionInterceptorTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/PatientIdPartitionInterceptorTest.java index cf4693e8991..73721a2e19e 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/PatientIdPartitionInterceptorTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/PatientIdPartitionInterceptorTest.java @@ -8,7 +8,6 @@ import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.partition.SystemRequestDetails; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.searchparam.extractor.ISearchParamExtractor; -import ca.uhn.fhir.util.MultimapCollector; import ca.uhn.fhir.jpa.util.SqlQuery; import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.rest.api.server.IBundleProvider; @@ -16,6 +15,7 @@ import ca.uhn.fhir.rest.param.ReferenceParam; import ca.uhn.fhir.rest.param.TokenOrListParam; import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException; +import ca.uhn.fhir.util.MultimapCollector; import com.google.common.collect.ListMultimap; import com.google.common.collect.Multimap; import org.hl7.fhir.r4.model.Bundle; @@ -57,7 +57,7 @@ public class PatientIdPartitionInterceptorTest extends BaseJpaR4SystemTest { @BeforeEach public void before() { - mySvc = new PatientIdPartitionInterceptor(myFhirCtx, mySearchParamExtractor); + mySvc = new PatientIdPartitionInterceptor(myFhirContext, mySearchParamExtractor); myForceOffsetSearchModeInterceptor = new ForceOffsetSearchModeInterceptor(); myInterceptorRegistry.registerInterceptor(mySvc); @@ -246,7 +246,7 @@ public class PatientIdPartitionInterceptorTest extends BaseJpaR4SystemTest { // Typed myCaptureQueriesListener.clear(); ReferenceParam referenceParam = new ReferenceParam(); - referenceParam.setValueAsQueryToken(myFhirCtx, "subject", ":Patient", "A"); + referenceParam.setValueAsQueryToken(myFhirContext, "subject", ":Patient", "A"); outcome = myObservationDao.search(SearchParameterMap.newSynchronous("subject", referenceParam), mySrd); assertEquals(1, outcome.size()); myCaptureQueriesListener.logSelectQueries(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/validation/RepositoryValidatingInterceptorHttpR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/validation/RepositoryValidatingInterceptorHttpR4Test.java index ef3c36dfa05..d7819f68b2d 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/validation/RepositoryValidatingInterceptorHttpR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/validation/RepositoryValidatingInterceptorHttpR4Test.java @@ -36,7 +36,7 @@ public class RepositoryValidatingInterceptorHttpR4Test extends BaseJpaR4Test { @BeforeEach public void before() { myValInterceptor = new RepositoryValidatingInterceptor(); - myValInterceptor.setFhirContext(myFhirCtx); + myValInterceptor.setFhirContext(myFhirContext); myInterceptorRegistry.registerInterceptor(myValInterceptor); myRestfulServerExtension.getRestfulServer().registerProvider(myObservationResourceProvider); @@ -68,7 +68,7 @@ public class RepositoryValidatingInterceptorHttpR4Test extends BaseJpaR4Test { .prefer(PreferReturnEnum.OPERATION_OUTCOME) .execute(); - String operationOutcomeEncoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getOperationOutcome()); + String operationOutcomeEncoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getOperationOutcome()); ourLog.info("Outcome: {}", operationOutcomeEncoded); assertThat(operationOutcomeEncoded, containsString("All observations should have a subject")); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/validation/RepositoryValidatingInterceptorR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/validation/RepositoryValidatingInterceptorR4Test.java index 8a14880845a..ade97f8e893 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/validation/RepositoryValidatingInterceptorR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/validation/RepositoryValidatingInterceptorR4Test.java @@ -41,7 +41,7 @@ public class RepositoryValidatingInterceptorR4Test extends BaseJpaR4Test { @BeforeEach public void before() { myValInterceptor = new RepositoryValidatingInterceptor(); - myValInterceptor.setFhirContext(myFhirCtx); + myValInterceptor.setFhirContext(myFhirContext); myInterceptorRegistry.registerInterceptor(myValInterceptor); } @@ -260,7 +260,7 @@ public class RepositoryValidatingInterceptorR4Test extends BaseJpaR4Test { assertEquals("1", id.getVersionIdPart()); } catch (PreconditionFailedException e) { // should not happen - fail(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); + fail(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); } } @@ -287,7 +287,7 @@ public class RepositoryValidatingInterceptorR4Test extends BaseJpaR4Test { assertEquals("1", id.getVersionIdPart()); } catch (PreconditionFailedException e) { // should not happen - fail(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); + fail(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); } } @@ -314,7 +314,7 @@ public class RepositoryValidatingInterceptorR4Test extends BaseJpaR4Test { assertEquals("1", id.getVersionIdPart()); } catch (PreconditionFailedException e) { // should not happen - fail(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); + fail(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); } } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/validation/ValidationMessageSuppressingInterceptorTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/validation/ValidationMessageSuppressingInterceptorTest.java index 8742be4cf9b..9efe6569e20 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/validation/ValidationMessageSuppressingInterceptorTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/validation/ValidationMessageSuppressingInterceptorTest.java @@ -52,7 +52,7 @@ public class ValidationMessageSuppressingInterceptorTest extends BaseResourcePro upload("/r4/uscore/StructureDefinition-us-core-pulse-oximetry.json"); String input = loadResource("/r4/uscore/observation-pulseox.json"); - Observation inputObs = loadResource(myFhirCtx, Observation.class, "/r4/uscore/observation-pulseox.json"); + Observation inputObs = loadResource(myFhirContext, Observation.class, "/r4/uscore/observation-pulseox.json"); try { myObservationDao.validate(inputObs, null, input, null, null, null, null); @@ -78,7 +78,7 @@ public class ValidationMessageSuppressingInterceptorTest extends BaseResourcePro upload("/r4/uscore/CodeSystem-dummy-loinc.json"); upload("/r4/uscore/StructureDefinition-us-core-pulse-oximetry.json"); - FhirValidator validator = myFhirCtx.newValidator(); + FhirValidator validator = myFhirContext.newValidator(); validator.setInterceptorBroadcaster(myInterceptorRegistry); validator.registerValidatorModule(new FhirInstanceValidator(myValidationSupport)); @@ -90,7 +90,7 @@ public class ValidationMessageSuppressingInterceptorTest extends BaseResourcePro // Without suppression { - Observation inputObs = loadResource(myFhirCtx, Observation.class, "/r4/uscore/observation-pulseox.json"); + Observation inputObs = loadResource(myFhirContext, Observation.class, "/r4/uscore/observation-pulseox.json"); try { myClient.create().resource(inputObs).execute().getId().toUnqualifiedVersionless().getValue(); fail(); @@ -106,7 +106,7 @@ public class ValidationMessageSuppressingInterceptorTest extends BaseResourcePro interceptor.addMessageSuppressionPatterns("Unknown code 'http://loinc.org#59408-5'"); myInterceptorRegistry.registerInterceptor(interceptor); { - Observation inputObs = loadResource(myFhirCtx, Observation.class, "/r4/uscore/observation-pulseox.json"); + Observation inputObs = loadResource(myFhirContext, Observation.class, "/r4/uscore/observation-pulseox.json"); String id = myClient.create().resource(inputObs).execute().getId().toUnqualifiedVersionless().getValue(); assertThat(id, matchesPattern("Observation/[0-9]+")); } @@ -122,7 +122,7 @@ public class ValidationMessageSuppressingInterceptorTest extends BaseResourcePro .build(); RepositoryValidatingInterceptor repositoryValidatingInterceptor = new RepositoryValidatingInterceptor(); - repositoryValidatingInterceptor.setFhirContext(myFhirCtx); + repositoryValidatingInterceptor.setFhirContext(myFhirContext); repositoryValidatingInterceptor.setRules(rules); myInterceptorRegistry.registerInterceptor(repositoryValidatingInterceptor); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/packages/JpaPackageCacheTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/packages/JpaPackageCacheTest.java index d1f0f9bb46b..cd6d6d1f531 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/packages/JpaPackageCacheTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/packages/JpaPackageCacheTest.java @@ -79,7 +79,7 @@ public class JpaPackageCacheTest extends BaseJpaR4Test { public void testSaveAndDeletePackagePartitionsEnabled() throws IOException { myPartitionSettings.setPartitioningEnabled(true); myPartitionSettings.setDefaultPartitionId(1); - myInterceptorService.registerInterceptor(new PatientIdPartitionInterceptor(myFhirCtx, mySearchParamExtractor)); + myInterceptorService.registerInterceptor(new PatientIdPartitionInterceptor(myFhirContext, mySearchParamExtractor)); myInterceptorService.registerInterceptor(myRequestTenantPartitionInterceptor); try (InputStream stream = ClasspathUtil.loadResourceAsStream("/packages/basisprofil.de.tar.gz")) { @@ -113,7 +113,7 @@ public class JpaPackageCacheTest extends BaseJpaR4Test { myPartitionSettings.setPartitioningEnabled(true); myPartitionSettings.setDefaultPartitionId(0); myPartitionSettings.setUnnamedPartitionMode(true); - myInterceptorService.registerInterceptor(new PatientIdPartitionInterceptor(myFhirCtx, mySearchParamExtractor)); + myInterceptorService.registerInterceptor(new PatientIdPartitionInterceptor(myFhirContext, mySearchParamExtractor)); myInterceptorService.registerInterceptor(myRequestTenantPartitionInterceptor); try (InputStream stream = ClasspathUtil.loadResourceAsStream("/packages/hl7.fhir.uv.shorthand-0.12.0.tgz")) { diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/packages/NpmDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/packages/NpmDstu3Test.java index b576866c7bf..d1b013b0e4f 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/packages/NpmDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/packages/NpmDstu3Test.java @@ -96,7 +96,7 @@ public class NpmDstu3Test extends BaseJpaDstu3Test { myConditionDao.validate(condition, null, null, null, ValidationModeEnum.CREATE, null, mySrd); fail(); } catch (PreconditionFailedException e) { - ourLog.info("Fail Outcome: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); + ourLog.info("Fail Outcome: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); OperationOutcome oo = (OperationOutcome) e.getOperationOutcome(); assertEquals("Condition.subject: minimum required = 1, but only found 0 (from http://fhir.de/StructureDefinition/condition-de-basis/0.2)", oo.getIssueFirstRep().getDiagnostics()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/packages/NpmR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/packages/NpmR4Test.java index 2a1552f7ed9..139bf03f003 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/packages/NpmR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/packages/NpmR4Test.java @@ -158,7 +158,7 @@ public class NpmR4Test extends BaseJpaR4Test { ourLog.info("**************************************************************************"); ourLog.info("**************************************************************************"); ourLog.info("Res " + i); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(resources.get(i))); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resources.get(i))); } }); @@ -252,13 +252,13 @@ public class NpmR4Test extends BaseJpaR4Test { // Fetch resource by URL runInTransaction(() -> { IBaseResource asset = myPackageCacheManager.loadPackageAssetByUrl(FhirVersionEnum.R4, "http://hl7.org/fhir/uv/shorthand/ImplementationGuide/hl7.fhir.uv.shorthand"); - assertThat(myFhirCtx.newJsonParser().encodeResourceToString(asset), containsString("\"url\":\"http://hl7.org/fhir/uv/shorthand/ImplementationGuide/hl7.fhir.uv.shorthand\",\"version\":\"0.12.0\"")); + assertThat(myFhirContext.newJsonParser().encodeResourceToString(asset), containsString("\"url\":\"http://hl7.org/fhir/uv/shorthand/ImplementationGuide/hl7.fhir.uv.shorthand\",\"version\":\"0.12.0\"")); }); // Fetch resource by URL with version runInTransaction(() -> { IBaseResource asset = myPackageCacheManager.loadPackageAssetByUrl(FhirVersionEnum.R4, "http://hl7.org/fhir/uv/shorthand/ImplementationGuide/hl7.fhir.uv.shorthand|0.12.0"); - assertThat(myFhirCtx.newJsonParser().encodeResourceToString(asset), containsString("\"url\":\"http://hl7.org/fhir/uv/shorthand/ImplementationGuide/hl7.fhir.uv.shorthand\",\"version\":\"0.12.0\"")); + assertThat(myFhirContext.newJsonParser().encodeResourceToString(asset), containsString("\"url\":\"http://hl7.org/fhir/uv/shorthand/ImplementationGuide/hl7.fhir.uv.shorthand\",\"version\":\"0.12.0\"")); }); // Search for the installed resource @@ -322,13 +322,13 @@ public class NpmR4Test extends BaseJpaR4Test { // Fetch resource by URL runInTransaction(() -> { IBaseResource asset = myPackageCacheManager.loadPackageAssetByUrl(FhirVersionEnum.R4, "http://hl7.org/fhir/uv/shorthand/ImplementationGuide/hl7.fhir.uv.shorthand"); - assertThat(myFhirCtx.newJsonParser().encodeResourceToString(asset), containsString("\"url\":\"http://hl7.org/fhir/uv/shorthand/ImplementationGuide/hl7.fhir.uv.shorthand\",\"version\":\"0.12.0\"")); + assertThat(myFhirContext.newJsonParser().encodeResourceToString(asset), containsString("\"url\":\"http://hl7.org/fhir/uv/shorthand/ImplementationGuide/hl7.fhir.uv.shorthand\",\"version\":\"0.12.0\"")); }); // Fetch resource by URL with version runInTransaction(() -> { IBaseResource asset = myPackageCacheManager.loadPackageAssetByUrl(FhirVersionEnum.R4, "http://hl7.org/fhir/uv/shorthand/ImplementationGuide/hl7.fhir.uv.shorthand|0.12.0"); - assertThat(myFhirCtx.newJsonParser().encodeResourceToString(asset), containsString("\"url\":\"http://hl7.org/fhir/uv/shorthand/ImplementationGuide/hl7.fhir.uv.shorthand\",\"version\":\"0.12.0\"")); + assertThat(myFhirContext.newJsonParser().encodeResourceToString(asset), containsString("\"url\":\"http://hl7.org/fhir/uv/shorthand/ImplementationGuide/hl7.fhir.uv.shorthand\",\"version\":\"0.12.0\"")); }); // Search for the installed resource diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/BaseResourceProviderDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/BaseResourceProviderDstu2Test.java index 910122b49a9..05f18b151b1 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/BaseResourceProviderDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/BaseResourceProviderDstu2Test.java @@ -14,15 +14,14 @@ import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum; import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; import ca.uhn.fhir.rest.server.RestfulServer; import ca.uhn.fhir.test.utilities.JettyUtil; -import ca.uhn.fhir.util.TestUtil; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.web.context.ContextLoader; @@ -57,17 +56,17 @@ public abstract class BaseResourceProviderDstu2Test extends BaseJpaDstu2Test { @AfterEach public void after() throws Exception { - myFhirCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.ONCE); + myFhirContext.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.ONCE); } @SuppressWarnings({"unchecked", "rawtypes"}) @BeforeEach public void before() throws Exception { - myFhirCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); - myFhirCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000); + myFhirContext.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); + myFhirContext.getRestfulClientFactory().setSocketTimeout(1200 * 1000); if (ourServer == null) { - ourRestServer = new RestfulServer(myFhirCtx); + ourRestServer = new RestfulServer(myFhirContext); ourRestServer.registerProviders(myResourceProviders.createProviders()); ourRestServer.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator()); ourRestServer.registerProvider(mySystemProvider); @@ -111,7 +110,7 @@ public abstract class BaseResourceProviderDstu2Test extends BaseJpaDstu2Test { ourPort = JettyUtil.getPortForStartedServer(server); ourServerBase = "http://localhost:" + ourPort + "/fhir/context"; - ourClient = myFhirCtx.newRestfulGenericClient(ourServerBase); + ourClient = myFhirContext.newRestfulGenericClient(ourServerBase); ourClient.registerInterceptor(new LoggingInterceptor()); PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java index e1a381f8da9..10229c1cbc4 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java @@ -1,66 +1,6 @@ package ca.uhn.fhir.jpa.provider; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.hamcrest.Matchers.containsInRelativeOrder; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.empty; -import static org.hamcrest.Matchers.emptyString; -import static org.hamcrest.Matchers.endsWith; -import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.Matchers.hasItems; -import static org.hamcrest.Matchers.not; -import static org.hamcrest.Matchers.startsWith; -import static org.hamcrest.Matchers.stringContainsInOrder; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.InetSocketAddress; -import java.net.Socket; -import java.net.SocketTimeoutException; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - import ca.uhn.fhir.i18n.Msg; -import ca.uhn.fhir.model.dstu2.resource.SearchParameter; -import ca.uhn.fhir.model.dstu2.valueset.XPathUsageTypeEnum; -import ca.uhn.fhir.model.primitive.IntegerDt; -import ca.uhn.fhir.rest.gclient.NumberClientParam; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.entity.ByteArrayEntity; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.hl7.fhir.instance.model.api.IBaseResource; -import org.hl7.fhir.instance.model.api.IIdType; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.test.util.AopTestUtils; - -import com.google.common.base.Charsets; - import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.model.util.JpaConstants; import ca.uhn.fhir.jpa.search.SearchCoordinatorSvcImpl; @@ -95,6 +35,7 @@ import ca.uhn.fhir.model.dstu2.resource.Organization; import ca.uhn.fhir.model.dstu2.resource.Parameters; import ca.uhn.fhir.model.dstu2.resource.Patient; import ca.uhn.fhir.model.dstu2.resource.Practitioner; +import ca.uhn.fhir.model.dstu2.resource.SearchParameter; import ca.uhn.fhir.model.dstu2.resource.Subscription; import ca.uhn.fhir.model.dstu2.resource.ValueSet; import ca.uhn.fhir.model.dstu2.valueset.BundleTypeEnum; @@ -104,10 +45,12 @@ import ca.uhn.fhir.model.dstu2.valueset.HTTPVerbEnum; import ca.uhn.fhir.model.dstu2.valueset.SearchEntryModeEnum; import ca.uhn.fhir.model.dstu2.valueset.SubscriptionChannelTypeEnum; import ca.uhn.fhir.model.dstu2.valueset.SubscriptionStatusEnum; +import ca.uhn.fhir.model.dstu2.valueset.XPathUsageTypeEnum; import ca.uhn.fhir.model.primitive.DateDt; import ca.uhn.fhir.model.primitive.DateTimeDt; import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.model.primitive.InstantDt; +import ca.uhn.fhir.model.primitive.IntegerDt; import ca.uhn.fhir.model.primitive.StringDt; import ca.uhn.fhir.model.primitive.UnsignedIntDt; import ca.uhn.fhir.model.primitive.UriDt; @@ -116,6 +59,7 @@ import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.SummaryEnum; import ca.uhn.fhir.rest.client.api.IGenericClient; +import ca.uhn.fhir.rest.gclient.NumberClientParam; import ca.uhn.fhir.rest.param.DateRangeParam; import ca.uhn.fhir.rest.param.NumberParam; import ca.uhn.fhir.rest.param.StringAndListParam; @@ -129,6 +73,60 @@ import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; import ca.uhn.fhir.util.BundleUtil; import ca.uhn.fhir.util.StopWatch; import ca.uhn.fhir.util.UrlUtil; +import com.google.common.base.Charsets; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpDelete; +import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpPut; +import org.apache.http.entity.ByteArrayEntity; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.hl7.fhir.instance.model.api.IBaseResource; +import org.hl7.fhir.instance.model.api.IIdType; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.test.util.AopTestUtils; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.net.SocketTimeoutException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.containsInRelativeOrder; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.emptyString; +import static org.hamcrest.Matchers.endsWith; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.startsWith; +import static org.hamcrest.Matchers.stringContainsInOrder; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { @@ -226,7 +224,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { String respString = ourClient.transaction().withBundle(input).prettyPrint().execute(); ourLog.info(respString); - ca.uhn.fhir.model.dstu2.resource.Bundle bundle = myFhirCtx.newXmlParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, respString); + ca.uhn.fhir.model.dstu2.resource.Bundle bundle = myFhirContext.newXmlParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, respString); IdDt id = new IdDt(bundle.getEntry().get(0).getResponse().getLocation()); Basic basic = ourClient.read().resource(Basic.class).withId(id).execute(); @@ -245,7 +243,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { ca.uhn.fhir.model.dstu2.resource.Bundle bundle = client.read().resource(ca.uhn.fhir.model.dstu2.resource.Bundle.class).withId(id).execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); } @Test @@ -374,7 +372,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { arr[0] = 3; fromDB.setContent(arr); - String encoded = myFhirCtx.newJsonParser().encodeResourceToString(fromDB); + String encoded = myFhirContext.newJsonParser().encodeResourceToString(fromDB); putRequest = new HttpPut(ourServerBase + "/Binary/" + resource.getIdPart()); putRequest.setEntity(new StringEntity(encoded, ContentType.parse("application/json+fhir"))); resp = ourHttpClient.execute(putRequest); @@ -393,7 +391,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { arr[0] = 4; binary.setContent(arr); binary.setId(""); - encoded = myFhirCtx.newJsonParser().encodeResourceToString(binary); + encoded = myFhirContext.newJsonParser().encodeResourceToString(binary); putRequest = new HttpPut(ourServerBase + "/Binary/" + resource.getIdPart()); putRequest.setEntity(new StringEntity(encoded, ContentType.parse("application/json+fhir"))); resp = ourHttpClient.execute(putRequest); @@ -414,7 +412,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { Patient pt = new Patient(); pt.addName().addFamily(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPost post = new HttpPost(ourServerBase + "/Patient"); post.addHeader(Constants.HEADER_IF_NONE_EXIST, "Patient?name=" + methodName); @@ -448,7 +446,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { public void testCreateResourceConditionalComplex() throws IOException { Patient pt = new Patient(); pt.addIdentifier().setSystem("http://general-hospital.co.uk/Identifiers").setValue("09832345234543876876"); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPost post = new HttpPost(ourServerBase + "/Patient"); post.addHeader(Constants.HEADER_IF_NONE_EXIST, "Patient?identifier=http://general-hospital.co.uk/Identifiers|09832345234543876876"); @@ -542,7 +540,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(responseString); assertEquals(400, response.getStatusLine().getStatusCode()); - OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString); + OperationOutcome oo = myFhirContext.newXmlParser().parseResource(OperationOutcome.class, responseString); assertEquals(Msg.code(365) + "Can not create resource with ID \"2\", ID must not be supplied on a create (POST) operation (use an HTTP PUT / update operation if you wish to supply an ID)", oo.getIssue().get(0).getDiagnostics()); } finally { @@ -617,11 +615,11 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { .returnBundle(Bundle.class) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(res)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(res)); assertEquals(3, res.getEntry().size()); - assertEquals(1, BundleUtil.toListOfResourcesOfType(myFhirCtx, res, Encounter.class).size()); - assertEquals(e1id.toUnqualifiedVersionless(), BundleUtil.toListOfResourcesOfType(myFhirCtx, res, Encounter.class).get(0).getIdElement().toUnqualifiedVersionless()); + assertEquals(1, BundleUtil.toListOfResourcesOfType(myFhirContext, res, Encounter.class).size()); + assertEquals(e1id.toUnqualifiedVersionless(), BundleUtil.toListOfResourcesOfType(myFhirContext, res, Encounter.class).get(0).getIdElement().toUnqualifiedVersionless()); } @@ -703,7 +701,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { Patient pt = new Patient(); pt.addName().addFamily(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPost post = new HttpPost(ourServerBase + "/Patient"); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -747,7 +745,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { Patient pt = new Patient(); pt.addName().addFamily(methodName); pt.addIdentifier().setSystem("http://ghh.org/patient").setValue(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPost post = new HttpPost(ourServerBase + "/Patient"); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -841,8 +839,8 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { */ @Test public void testDocumentManifestResources() throws Exception { - myFhirCtx.getResourceDefinition(Practitioner.class); - myFhirCtx.getResourceDefinition(DocumentManifest.class); + myFhirContext.getResourceDefinition(Practitioner.class); + myFhirContext.getResourceDefinition(DocumentManifest.class); IGenericClient client = ourClient; @@ -1088,7 +1086,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { @Test public void testEverythingPatientDoesntRepeatPatient() { ca.uhn.fhir.model.dstu2.resource.Bundle b; - b = myFhirCtx.newJsonParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, new InputStreamReader(ResourceProviderDstu2Test.class.getResourceAsStream("/bug147-bundle.json"))); + b = myFhirContext.newJsonParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, new InputStreamReader(ResourceProviderDstu2Test.class.getResourceAsStream("/bug147-bundle.json"))); ca.uhn.fhir.model.dstu2.resource.Bundle resp = ourClient.transaction().withBundle(b).execute(); List ids = new ArrayList(); @@ -1184,7 +1182,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { ca.uhn.fhir.model.dstu2.resource.Bundle resp = ourClient.transaction().withBundle(b).execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); IdDt patientId = new IdDt(resp.getEntry().get(0).getResponse().getLocation()); assertEquals("Patient", patientId.getResourceType()); @@ -1324,7 +1322,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); IOUtils.closeQuietly(response.getEntity().getContent()); ourLog.info(output); - List ids = toIdListUnqualifiedVersionless(myFhirCtx.newXmlParser().parseResource(Bundle.class, output)); + List ids = toIdListUnqualifiedVersionless(myFhirContext.newXmlParser().parseResource(Bundle.class, output)); ourLog.info(ids.toString()); assertThat(ids, containsInAnyOrder(pId, cId, oId)); } finally { @@ -1339,7 +1337,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); IOUtils.closeQuietly(response.getEntity().getContent()); ourLog.info(output); - List ids = toIdListUnqualifiedVersionless(myFhirCtx.newXmlParser().parseResource(Bundle.class, output)); + List ids = toIdListUnqualifiedVersionless(myFhirContext.newXmlParser().parseResource(Bundle.class, output)); ourLog.info(ids.toString()); assertThat(ids, containsInAnyOrder(pId, cId, oId)); } finally { @@ -2100,7 +2098,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); IOUtils.closeQuietly(response.getEntity().getContent()); ourLog.info(resp); - ca.uhn.fhir.model.dstu2.resource.Bundle bundle = myFhirCtx.newXmlParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, resp); + ca.uhn.fhir.model.dstu2.resource.Bundle bundle = myFhirContext.newXmlParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, resp); matches = bundle.getEntry().size(); assertThat(matches, greaterThan(0)); @@ -2214,7 +2212,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { oid1 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -2226,7 +2224,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { oid2 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -2238,7 +2236,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { oid3 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -2250,7 +2248,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { oid4 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } String uri = ourServerBase + "/Observation?_sort=code-value-quantity"; @@ -2259,10 +2257,10 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { HttpGet get = new HttpGet(uri); try (CloseableHttpResponse resp = ourHttpClient.execute(get)) { String output = IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8); - found = myFhirCtx.newXmlParser().parseResource(Bundle.class, output); + found = myFhirContext.newXmlParser().parseResource(Bundle.class, output); } - ourLog.info("Bundle: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(found)); + ourLog.info("Bundle: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(found)); List list = toUnqualifiedVersionlessIds(found); assertEquals(4, found.getEntry().size()); @@ -2526,14 +2524,14 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { // Read back directly from the DAO { Organization returned = myOrganizationDao.read(orgId, mySrd); - String val = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned); + String val = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned); ourLog.info(val); assertThat(val, containsString("")); } // Read back through the HTTP API { Organization returned = ourClient.read(Organization.class, orgId); - String val = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned); + String val = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned); ourLog.info(val); assertThat(val, containsString("")); } @@ -2576,7 +2574,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { Patient pt = new Patient(); pt.addName().addFamily(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPut post = new HttpPut(ourServerBase + "/Patient"); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -2585,7 +2583,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(responseString); assertEquals(400, response.getStatusLine().getStatusCode()); - OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString); + OperationOutcome oo = myFhirContext.newXmlParser().parseResource(OperationOutcome.class, responseString); assertThat(oo.getIssue().get(0).getDiagnostics(), containsString("Can not update resource, request URL must contain an ID element for update (PUT) operation (it must be of the form [base]/[resource type]/[id])")); } finally { response.close(); @@ -2624,7 +2622,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { Patient pt = new Patient(); pt.addName().addFamily(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPost post = new HttpPost(ourServerBase + "/Patient?name=" + methodName); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -2640,7 +2638,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { } pt.addName().addFamily(methodName + "2"); - resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPut put = new HttpPut(ourServerBase + "/Patient?name=" + methodName); put.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); response = ourHttpClient.execute(put); @@ -2659,7 +2657,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { public void testUpdateResourceConditionalComplex() throws IOException { Patient pt = new Patient(); pt.addIdentifier().setSystem("http://general-hospital.co.uk/Identifiers").setValue("09832345234543876876"); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPost post = new HttpPost(ourServerBase + "/Patient"); post.addHeader(Constants.HEADER_IF_NONE_EXIST, "Patient?identifier=http://general-hospital.co.uk/Identifiers|09832345234543876876"); @@ -2677,7 +2675,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { } pt.addName().addFamily("FOO"); - resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPut put = new HttpPut(ourServerBase + "/Patient?identifier=" + ("http://general-hospital.co.uk/Identifiers|09832345234543876876".replace("|", UrlUtil.escapeUrlParam("|")))); put.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -2703,7 +2701,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { Patient pt = new Patient(); pt.addName().addFamily(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPost post = new HttpPost(ourServerBase + "/Patient"); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -2723,7 +2721,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { pt.setId(id); pt.addAddress().addLine("AAAAAAAAAAAAAAAAAAAAAA"); - resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPut put = new HttpPut(ourServerBase + "/Patient/" + id.getIdPart()); put.addHeader(Constants.HEADER_PREFER, Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_REPRESENTATION); @@ -2734,7 +2732,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); IOUtils.closeQuietly(response.getEntity().getContent()); - Patient respPt = myFhirCtx.newXmlParser().parseResource(Patient.class, responseString); + Patient respPt = myFhirContext.newXmlParser().parseResource(Patient.class, responseString); assertEquals("2", respPt.getId().getVersionIdPart()); InstantDt updateTime = ResourceMetadataKeyEnum.UPDATED.get(respPt); @@ -2839,7 +2837,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { String input = "{\"resourceType\":\"Parameters\",\"parameter\":[{\"name\":\"mode\",\"valueString\":\"create\"},{\"name\":\"resource\",\"resource\":{\"resourceType\":\"QuestionnaireResponse\",\"questionnaire\":{\"reference\":\"http://fhirtest.uhn.ca/baseDstu2/Questionnaire/MedsCheckEligibility\"},\"text\":{\"status\":\"generated\",\"div\":\"
!-- populated from the rendered HTML below -->
\"},\"status\":\"completed\",\"authored\":\"2017-02-10T00:02:58.098Z\",\"group\":{\"question\":[{\"linkId\":\"d94b4f57-1ca0-4d65-acba-8bd9a3926c8c\",\"answer\":[{\"valueBoolean\":false}],\"text\":\"The patient has a valid Medicare or DVA entitlement card\"},{\"linkId\":\"0cbe66db-ff12-473a-940e-4672fb82de44\",\"answer\":[{\"valueBoolean\":false}],\"text\":\"The patient has received a MedsCheck, Diabetes MedsCheck, Home Medicines Review (HMR) otr Restidential Medication Management Review (RMMR) in the past 12 months\"},{\"linkId\":\"35790cfd-2d98-4721-963e-9663e1897a17\",\"answer\":[{\"valueBoolean\":false}],\"text\":\"The patient is living at home in a community setting\"},{\"linkId\":\"3ccc8304-76cd-41ff-9360-2c8755590bae\",\"answer\":[{\"valueBoolean\":false}],\"text\":\"The patient has been recently diagnosed with type 3 diabetes (in the last 12 months) AND is unable to gain timely access to existing diabetes education or health services in the community OR \"},{\"linkId\":\"b05f6f09-49ec-40f9-a889-9a3fdff9e0da\",\"answer\":[{\"valueBoolean\":false}],\"text\":\"The patient has type 2 diabetes , is less than ideally controlled AND is unable to gain timely access to existing diabetes education or health services in their community \"},{\"linkId\":\"4a777f56-800d-4e0b-a9c3-e929832adb5b\",\"answer\":[{\"valueBoolean\":false,\"group\":[{\"linkId\":\"95bbc904-149e-427f-88a4-7f6c8ab186fa\",\"question\":[{\"linkId\":\"f0acea9e-716c-4fce-b7a2-aad59de9d136\",\"answer\":[{\"valueBoolean\":false}],\"text\":\"Patient has had an Acute or Adverse Event\"},{\"linkId\":\"e1629159-6dea-4295-a93e-e7c2829ce180\",\"answer\":[{\"valueBoolean\":false}],\"text\":\"Exacerbation of a Chronic Disease or Condition\"},{\"linkId\":\"2ce526fa-edaa-44b3-8d5a-6e97f6379ce8\",\"answer\":[{\"valueBoolean\":false}],\"text\":\"New Diagnosis\"},{\"linkId\":\"9d6ffa9f-0110-418c-9ed0-f04910fda2ed\",\"answer\":[{\"valueBoolean\":false}],\"text\":\"Recent hospital admission (<3 months)\"},{\"linkId\":\"d2803ff7-25f7-4c7b-ab92-356c49910478\",\"answer\":[{\"valueBoolean\":false}],\"text\":\"Major change to regular medication regime\"},{\"linkId\":\"b34af32d-c69d-4d44-889f-5b6d420a7d08\",\"answer\":[{\"valueBoolean\":false}],\"text\":\"Suspected non-adherence to the patient's medication regime \"},{\"linkId\":\"74bad553-c273-41e6-8647-22b860430bc2\",\"answer\":[],\"text\":\"Other\"}]}]}],\"text\":\"The patient has experienced one or more of the following recent significant medical events\"},{\"linkId\":\"ecbf4e5a-d4d1-43eb-9f43-0c0e35fc09c7\",\"answer\":[{\"valueBoolean\":false}],\"text\":\"The Pharmacist has obtained patient consent to take part in the MedsCheck Service or Diabetes MedsCheck Service  and share information obtained during the services with other nominated members of the patients healthcare team (such as their GP, diabetes educator) if required\"},{\"linkId\":\"8ef66774-43b0-4190-873f-cfbb6e980aa9\",\"answer\":[],\"text\":\"Question\"}]}}}]}"; - IParser p = myFhirCtx.newJsonParser().setPrettyPrint(true); + IParser p = myFhirContext.newJsonParser().setPrettyPrint(true); ourLog.info(p.encodeResourceToString(p.parseResource(input))); @@ -2887,7 +2885,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { Parameters input = new Parameters(); input.addParameter().setName("resource").setResource(patient); - String inputStr = myFhirCtx.newXmlParser().encodeResourceToString(input); + String inputStr = myFhirContext.newXmlParser().encodeResourceToString(input); ourLog.info(inputStr); HttpPost post = new HttpPost(ourServerBase + "/Patient/$validate?_pretty=true"); @@ -2915,7 +2913,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { Parameters input = new Parameters(); input.addParameter().setName("resource").setResource(patient); - String inputStr = myFhirCtx.newXmlParser().encodeResourceToString(input); + String inputStr = myFhirContext.newXmlParser().encodeResourceToString(input); // ourLog.info(inputStr); HttpPost post = new HttpPost(ourServerBase + "/Patient/$validate"); @@ -2942,7 +2940,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { Parameters input = new Parameters(); input.addParameter().setName("resource").setResource(patient); - String inputStr = myFhirCtx.newXmlParser().encodeResourceToString(input); + String inputStr = myFhirContext.newXmlParser().encodeResourceToString(input); ourLog.info(inputStr); HttpPost post = new HttpPost(ourServerBase + "/Patient/$validate"); @@ -2962,7 +2960,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test { @Test public void testValueSetExpandOperation() throws IOException { - ValueSet upload = myFhirCtx.newXmlParser().parseResource(ValueSet.class, new InputStreamReader(ResourceProviderDstu2Test.class.getResourceAsStream("/extensional-case-2.xml"))); + ValueSet upload = myFhirContext.newXmlParser().parseResource(ValueSet.class, new InputStreamReader(ResourceProviderDstu2Test.class.getResourceAsStream("/extensional-case-2.xml"))); IIdType vsid = ourClient.create().resource(upload).execute().getId().toUnqualifiedVersionless(); HttpGet get = new HttpGet(ourServerBase + "/ValueSet/" + vsid.getIdPart() + "/$expand"); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2ValueSetTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2ValueSetTest.java index 23b42956232..bb7c4041c71 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2ValueSetTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2ValueSetTest.java @@ -48,7 +48,7 @@ public class ResourceProviderDstu2ValueSetTest extends BaseResourceProviderDstu2 .andParameter("system", new UriDt("http://loinc.org")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(new BooleanDt(true), respParam.getParameter().get(0).getValue()); @@ -64,7 +64,7 @@ public class ResourceProviderDstu2ValueSetTest extends BaseResourceProviderDstu2 .andParameter("system", new UriDt("http://loinc.org")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -86,7 +86,7 @@ public class ResourceProviderDstu2ValueSetTest extends BaseResourceProviderDstu2 .andParameter("system", new UriDt("http://hl7.org/fhir/v3/MaritalStatus")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -106,7 +106,7 @@ public class ResourceProviderDstu2ValueSetTest extends BaseResourceProviderDstu2 .withParameter(Parameters.class, "coding", new CodingDt("http://loinc.org", "8450-9")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -175,7 +175,7 @@ public class ResourceProviderDstu2ValueSetTest extends BaseResourceProviderDstu2 .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder("", @@ -206,7 +206,7 @@ public class ResourceProviderDstu2ValueSetTest extends BaseResourceProviderDstu2 expanded = (ValueSet) respParam.getParameter().get(0).getResource(); expanded = myValueSetDao.expand(myExtensionalVsId, new ValueSetExpansionOptions().setFilter("systolic"), mySrd); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -223,7 +223,7 @@ public class ResourceProviderDstu2ValueSetTest extends BaseResourceProviderDstu2 .withParameter(Parameters.class, "filter", new StringDt("11378")) .execute(); expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -241,7 +241,7 @@ public class ResourceProviderDstu2ValueSetTest extends BaseResourceProviderDstu2 .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -263,7 +263,7 @@ public class ResourceProviderDstu2ValueSetTest extends BaseResourceProviderDstu2 .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SubscriptionsDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SubscriptionsDstu2Test.java index 7346093a0ef..0a3290bedcb 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SubscriptionsDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SubscriptionsDstu2Test.java @@ -7,7 +7,6 @@ import ca.uhn.fhir.model.dstu2.valueset.SubscriptionChannelTypeEnum; import ca.uhn.fhir.model.dstu2.valueset.SubscriptionStatusEnum; import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; -import ca.uhn.fhir.util.TestUtil; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; @@ -15,7 +14,6 @@ import org.eclipse.jetty.websocket.api.annotations.WebSocket; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -24,8 +22,8 @@ import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.in; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class SubscriptionsDstu2Test extends BaseResourceProviderDstu2Test { @@ -264,7 +262,7 @@ public class SubscriptionsDstu2Test extends BaseResourceProviderDstu2Test { myPingCount++; } else if (myGotBound && theMsg.startsWith("add " + mySubsId + "\n")) { String text = theMsg.substring(("add " + mySubsId + "\n").length()); - IBaseResource res = myEncoding.newParser(myFhirCtx).parseResource(text); + IBaseResource res = myEncoding.newParser(myFhirContext).parseResource(text); myReceived.add(res); myPingCount++; } else { diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderDstu2Test.java index f9792f9a435..03d5094e221 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderDstu2Test.java @@ -217,7 +217,7 @@ public class SystemProviderDstu2Test extends BaseJpaDstu2Test { for (int i = 0; i < 10; i++) { ourLog.info("** Beginning pass {}", i); - Bundle input = myFhirCtx.newJsonParser().parseResource(Bundle.class, IOUtils.toString(getClass().getResourceAsStream("/dstu2/createdeletebundle.json"), Charsets.UTF_8)); + Bundle input = myFhirContext.newJsonParser().parseResource(Bundle.class, IOUtils.toString(getClass().getResourceAsStream("/dstu2/createdeletebundle.json"), Charsets.UTF_8)); ourClient.transaction().withBundle(input).execute(); myPatientDao.read(new IdType("Patient/Patient1063259")); @@ -243,7 +243,7 @@ public class SystemProviderDstu2Test extends BaseJpaDstu2Test { } private void deleteAllOfType(String theType) { - BundleUtil.toListOfResources(myFhirCtx, ourClient.search().forResource(theType).execute()) + BundleUtil.toListOfResources(myFhirContext, ourClient.search().forResource(theType).execute()) .forEach(t -> { ourClient.delete().resourceById(t.getIdElement()).execute(); }); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderTransactionSearchDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderTransactionSearchDstu2Test.java index cc5b8b1f60c..69265c9b997 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderTransactionSearchDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderTransactionSearchDstu2Test.java @@ -130,7 +130,7 @@ public class SystemProviderTransactionSearchDstu2Test extends BaseJpaDstu2Test { myDaoConfig.setMaximumSearchResultCountInTransaction(100); Bundle output = myClient.transaction().withBundle(input).execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); assertEquals(1, output.getEntry().size()); Bundle respBundle = (Bundle) output.getEntry().get(0).getResource(); @@ -153,7 +153,7 @@ public class SystemProviderTransactionSearchDstu2Test extends BaseJpaDstu2Test { .setUrl("Patient?_count=5&_sort=name"); Bundle output = myClient.transaction().withBundle(input).execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); assertEquals(1, output.getEntry().size()); Bundle respBundle = (Bundle) output.getEntry().get(0).getResource(); @@ -188,7 +188,7 @@ public class SystemProviderTransactionSearchDstu2Test extends BaseJpaDstu2Test { } Bundle output = myClient.transaction().withBundle(input).execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); assertEquals(30, output.getEntry().size()); for (int i = 0; i < 30; i++) { @@ -215,7 +215,7 @@ public class SystemProviderTransactionSearchDstu2Test extends BaseJpaDstu2Test { myDaoConfig.setMaximumSearchResultCountInTransaction(100); Bundle output = myClient.transaction().withBundle(input).execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); assertEquals(1, output.getEntry().size()); Bundle respBundle = (Bundle) output.getEntry().get(0).getResource(); @@ -238,7 +238,7 @@ public class SystemProviderTransactionSearchDstu2Test extends BaseJpaDstu2Test { .setUrl("Patient?_count=5&_sort=name"); Bundle output = myClient.transaction().withBundle(input).execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); assertEquals(1, output.getEntry().size()); Bundle respBundle = (Bundle) output.getEntry().get(0).getResource(); @@ -273,7 +273,7 @@ public class SystemProviderTransactionSearchDstu2Test extends BaseJpaDstu2Test { } Bundle output = myClient.transaction().withBundle(input).execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); assertEquals(30, output.getEntry().size()); for (int i = 0; i < 30; i++) { diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/BaseResourceProviderDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/BaseResourceProviderDstu3Test.java index a0022861e0c..7ff8323b4c8 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/BaseResourceProviderDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/BaseResourceProviderDstu3Test.java @@ -30,8 +30,8 @@ import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; import org.hl7.fhir.dstu3.model.Parameters; import org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent; import org.hl7.fhir.dstu3.model.Patient; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.springframework.web.context.ContextLoader; import org.springframework.web.context.WebApplicationContext; @@ -70,7 +70,7 @@ public abstract class BaseResourceProviderDstu3Test extends BaseJpaDstu3Test { @AfterEach public void after() throws Exception { - myFhirCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.ONCE); + myFhirContext.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.ONCE); myResourceCountsCache.clear(); ourRestServer.getInterceptorService().unregisterAllInterceptors(); } @@ -79,12 +79,12 @@ public abstract class BaseResourceProviderDstu3Test extends BaseJpaDstu3Test { @BeforeEach public void before() throws Exception { myResourceCountsCache.clear(); - myFhirCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); - myFhirCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000); - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); + myFhirContext.getRestfulClientFactory().setSocketTimeout(1200 * 1000); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); if (ourServer == null) { - ourRestServer = new RestfulServer(myFhirCtx); + ourRestServer = new RestfulServer(myFhirContext); ourRestServer.registerProviders(myResourceProviders.createProviders()); ourRestServer.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator()); ourRestServer.setDefaultResponseEncoding(EncodingEnum.XML); @@ -159,8 +159,8 @@ public abstract class BaseResourceProviderDstu3Test extends BaseJpaDstu3Test { confProvider.setSearchParamRegistry(ourSearchParamRegistry); - myFhirCtx.getRestfulClientFactory().setSocketTimeout(5000000); - ourClient = myFhirCtx.newRestfulGenericClient(ourServerBase); + myFhirContext.getRestfulClientFactory().setSocketTimeout(5000000); + ourClient = myFhirContext.newRestfulGenericClient(ourServerBase); if (shouldLogClient()) { ourClient.registerInterceptor(new LoggingInterceptor()); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/CompositionDocumentDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/CompositionDocumentDstu3Test.java index bdcae4098ee..f2b7d9676e4 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/CompositionDocumentDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/CompositionDocumentDstu3Test.java @@ -3,7 +3,6 @@ package ca.uhn.fhir.jpa.provider.dstu3; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.parser.StrictErrorHandler; import ca.uhn.fhir.rest.api.EncodingEnum; -import ca.uhn.fhir.util.TestUtil; import com.google.common.base.Charsets; import org.apache.commons.io.IOUtils; import org.apache.http.client.ClientProtocolException; @@ -20,10 +19,9 @@ import org.hl7.fhir.dstu3.model.Observation.ObservationStatus; import org.hl7.fhir.dstu3.model.Organization; import org.hl7.fhir.dstu3.model.Patient; import org.hl7.fhir.dstu3.model.Reference; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.ArrayList; @@ -65,7 +63,7 @@ public class CompositionDocumentDstu3Test extends BaseResourceProviderDstu3Test @BeforeEach public void before() throws Exception { super.before(); - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); myDaoConfig.setAllowMultipleDelete(true); @@ -146,7 +144,7 @@ public class CompositionDocumentDstu3Test extends BaseResourceProviderDstu3Test try (CloseableHttpResponse resp = ourHttpClient.execute(get)) { String resourceString = IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8); - bundle = theEncoding.newParser(myFhirCtx).parseResource(Bundle.class, resourceString); + bundle = theEncoding.newParser(myFhirContext).parseResource(Bundle.class, resourceString); } return bundle; } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/PatientEverythingDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/PatientEverythingDstu3Test.java index 3fe6ec041d1..c6d78c2519d 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/PatientEverythingDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/PatientEverythingDstu3Test.java @@ -3,7 +3,6 @@ package ca.uhn.fhir.jpa.provider.dstu3; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.parser.StrictErrorHandler; import ca.uhn.fhir.rest.api.EncodingEnum; -import ca.uhn.fhir.util.TestUtil; import com.google.common.base.Charsets; import org.apache.commons.io.IOUtils; import org.apache.http.client.ClientProtocolException; @@ -18,7 +17,6 @@ import org.hl7.fhir.dstu3.model.Observation.ObservationStatus; import org.hl7.fhir.dstu3.model.Organization; import org.hl7.fhir.dstu3.model.Patient; import org.hl7.fhir.dstu3.model.Reference; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -68,7 +66,7 @@ public class PatientEverythingDstu3Test extends BaseResourceProviderDstu3Test { @Override public void before() throws Exception { super.before(); - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); myDaoConfig.setAllowMultipleDelete(true); @@ -247,7 +245,7 @@ public class PatientEverythingDstu3Test extends BaseResourceProviderDstu3Test { CloseableHttpResponse resp = ourHttpClient.execute(get); try { assertEquals(theEncoding.getResourceContentTypeNonLegacy(), resp.getFirstHeader(ca.uhn.fhir.rest.api.Constants.HEADER_CONTENT_TYPE).getValue().replaceAll(";.*", "")); - bundle = theEncoding.newParser(myFhirCtx).parseResource(Bundle.class, IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8)); + bundle = theEncoding.newParser(myFhirContext).parseResource(Bundle.class, IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8)); } finally { IOUtils.closeQuietly(resp); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderCustomSearchParamDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderCustomSearchParamDstu3Test.java index 9f558b26e29..3d163b92496 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderCustomSearchParamDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderCustomSearchParamDstu3Test.java @@ -11,7 +11,6 @@ import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.gclient.ReferenceClientParam; import ca.uhn.fhir.rest.gclient.TokenClientParam; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; -import ca.uhn.fhir.util.TestUtil; import org.apache.commons.io.IOUtils; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; @@ -31,7 +30,6 @@ import org.hl7.fhir.dstu3.model.Reference; import org.hl7.fhir.dstu3.model.SearchParameter; import org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType; import org.hl7.fhir.instance.model.api.IIdType; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -264,7 +262,7 @@ public class ResourceProviderCustomSearchParamDstu3Test extends BaseResourceProv eyeColourSp.setXpathUsage(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.NORMAL); eyeColourSp.setStatus(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(eyeColourSp)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(eyeColourSp)); ourClient .create() @@ -278,7 +276,7 @@ public class ResourceProviderCustomSearchParamDstu3Test extends BaseResourceProv p1.addExtension().setUrl("http://acme.org/eyecolour").setValue(new CodeType("blue")); IIdType p1id = myPatientDao.create(p1).getId().toUnqualifiedVersionless(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p1)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(p1)); Patient p2 = new Patient(); p2.setActive(true); @@ -292,7 +290,7 @@ public class ResourceProviderCustomSearchParamDstu3Test extends BaseResourceProv .returnBundle(Bundle.class) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); List foundResources = toUnqualifiedVersionlessIdValues(bundle); assertThat(foundResources, contains(p1id.getValue())); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3CodeSystemTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3CodeSystemTest.java index ce62ab38a9b..d4e25ba4757 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3CodeSystemTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3CodeSystemTest.java @@ -64,7 +64,7 @@ public class ResourceProviderDstu3CodeSystemTest extends BaseResourceProviderDst .andParameter("system", new UriType(FhirResourceDaoDstu3TerminologyTest.URL_MY_CODE_SYSTEM)) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -86,7 +86,7 @@ public class ResourceProviderDstu3CodeSystemTest extends BaseResourceProviderDst .useHttpGet() .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -130,7 +130,7 @@ public class ResourceProviderDstu3CodeSystemTest extends BaseResourceProviderDst "}"; // Create the code system - CodeSystem cs = (CodeSystem) myFhirCtx.newJsonParser().parseResource(input); + CodeSystem cs = (CodeSystem) myFhirContext.newJsonParser().parseResource(input); ourClient.update().resource(cs).execute(); runInTransaction(() -> assertEquals(26L, myConceptDao.count())); @@ -156,7 +156,7 @@ public class ResourceProviderDstu3CodeSystemTest extends BaseResourceProviderDst .andParameter("system", new UriType("http://hl7.org/fhir/v2/0203")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -197,7 +197,7 @@ public class ResourceProviderDstu3CodeSystemTest extends BaseResourceProviderDst .andParameter("system", new UriType("http://acme.org")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -235,7 +235,7 @@ public class ResourceProviderDstu3CodeSystemTest extends BaseResourceProviderDst .withParameter(Parameters.class, "coding", new Coding().setSystem("http://acme.org").setCode("8450-9")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -310,7 +310,7 @@ public class ResourceProviderDstu3CodeSystemTest extends BaseResourceProviderDst .andParameter("system", new UriType("http://hl7.org/fhir/v3/MaritalStatus")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3CodeSystemVersionedTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3CodeSystemVersionedTest.java index 5d3e420b12f..e0a3c196c8d 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3CodeSystemVersionedTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3CodeSystemVersionedTest.java @@ -101,7 +101,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("system", new UriType(FhirResourceDaoDstu3TerminologyTest.URL_MY_CODE_SYSTEM)) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -123,7 +123,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .useHttpGet() .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -145,7 +145,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("version", new StringType("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -168,7 +168,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .useHttpGet() .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -190,7 +190,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("version", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -213,7 +213,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .useHttpGet() .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -237,7 +237,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("system", new UriType("http://acme.org")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -259,7 +259,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("version", new StringType("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -281,7 +281,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("version", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -321,7 +321,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .withParameter(Parameters.class, "coding", new Coding().setSystem("http://acme.org").setCode("8450-9")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -341,7 +341,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .withParameter(Parameters.class, "coding", new Coding().setSystem("http://acme.org").setCode("8450-9").setVersion("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -361,7 +361,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .withParameter(Parameters.class, "coding", new Coding().setSystem("http://acme.org").setCode("8450-9").setVersion("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -386,7 +386,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("system", new UriType("http://hl7.org/fhir/v2/0243")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -406,7 +406,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("version", new StringType("2.8.2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -429,7 +429,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("system", new UriType(SYSTEM_PARENTCHILD)) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -447,7 +447,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("version", new StringType("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -465,7 +465,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("version", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -486,7 +486,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("system", new UriType(SYSTEM_PARENTCHILD)) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -504,7 +504,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("version", new StringType("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -522,7 +522,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("version", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -542,7 +542,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("system", new UriType(SYSTEM_PARENTCHILD)) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -560,7 +560,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("version", new StringType("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -578,7 +578,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("version", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -615,7 +615,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("codingB", new Coding().setSystem(SYSTEM_PARENTCHILD).setCode("ParentB")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -631,7 +631,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("codingB", new Coding().setSystem(SYSTEM_PARENTCHILD).setCode("ParentC").setVersion("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -647,7 +647,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("codingB", new Coding().setSystem(SYSTEM_PARENTCHILD).setCode("ParentB").setVersion("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -668,7 +668,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("codingB", new Coding().setSystem(SYSTEM_PARENTCHILD).setCode("ParentA")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -684,7 +684,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("codingB", new Coding().setSystem(SYSTEM_PARENTCHILD).setCode("ParentA").setVersion("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -700,7 +700,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("codingB", new Coding().setSystem(SYSTEM_PARENTCHILD).setCode("ParentA").setVersion("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -720,7 +720,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("codingB", new Coding().setSystem(SYSTEM_PARENTCHILD).setCode("ParentC")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -736,7 +736,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("codingB", new Coding().setSystem(SYSTEM_PARENTCHILD).setCode("ParentB").setVersion("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -752,7 +752,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr .andParameter("codingB", new Coding().setSystem(SYSTEM_PARENTCHILD).setCode("ParentC").setVersion("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -767,7 +767,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr CodeSystem initialCodeSystem = ourClient.read().resource(CodeSystem.class).withId(parentChildCs1Id).execute(); assertEquals("Parent Child CodeSystem 1", initialCodeSystem.getName()); initialCodeSystem.setName("Updated Parent Child CodeSystem 1"); - String encoded = myFhirCtx.newJsonParser().encodeResourceToString(initialCodeSystem); + String encoded = myFhirContext.newJsonParser().encodeResourceToString(initialCodeSystem); HttpPut putRequest = new HttpPut(ourServerBase + "/CodeSystem/" + parentChildCs1Id); putRequest.setEntity(new StringEntity(encoded, ContentType.parse("application/json+fhir"))); CloseableHttpResponse resp = ourHttpClient.execute(putRequest); @@ -783,7 +783,7 @@ public class ResourceProviderDstu3CodeSystemVersionedTest extends BaseResourcePr initialCodeSystem = ourClient.read().resource(CodeSystem.class).withId(parentChildCs2Id).execute(); assertEquals("Parent Child CodeSystem 2", initialCodeSystem.getName()); initialCodeSystem.setName("Updated Parent Child CodeSystem 2"); - encoded = myFhirCtx.newJsonParser().encodeResourceToString(initialCodeSystem); + encoded = myFhirContext.newJsonParser().encodeResourceToString(initialCodeSystem); putRequest = new HttpPut(ourServerBase + "/CodeSystem/" + parentChildCs2Id); putRequest.setEntity(new StringEntity(encoded, ContentType.parse("application/json+fhir"))); resp = ourHttpClient.execute(putRequest); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ConceptMapTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ConceptMapTest.java index 0f1cd25e2c5..d2c784cc5fe 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ConceptMapTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ConceptMapTest.java @@ -1,10 +1,6 @@ package ca.uhn.fhir.jpa.provider.dstu3; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - +import ca.uhn.fhir.rest.api.MethodOutcome; import org.hl7.fhir.dstu3.model.BooleanType; import org.hl7.fhir.dstu3.model.CodeType; import org.hl7.fhir.dstu3.model.Coding; @@ -24,7 +20,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.transaction.annotation.Transactional; -import ca.uhn.fhir.rest.api.MethodOutcome; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDstu3Test { private static final Logger ourLog = LoggerFactory.getLogger(ResourceProviderDstu3ConceptMapTest.class); @@ -73,14 +72,14 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst public void testTranslateByCodeSystemsAndSourceCodeOneToMany() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); Parameters inParams = new Parameters(); inParams.addParameter().setName("system").setValue(new UriType(CS_URL)); inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_3)); inParams.addParameter().setName("code").setValue(new CodeType("12345")); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = ourClient .operation() @@ -89,7 +88,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -141,7 +140,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2)); inParams.addParameter().setName("code").setValue(new CodeType("11111")); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = ourClient .operation() @@ -150,7 +149,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -189,7 +188,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2)); inParams.addParameter().setName("code").setValue(new CodeType("11111")); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = ourClient .operation() @@ -198,7 +197,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); // Should return v2 since v2 specified. ParametersParameterComponent param = getParameterByName(respParams, "result"); @@ -239,7 +238,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2)); inParams.addParameter().setName("code").setValue(new CodeType("11111")); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = ourClient .operation() @@ -248,7 +247,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); // Should return v1 since v1 specified. ParametersParameterComponent param = getParameterByName(respParams, "result"); @@ -288,7 +287,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2)); inParams.addParameter().setName("code").setValue(new CodeType("11111")); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = ourClient .operation() @@ -297,7 +296,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); // Should return v2 since v2 is the most recently updated version. ParametersParameterComponent param = getParameterByName(respParams, "result"); @@ -336,7 +335,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2)); inParams.addParameter().setName("code").setValue(new CodeType("11111")); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = ourClient .operation() @@ -345,7 +344,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); // Should return v2 since v2 is the most recently updated version. ParametersParameterComponent param = getParameterByName(respParams, "result"); @@ -384,7 +383,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2)); inParams.addParameter().setName("code").setValue(new CodeType("11111")); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = ourClient .operation() @@ -393,7 +392,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); // Should return v2 since v2 is the most recently updated version. ParametersParameterComponent param = getParameterByName(respParams, "result"); @@ -431,7 +430,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2)); inParams.addParameter().setName("code").setValue(new CodeType("11111")); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = ourClient .operation() @@ -440,7 +439,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertFalse(((BooleanType) param.getValue()).booleanValue()); @@ -463,7 +462,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst inParams.addParameter().setName("code").setValue(new CodeType("11111")); inParams.addParameter().setName("reverse").setValue(new BooleanType(true)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = ourClient @@ -473,7 +472,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); @@ -508,7 +507,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst inParams.addParameter().setName("code").setValue(new CodeType("11111")); inParams.addParameter().setName("reverse").setValue(new BooleanType(true)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = ourClient @@ -518,7 +517,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); @@ -553,7 +552,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst inParams.addParameter().setName("code").setValue(new CodeType("11111")); inParams.addParameter().setName("reverse").setValue(new BooleanType(true)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = ourClient @@ -563,7 +562,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); @@ -598,7 +597,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst inParams.addParameter().setName("code").setValue(new CodeType("11111")); inParams.addParameter().setName("reverse").setValue(new BooleanType(true)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = ourClient @@ -608,7 +607,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); @@ -648,7 +647,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst IIdType conceptMapId = myConceptMapDao.create(conceptMap, mySrd).getId().toUnqualifiedVersionless(); conceptMap = myConceptMapDao.read(conceptMapId); - ourLog.info("ConceptMap: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); } private void createReverseConceptMap(String url, String version, String sourceCode, String sourceDisplay) { @@ -669,7 +668,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst IIdType conceptMapId = myConceptMapDao.create(conceptMap, mySrd).getId().toUnqualifiedVersionless(); ConceptMap conceptMap1 = myConceptMapDao.read(conceptMapId); - ourLog.info("ConceptMap : \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap1)); + ourLog.info("ConceptMap : \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap1)); } } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java index d83c1126549..148b17b0be8 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java @@ -152,7 +152,22 @@ import java.util.stream.Collectors; import static org.apache.commons.lang3.StringUtils.isNotBlank; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.containsInRelativeOrder; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.emptyString; +import static org.hamcrest.Matchers.endsWith; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.lessThanOrEqualTo; +import static org.hamcrest.Matchers.matchesPattern; +import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.startsWith; +import static org.hamcrest.Matchers.stringContainsInOrder; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; @@ -332,7 +347,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { @Override public void before() throws Exception { super.before(); - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); myDaoConfig.setAllowMultipleDelete(true); @@ -368,7 +383,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { String respString = ourClient.transaction().withBundle(input).prettyPrint().execute(); ourLog.info(respString); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, respString); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, respString); IdType id = new IdType(bundle.getEntry().get(0).getResponse().getLocation()); Basic basic = ourClient.read().resource(Basic.class).withId(id).execute(); @@ -384,7 +399,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { try { String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(resp); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, resp); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, resp); ids = toUnqualifiedIdValues(bundle); } finally { IOUtils.closeQuietly(response); @@ -400,7 +415,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { try { String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(resp); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, resp); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, resp); ids = toUnqualifiedVersionlessIdValues(bundle); } finally { IOUtils.closeQuietly(response); @@ -420,7 +435,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { Bundle bundle = client.read().resource(Bundle.class).withId(id).execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); } @Test @@ -626,7 +641,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { arr[0] = 3; fromDB.setContent(arr); - String encoded = myFhirCtx.newJsonParser().encodeResourceToString(fromDB); + String encoded = myFhirContext.newJsonParser().encodeResourceToString(fromDB); putRequest = new HttpPut(ourServerBase + "/Binary/" + resource.getIdPart()); putRequest.setEntity(new StringEntity(encoded, ContentType.parse("application/json+fhir"))); resp = ourHttpClient.execute(putRequest); @@ -644,7 +659,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { arr[0] = 4; binary.setId(""); - encoded = myFhirCtx.newJsonParser().encodeResourceToString(binary); + encoded = myFhirContext.newJsonParser().encodeResourceToString(binary); putRequest = new HttpPut(ourServerBase + "/Binary/" + resource.getIdPart()); putRequest.setEntity(new StringEntity(encoded, ContentType.parse("application/json+fhir"))); resp = ourHttpClient.execute(putRequest); @@ -762,14 +777,14 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { obs.addIdentifier().setSystem("urn:foo").setValue("bar"); IBaseResource outcome = ourClient.create().resource(obs).execute().getOperationOutcome(); - String encodedOo = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String encodedOo = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(encodedOo); assertThat(encodedOo, containsString("cvc-complex-type.2.4.b")); assertThat(encodedOo, containsString("Successfully created resource \\\"Observation/")); interceptor.setAddValidationResultsToResponseOperationOutcome(false); outcome = ourClient.create().resource(obs).execute().getOperationOutcome(); - encodedOo = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + encodedOo = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(encodedOo); assertThat(encodedOo, not(containsString("cvc-complex-type.2.4.b"))); assertThat(encodedOo, containsString("Successfully created resource \\\"Observation/")); @@ -823,7 +838,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { Patient pt = new Patient(); pt.addName().setFamily(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPost post = new HttpPost(ourServerBase + "/Patient"); post.addHeader(Constants.HEADER_IF_NONE_EXIST, "Patient?name=" + methodName); @@ -857,7 +872,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { public void testCreateResourceConditionalComplex() throws IOException { Patient pt = new Patient(); pt.addIdentifier().setSystem("http://general-hospital.co.uk/Identifiers").setValue("09832345234543876876"); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPost post = new HttpPost(ourServerBase + "/Patient"); post.addHeader(Constants.HEADER_IF_NONE_EXIST, "Patient?identifier=http://general-hospital.co.uk/Identifiers|09832345234543876876"); @@ -950,7 +965,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(responseString); assertEquals(400, response.getStatusLine().getStatusCode()); - OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString); + OperationOutcome oo = myFhirContext.newXmlParser().parseResource(OperationOutcome.class, responseString); assertEquals(Msg.code(365) + "Can not create resource with ID \"2\", ID must not be supplied on a create (POST) operation (use an HTTP PUT / update operation if you wish to supply an ID)", oo.getIssue().get(0).getDiagnostics()); @@ -1050,7 +1065,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { .where(Patient.IDENTIFIER.exactly().code(methodName)) .execute(); - String encoded = myFhirCtx.newXmlParser().encodeResourceToString(response.getOperationOutcome()); + String encoded = myFhirContext.newXmlParser().encodeResourceToString(response.getOperationOutcome()); ourLog.info(encoded); assertThat(encoded, containsString( " ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output)); + List ids = toUnqualifiedVersionlessIds(myFhirContext.newXmlParser().parseResource(Bundle.class, output)); ourLog.info(ids.toString()); assertThat(ids, containsInAnyOrder(pId, cId, oId)); } finally { @@ -1758,7 +1773,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); IOUtils.closeQuietly(response.getEntity().getContent()); ourLog.info(output); - List ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output)); + List ids = toUnqualifiedVersionlessIds(myFhirContext.newXmlParser().parseResource(Bundle.class, output)); ourLog.info(ids.toString()); assertThat(ids, containsInAnyOrder(pId, cId, oId)); } finally { @@ -1807,7 +1822,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { public void testEverythingWithLargeSet() throws Exception { String inputString = IOUtils.toString(getClass().getResourceAsStream("/david_big_bundle.json"), StandardCharsets.UTF_8); - Bundle inputBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, inputString); + Bundle inputBundle = myFhirContext.newJsonParser().parseResource(Bundle.class, inputString); inputBundle.setType(BundleType.TRANSACTION); assertEquals(53, inputBundle.getEntry().size()); @@ -1833,7 +1848,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { .returnResourceType(Bundle.class) .execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(responseBundle)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(responseBundle)); List ids = new ArrayList(); for (BundleEntryComponent nextEntry : responseBundle.getEntry()) { @@ -1934,7 +1949,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { p.setActive(true); IIdType id = ourClient.create().resource(p).execute().getId().toUnqualifiedVersionless(); - myFhirCtx.getRestfulClientFactory().setSocketTimeout(300 * 1000); + myFhirContext.getRestfulClientFactory().setSocketTimeout(300 * 1000); Bundle response = ourClient .operation() @@ -2145,7 +2160,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { try { myBundleDao.validate(history, null, null, null, null, null, mySrd); } catch (PreconditionFailedException e) { - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); throw e; } } @@ -2157,7 +2172,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { Patient pt = new Patient(); pt.setId("Patient/AAA/_history/4"); pt.addName().setFamily(methodName); - String resource = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(pt); ourLog.info("Input: {}", resource); @@ -2199,7 +2214,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { Patient pt = new Patient(); pt.setId("Patient/AAA/_history/4"); pt.addName().setFamily(methodName); - String resource = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(pt); ourLog.info("Input: {}", resource); @@ -2228,7 +2243,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { String respString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info("Response: {}", respString); assertEquals(400, response.getStatusLine().getStatusCode()); - OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, respString); + OperationOutcome oo = myFhirContext.newXmlParser().parseResource(OperationOutcome.class, respString); assertEquals( Msg.code(420) + "Can not update resource, resource body must contain an ID element which matches the request URL for update (PUT) operation - Resource body ID of \"AAA\" does not match URL ID of \"" + id.getIdPart() + "\"", @@ -2307,7 +2322,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { String methodName = "testMetaOperations"; ourClient.registerInterceptor(new LoggingInterceptor(true)); ourClient.setPrettyPrint(true); - IValidatorModule module = new FhirInstanceValidator(myFhirCtx); + IValidatorModule module = new FhirInstanceValidator(myFhirContext); BaseValidatingInterceptor validatingInterceptor = new RequestValidatingInterceptor().addValidatorModule(module); ourRestServer.registerInterceptor(validatingInterceptor); try { @@ -2577,7 +2592,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { Patient p = ourClient.read().resource(Patient.class).withId("B").execute(); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(p); ourLog.info(encoded); assertThat(encoded, containsString("http://foo")); @@ -2655,7 +2670,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { String output = IOUtils.toString(resp.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(output); - Bundle b = myFhirCtx.newXmlParser().parseResource(Bundle.class, output); + Bundle b = myFhirContext.newXmlParser().parseResource(Bundle.class, output); assertEquals("http://localhost:" + ourPort + "/fhir/context/Patient?_count=5&_pretty=true&name=Jernel%C3%B6v", b.getLink("self").getUrl()); @@ -2826,7 +2841,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); IOUtils.closeQuietly(response.getEntity().getContent()); ourLog.info(output); - List ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output)); + List ids = toUnqualifiedVersionlessIds(myFhirContext.newXmlParser().parseResource(Bundle.class, output)); ourLog.info(ids.toString()); assertThat(ids, containsInAnyOrder(pid1)); } finally { @@ -2840,7 +2855,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); IOUtils.closeQuietly(response.getEntity().getContent()); ourLog.info(output); - List ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output)); + List ids = toUnqualifiedVersionlessIds(myFhirContext.newXmlParser().parseResource(Bundle.class, output)); ourLog.info(ids.toString()); assertThat(ids, containsInAnyOrder(pid2)); } finally { @@ -3108,7 +3123,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); IOUtils.closeQuietly(response.getEntity().getContent()); ourLog.info(resp); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, resp); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, resp); matches = bundle.getTotal(); assertThat(matches, greaterThan(0)); @@ -3411,7 +3426,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { try (CloseableHttpResponse resp = ourHttpClient.execute(get)) { assertEquals(200, resp.getStatusLine().getStatusCode()); String respString = IOUtils.toString(resp.getEntity().getContent(), Constants.CHARSET_UTF8); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, respString); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, respString); assertEquals(1, bundle.getEntry().size()); } } @@ -3529,7 +3544,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { CloseableHttpResponse resp = ourHttpClient.execute(get); try { assertEquals(200, resp.getStatusLine().getStatusCode()); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, IOUtils.toString(resp.getEntity().getContent(), Constants.CHARSET_UTF8)); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, IOUtils.toString(resp.getEntity().getContent(), Constants.CHARSET_UTF8)); List ids = toUnqualifiedVersionlessIdValues(bundle); assertThat(ids, contains(oid1)); @@ -3563,7 +3578,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { oid1 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -3575,7 +3590,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { oid2 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -3587,7 +3602,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { oid3 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -3599,7 +3614,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { oid4 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } String uri = ourServerBase + "/Observation?_sort=code-value-date"; @@ -3608,10 +3623,10 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { HttpGet get = new HttpGet(uri); try (CloseableHttpResponse resp = ourHttpClient.execute(get)) { String output = IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8); - found = myFhirCtx.newXmlParser().parseResource(Bundle.class, output); + found = myFhirContext.newXmlParser().parseResource(Bundle.class, output); } - ourLog.info("Bundle: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(found)); + ourLog.info("Bundle: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(found)); List list = toUnqualifiedVersionlessIds(found); assertEquals(4, found.getEntry().size()); @@ -3716,7 +3731,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { CloseableHttpResponse resp = ourHttpClient.execute(get); try { assertEquals(200, resp.getStatusLine().getStatusCode()); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, IOUtils.toString(resp.getEntity().getContent(), Constants.CHARSET_UTF8)); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, IOUtils.toString(resp.getEntity().getContent(), Constants.CHARSET_UTF8)); List ids = toUnqualifiedVersionlessIdValues(bundle); assertThat(ids, contains(id1.getValue())); @@ -3911,14 +3926,14 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { // Read back directly from the DAO { Organization returned = myOrganizationDao.read(orgId, mySrd); - String val = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned); + String val = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned); ourLog.info(val); assertThat(val, containsString("")); } // Read back through the HTTP API { Organization returned = ourClient.read(Organization.class, orgId.getIdPart()); - String val = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned); + String val = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned); ourLog.info(val); assertThat(val, containsString("")); } @@ -3961,7 +3976,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { Patient pt = new Patient(); pt.addName().setFamily(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPut post = new HttpPut(ourServerBase + "/Patient"); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -3970,7 +3985,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(responseString); assertEquals(400, response.getStatusLine().getStatusCode()); - OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString); + OperationOutcome oo = myFhirContext.newXmlParser().parseResource(OperationOutcome.class, responseString); assertThat(oo.getIssue().get(0).getDiagnostics(), containsString("Can not update resource, request URL must contain an ID element for update (PUT) operation (it must be of the form [base]/[resource type]/[id])")); } finally { @@ -3985,7 +4000,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { Patient pt = new Patient(); pt.setId("2"); pt.addName().setFamily(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPut post = new HttpPut(ourServerBase + "/Patient"); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -4011,7 +4026,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { Patient pt = new Patient(); pt.addName().setFamily(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPut post = new HttpPut(ourServerBase + "/Patient/FOO"); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -4039,7 +4054,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { p1.setId("FOO"); p1.addAddress().addLine("NEWLINE"); - String encoded = myFhirCtx.newJsonParser().encodeResourceToString(p1); + String encoded = myFhirContext.newJsonParser().encodeResourceToString(p1); ourLog.info(encoded); HttpPut put = new HttpPut(ourServerBase + "/Patient/" + p1id.getIdPart()); @@ -4048,7 +4063,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { CloseableHttpResponse response = ourHttpClient.execute(put); try { assertEquals(400, response.getStatusLine().getStatusCode()); - OperationOutcome oo = myFhirCtx.newJsonParser().parseResource(OperationOutcome.class, new InputStreamReader(response.getEntity().getContent())); + OperationOutcome oo = myFhirContext.newJsonParser().parseResource(OperationOutcome.class, new InputStreamReader(response.getEntity().getContent())); assertEquals( Msg.code(420) + "Can not update resource, resource body must contain an ID element which matches the request URL for update (PUT) operation - Resource body ID of \"FOO\" does not match URL ID of \"" + p1id.getIdPart() + "\"", @@ -4060,14 +4075,14 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { // Try to update with the no ID in the resource body p1.setId((String) null); - encoded = myFhirCtx.newJsonParser().encodeResourceToString(p1); + encoded = myFhirContext.newJsonParser().encodeResourceToString(p1); put = new HttpPut(ourServerBase + "/Patient/" + p1id.getIdPart()); put.setEntity(new StringEntity(encoded, ContentType.create(Constants.CT_FHIR_JSON, "UTF-8"))); put.addHeader("Accept", Constants.CT_FHIR_JSON); response = ourHttpClient.execute(put); try { assertEquals(400, response.getStatusLine().getStatusCode()); - OperationOutcome oo = myFhirCtx.newJsonParser().parseResource(OperationOutcome.class, new InputStreamReader(response.getEntity().getContent())); + OperationOutcome oo = myFhirContext.newJsonParser().parseResource(OperationOutcome.class, new InputStreamReader(response.getEntity().getContent())); assertEquals(Msg.code(419) + "Can not update resource, resource body must contain an ID element for update (PUT) operation", oo.getIssue().get(0).getDiagnostics()); } finally { response.close(); @@ -4076,7 +4091,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { // Try to update with the to correct ID in the resource body p1.setId(p1id.getIdPart()); - encoded = myFhirCtx.newJsonParser().encodeResourceToString(p1); + encoded = myFhirContext.newJsonParser().encodeResourceToString(p1); put = new HttpPut(ourServerBase + "/Patient/" + p1id.getIdPart()); put.setEntity(new StringEntity(encoded, ContentType.create(Constants.CT_FHIR_JSON, "UTF-8"))); response = ourHttpClient.execute(put); @@ -4121,7 +4136,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { Patient pt = new Patient(); pt.addName().setFamily(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPost post = new HttpPost(ourServerBase + "/Patient?name=" + methodName); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -4137,7 +4152,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { } pt.addAddress().addLine("AAAAAAAAAAAAAAAAAAA"); - resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPut put = new HttpPut(ourServerBase + "/Patient?name=" + methodName); put.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); response = ourHttpClient.execute(put); @@ -4156,7 +4171,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { public void testUpdateResourceConditionalComplex() throws IOException { Patient pt = new Patient(); pt.addIdentifier().setSystem("http://general-hospital.co.uk/Identifiers").setValue("09832345234543876876"); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPost post = new HttpPost(ourServerBase + "/Patient"); post.addHeader(Constants.HEADER_IF_NONE_EXIST, "Patient?identifier=http://general-hospital.co.uk/Identifiers|09832345234543876876"); @@ -4174,7 +4189,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { } pt.addName().setFamily("FOO"); - resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPut put = new HttpPut(ourServerBase + "/Patient?identifier=" + ("http://general-hospital.co.uk/Identifiers|09832345234543876876".replace("|", UrlUtil.escapeUrlParam("|")))); put.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -4200,7 +4215,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { Patient pt = new Patient(); pt.addName().setFamily(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPost post = new HttpPost(ourServerBase + "/Patient"); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -4220,7 +4235,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { pt = new Patient(); pt.setId(id.getIdPart()); - resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPut put = new HttpPut(ourServerBase + "/Patient/" + id.getIdPart()); put.addHeader(Constants.HEADER_PREFER, Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_REPRESENTATION); @@ -4231,7 +4246,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); IOUtils.closeQuietly(response.getEntity().getContent()); - Patient respPt = myFhirCtx.newXmlParser().parseResource(Patient.class, responseString); + Patient respPt = myFhirContext.newXmlParser().parseResource(Patient.class, responseString); assertEquals("2", respPt.getIdElement().getVersionIdPart()); InstantType updateTime = respPt.getMeta().getLastUpdatedElement(); @@ -4305,7 +4320,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { pt.addName().setFamily("FAM2"); pt.setId(id.toUnqualifiedVersionless()); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPut put = new HttpPut(ourServerBase + "/Patient/" + id.getIdPart()); put.addHeader(Constants.HEADER_IF_MATCH, "W/\"44\""); @@ -4315,7 +4330,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(responseString); assertEquals(409, response.getStatusLine().getStatusCode()); - OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString); + OperationOutcome oo = myFhirContext.newXmlParser().parseResource(OperationOutcome.class, responseString); assertThat(oo.getIssue().get(0).getDiagnostics(), containsString("Trying to update Patient/" + id.getIdPart() + "/_history/44 but this is not the current version")); } finally { response.close(); @@ -4343,7 +4358,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { Patient pt = new Patient(); pt.setId("333"); pt.addName().setFamily(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPut post = new HttpPut(ourServerBase + "/Patient/A2"); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -4352,7 +4367,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(responseString); assertEquals(400, response.getStatusLine().getStatusCode()); - OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString); + OperationOutcome oo = myFhirContext.newXmlParser().parseResource(OperationOutcome.class, responseString); assertEquals( Msg.code(420) + "Can not update resource, resource body must contain an ID element which matches the request URL for update (PUT) operation - Resource body ID of \"333\" does not match URL ID of \"A2\"", oo.getIssue().get(0).getDiagnostics()); @@ -4383,7 +4398,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { Parameters input = new Parameters(); input.addParameter().setName("mode").setValue(new CodeType("create")); - String inputStr = myFhirCtx.newXmlParser().encodeResourceToString(input); + String inputStr = myFhirContext.newXmlParser().encodeResourceToString(input); ourLog.info(inputStr); HttpPost post = new HttpPost(ourServerBase + "/Patient/$validate"); @@ -4408,7 +4423,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { patient.addName().addGiven("James"); patient.setBirthDateElement(new DateType("2011-02-02")); - String inputStr = myFhirCtx.newXmlParser().encodeResourceToString(patient); + String inputStr = myFhirContext.newXmlParser().encodeResourceToString(patient); HttpPost post = new HttpPost(ourServerBase + "/Patient/$validate"); post.setEntity(new StringEntity(inputStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -4431,7 +4446,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { Parameters input = new Parameters(); input.addParameter().setName("resource").setResource(patient); - String inputStr = myFhirCtx.newXmlParser().encodeResourceToString(input); + String inputStr = myFhirContext.newXmlParser().encodeResourceToString(input); ourLog.debug(inputStr); HttpPost post = new HttpPost(ourServerBase + "/Patient/$validate"); @@ -4480,7 +4495,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { Parameters input = new Parameters(); input.addParameter().setName("resource").setResource(patient); - String inputStr = myFhirCtx.newXmlParser().encodeResourceToString(input); + String inputStr = myFhirContext.newXmlParser().encodeResourceToString(input); ourLog.info(inputStr); HttpPost post = new HttpPost(ourServerBase + "/Patient/A123/$validate"); @@ -4508,7 +4523,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { Parameters input = new Parameters(); input.addParameter().setName("resource").setResource(patient); - String inputStr = myFhirCtx.newXmlParser().encodeResourceToString(input); + String inputStr = myFhirContext.newXmlParser().encodeResourceToString(input); HttpPost post = new HttpPost(ourServerBase + "/Patient/$validate?_pretty=true"); post.setEntity(new StringEntity(inputStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -4535,7 +4550,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { patient.addName().addGiven("James"); patient.setBirthDateElement(new DateType("2011-02-02")); - String inputStr = myFhirCtx.newXmlParser().encodeResourceToString(patient); + String inputStr = myFhirContext.newXmlParser().encodeResourceToString(patient); HttpPost post = new HttpPost(ourServerBase + "/Patient/$validate"); post.setEntity(new StringEntity(inputStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -4557,10 +4572,10 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { @Test public void testValueSetExpandOperation() throws IOException { - CodeSystem cs = myFhirCtx.newXmlParser().parseResource(CodeSystem.class, new InputStreamReader(ResourceProviderDstu3Test.class.getResourceAsStream("/extensional-case-3-cs.xml"))); + CodeSystem cs = myFhirContext.newXmlParser().parseResource(CodeSystem.class, new InputStreamReader(ResourceProviderDstu3Test.class.getResourceAsStream("/extensional-case-3-cs.xml"))); ourClient.create().resource(cs).execute(); - ValueSet upload = myFhirCtx.newXmlParser().parseResource(ValueSet.class, new InputStreamReader(ResourceProviderDstu3Test.class.getResourceAsStream("/extensional-case-3-vs.xml"))); + ValueSet upload = myFhirContext.newXmlParser().parseResource(ValueSet.class, new InputStreamReader(ResourceProviderDstu3Test.class.getResourceAsStream("/extensional-case-3-vs.xml"))); IIdType vsid = ourClient.create().resource(upload).execute().getId().toUnqualifiedVersionless(); HttpGet get = new HttpGet(ourServerBase + "/ValueSet/" + vsid.getIdPart() + "/$expand"); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ValueSetTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ValueSetTest.java index e6d4631efcc..4837718187b 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ValueSetTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ValueSetTest.java @@ -8,11 +8,10 @@ import ca.uhn.fhir.jpa.dao.r4.FhirResourceDaoR4TerminologyTest; import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion; import ca.uhn.fhir.jpa.entity.TermConcept; import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink.RelationshipTypeEnum; -import ca.uhn.fhir.jpa.util.BaseCaptureQueriesListener; -import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc; +import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener; +import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; @@ -56,7 +55,10 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.stringContainsInOrder; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3Test { @@ -289,7 +291,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, Matchers.containsString("")); assertThat(resp, Matchers.containsString("")); @@ -322,7 +324,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, Matchers.containsString("")); assertThat(resp, Matchers.containsString("")); @@ -352,7 +354,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, Matchers.containsString("")); assertThat(resp, not(containsString("\"Foo Code\""))); @@ -378,7 +380,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, Matchers.stringContainsInOrder( "", @@ -398,7 +400,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, Matchers.stringContainsInOrder( "", @@ -420,7 +422,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, Matchers.stringContainsInOrder( "", @@ -460,7 +462,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, Matchers.stringContainsInOrder( "", @@ -502,7 +504,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, Matchers.stringContainsInOrder( "", @@ -523,7 +525,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, Matchers.containsStringIgnoringCase("")); @@ -543,7 +545,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, Matchers.containsStringIgnoringCase("")); @@ -634,7 +636,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, Matchers.containsStringIgnoringCase("")); @@ -653,7 +655,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, Matchers.containsStringIgnoringCase("")); @@ -675,7 +677,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, Matchers.containsStringIgnoringCase("")); @@ -735,7 +737,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .andParameter("system", new UriType("http://acme.org")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(true, ((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -761,7 +763,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 String respString = IOUtils.toString(response.getEntity().getContent(), Charsets.UTF_8); ourLog.info(respString); - Parameters respParam = myFhirCtx.newJsonParser().parseResource(Parameters.class, respString); + Parameters respParam = myFhirContext.newJsonParser().parseResource(Parameters.class, respString); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); } } @@ -779,7 +781,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(true, ((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -802,7 +804,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .useHttpGet() .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("result", respParam.getParameter().get(0).getName()); @@ -832,7 +834,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .useHttpGet() .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("result", respParam.getParameter().get(0).getName()); @@ -860,7 +862,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -883,7 +885,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder("", "")); } @@ -903,7 +905,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, not(stringContainsInOrder("",""))); @@ -924,7 +926,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, not(stringContainsInOrder("",""))); @@ -943,7 +945,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ValueSetVersionedTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ValueSetVersionedTest.java index b443e931128..1aeac262a62 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ValueSetVersionedTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ValueSetVersionedTest.java @@ -1,6 +1,5 @@ package ca.uhn.fhir.jpa.provider.dstu3; -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; import ca.uhn.fhir.jpa.dao.data.IResourceTableDao; @@ -9,7 +8,6 @@ import ca.uhn.fhir.jpa.entity.TermConcept; import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink.RelationshipTypeEnum; import ca.uhn.fhir.jpa.entity.TermValueSet; import ca.uhn.fhir.jpa.entity.TermValueSetConcept; -import ca.uhn.fhir.jpa.entity.TermValueSetConceptDesignation; import ca.uhn.fhir.jpa.entity.TermValueSetPreExpansionStatusEnum; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc; @@ -17,11 +15,14 @@ import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; -import org.hl7.fhir.instance.model.api.IIdType; +import org.hl7.fhir.dstu3.model.BooleanType; import org.hl7.fhir.dstu3.model.Bundle; import org.hl7.fhir.dstu3.model.CodeSystem; import org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemContentMode; import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent; +import org.hl7.fhir.dstu3.model.CodeType; +import org.hl7.fhir.dstu3.model.CodeableConcept; +import org.hl7.fhir.dstu3.model.Coding; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.Parameters; import org.hl7.fhir.dstu3.model.StringType; @@ -30,10 +31,7 @@ import org.hl7.fhir.dstu3.model.ValueSet; import org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent; import org.hl7.fhir.dstu3.model.ValueSet.FilterOperator; import org.hl7.fhir.dstu3.model.codesystems.HttpVerb; -import org.hl7.fhir.dstu3.model.BooleanType; -import org.hl7.fhir.dstu3.model.CodeType; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Coding; +import org.hl7.fhir.instance.model.api.IIdType; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.springframework.data.domain.PageRequest; @@ -275,7 +273,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, containsString("")); @@ -300,7 +298,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .execute(); expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, containsString("")); @@ -336,7 +334,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, containsString("")); @@ -361,7 +359,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .execute(); expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, containsString("")); @@ -392,7 +390,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, not(containsString("\"Foo Code\""))); @@ -406,7 +404,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .execute(); expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, not(containsString("\"Foo Code\""))); @@ -432,7 +430,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, not(containsString("\"Foo Code\""))); @@ -446,7 +444,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .execute(); expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, not(containsString("\"Foo Code\""))); @@ -467,7 +465,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -483,7 +481,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv expanded = (ValueSet) respParam.getParameter().get(0).getResource(); // Should return v2 as this was the last version loaded. - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -499,7 +497,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .execute(); expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -522,7 +520,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -538,7 +536,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv expanded = (ValueSet) respParam.getParameter().get(0).getResource(); // Should return v2 as this was the last version loaded. - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -554,7 +552,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .execute(); expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -600,7 +598,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -616,7 +614,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv expanded = (ValueSet) respParam.getParameter().get(0).getResource(); // Should return v2 as this was the last version loaded. - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -632,7 +630,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .execute(); expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -677,7 +675,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); // Should return v2 as this was the last updated. - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -698,7 +696,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv expanded = (ValueSet) respParam.getParameter().get(0).getResource(); // Should return v1. - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -719,7 +717,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv expanded = (ValueSet) respParam.getParameter().get(0).getResource(); // Should return v2. - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -746,7 +744,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); // Should return v2 as this was the last updated. - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -767,7 +765,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv expanded = (ValueSet) respParam.getParameter().get(0).getResource(); // Should return v1. - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -788,7 +786,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv expanded = (ValueSet) respParam.getParameter().get(0).getResource(); // Should return v2. - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -812,7 +810,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsStringIgnoringCase("")); @@ -828,7 +826,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .execute(); expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsStringIgnoringCase("")); @@ -852,7 +850,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsStringIgnoringCase("")); @@ -868,7 +866,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .execute(); expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsStringIgnoringCase("")); @@ -894,7 +892,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv assertEquals(1, respParam.getParameter().size()); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsStringIgnoringCase("")); @@ -927,7 +925,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .withNoParameters(Parameters.class) .returnResourceType(ValueSet.class) .execute(); - ourLog.info("Expanded: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expanded)); + ourLog.info("Expanded: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expanded)); assertEquals(1, expanded.getExpansion().getContains().size()); // Update the CodeSystem Version and Codes @@ -952,7 +950,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .withNoParameters(Parameters.class) .returnResourceType(ValueSet.class) .execute(); - ourLog.info("Expanded: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expanded)); + ourLog.info("Expanded: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expanded)); assertEquals(1, expanded.getExpansion().getContains().size()); } @@ -964,14 +962,14 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv loadAndPersistCodeSystemAndValueSetWithDesignations(); CodeSystem codeSystem_v1 = myCodeSystemDao.read(myExtensionalCsId_v1); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem_v1)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem_v1)); CodeSystem codeSystem_v2 = myCodeSystemDao.read(myExtensionalCsId_v2); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem_v2)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem_v2)); ValueSet valueSet_v1 = myValueSetDao.read(myExtensionalVsId_v1); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet_v1)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet_v1)); ValueSet valueSet_v2 = myValueSetDao.read(myExtensionalVsId_v2); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet_v2)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet_v2)); String initialValueSetName_v1 = valueSet_v1.getName(); validateTermValueSetNotExpanded(initialValueSetName_v1, "1", myExtensionalVsIdOnResourceTable_v1); @@ -985,7 +983,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv updatedValueSet_v1.setName(valueSet_v1.getName().concat(" - MODIFIED")); persistSingleValueSet(updatedValueSet_v1, HttpVerb.PUT); updatedValueSet_v1 = myValueSetDao.read(myExtensionalVsId_v1); - ourLog.info("Updated ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet_v1)); + ourLog.info("Updated ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet_v1)); String updatedValueSetName_v1 = valueSet_v1.getName(); validateTermValueSetNotExpanded(updatedValueSetName_v1,"1", myExtensionalVsIdOnResourceTable_v1); @@ -994,7 +992,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv updatedValueSet_v2.setName(valueSet_v2.getName().concat(" - MODIFIED")); persistSingleValueSet(updatedValueSet_v2, HttpVerb.PUT); updatedValueSet_v2 = myValueSetDao.read(myExtensionalVsId_v2); - ourLog.info("Updated ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet_v2)); + ourLog.info("Updated ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet_v2)); String updatedValueSetName_v2 = valueSet_v2.getName(); validateTermValueSetNotExpanded(updatedValueSetName_v2,"2", myExtensionalVsIdOnResourceTable_v2); @@ -1012,14 +1010,14 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv loadAndPersistCodeSystemAndValueSetWithDesignations(); CodeSystem codeSystem_v1 = myCodeSystemDao.read(myExtensionalCsId_v1); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem_v1)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem_v1)); CodeSystem codeSystem_v2 = myCodeSystemDao.read(myExtensionalCsId_v2); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem_v2)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem_v2)); ValueSet valueSet_v1 = myValueSetDao.read(myExtensionalVsId_v1); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet_v1)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet_v1)); ValueSet valueSet_v2 = myValueSetDao.read(myExtensionalVsId_v2); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet_v2)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet_v2)); String initialValueSetName_v1 = valueSet_v1.getName(); validateTermValueSetNotExpanded(initialValueSetName_v1, "1", myExtensionalVsIdOnResourceTable_v1); @@ -1042,11 +1040,11 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .getRequest() .setMethod(Bundle.HTTPVerb.PUT) .setUrl("ValueSet/" + updatedValueSet_v1.getIdElement().getIdPart()); - ourLog.info("Transaction Bundle:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info("Transaction Bundle:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); ourClient.transaction().withBundle(bundle).execute(); updatedValueSet_v1 = myValueSetDao.read(myExtensionalVsId_v1); - ourLog.info("Updated ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet_v1)); + ourLog.info("Updated ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet_v1)); String updatedValueSetName_v1 = valueSet_v1.getName(); validateTermValueSetNotExpanded(updatedValueSetName_v1, "1", myExtensionalVsIdOnResourceTable_v1); @@ -1064,11 +1062,11 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .getRequest() .setMethod(Bundle.HTTPVerb.PUT) .setUrl("ValueSet/" + updatedValueSet_v2.getIdElement().getIdPart()); - ourLog.info("Transaction Bundle:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info("Transaction Bundle:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); ourClient.transaction().withBundle(bundle).execute(); updatedValueSet_v2 = myValueSetDao.read(myExtensionalVsId_v2); - ourLog.info("Updated ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet_v2)); + ourLog.info("Updated ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet_v2)); String updatedValueSetName_v2 = valueSet_v2.getName(); validateTermValueSetNotExpanded(updatedValueSetName_v2, "2", myExtensionalVsIdOnResourceTable_v2); @@ -1193,7 +1191,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .andParameter("valueSetVersion", new StringType("1")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1209,7 +1207,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .andParameter("valueSetVersion", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1226,7 +1224,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .andParameter("valueSetVersion", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1242,7 +1240,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .andParameter("valueSetVersion", new StringType("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1263,7 +1261,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .andParameter("systemVersion", new StringType("1")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1277,7 +1275,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .andParameter("systemVersion", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1292,7 +1290,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .andParameter("systemVersion", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1306,7 +1304,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .andParameter("systemVersion", new StringType("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1333,7 +1331,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .andParameter("valueSetVersion", new StringType("1")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1347,7 +1345,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .andParameter("valueSetVersion", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1362,7 +1360,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .andParameter("valueSetVersion", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1376,7 +1374,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .andParameter("valueSetVersion", new StringType("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1405,7 +1403,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .andParameter("valueSetVersion", new StringType("1")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1419,7 +1417,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .andParameter("valueSetVersion", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1434,7 +1432,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .andParameter("valueSetVersion", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1448,7 +1446,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv .andParameter("valueSetVersion", new StringType("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderExpungeDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderExpungeDstu3Test.java index fb385d718a0..52aa2d8a5c7 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderExpungeDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderExpungeDstu3Test.java @@ -363,7 +363,7 @@ public class ResourceProviderExpungeDstu3Test extends BaseResourceProviderDstu3T p.addParameter() .setName(ProviderConstants.OPERATION_EXPUNGE_PARAM_EXPUNGE_DELETED_RESOURCES) .setValue(new BooleanType(true)); - ourLog.info(myFhirCtx.newJsonParser().encodeResourceToString(p)); + ourLog.info(myFhirContext.newJsonParser().encodeResourceToString(p)); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderR3CodeSystemDesignationTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderR3CodeSystemDesignationTest.java index ee4eaa4bb6d..6fd92f57ed9 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderR3CodeSystemDesignationTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderR3CodeSystemDesignationTest.java @@ -1,12 +1,5 @@ package ca.uhn.fhir.jpa.provider.dstu3; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - import org.hl7.fhir.dstu3.model.BooleanType; import org.hl7.fhir.dstu3.model.CodeSystem; import org.hl7.fhir.dstu3.model.CodeType; @@ -18,6 +11,13 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.transaction.annotation.Transactional; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + public class ResourceProviderR3CodeSystemDesignationTest extends BaseResourceProviderDstu3Test { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderR3CodeSystemDesignationTest.class); @@ -42,7 +42,7 @@ public class ResourceProviderR3CodeSystemDesignationTest extends BaseResourcePro .andParameter("displayLanguage",new CodeType("de-AT")) .execute(); - String resp = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); @@ -86,7 +86,7 @@ public class ResourceProviderR3CodeSystemDesignationTest extends BaseResourcePro .andParameter("displayLanguage",new CodeType("zh-CN")) .execute(); - String resp = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); @@ -121,7 +121,7 @@ public class ResourceProviderR3CodeSystemDesignationTest extends BaseResourcePro .andParameter("system", new UriType(CS_ACME_URL)) .execute(); - String resp = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ServerDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ServerDstu3Test.java index f4058e09356..a6b581b24d4 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ServerDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ServerDstu3Test.java @@ -44,7 +44,7 @@ public class ServerDstu3Test extends BaseResourceProviderDstu3Test { String respString = IOUtils.toString(resp.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(respString); - CapabilityStatement cs = myFhirCtx.newXmlParser().parseResource(CapabilityStatement.class, respString); + CapabilityStatement cs = myFhirContext.newXmlParser().parseResource(CapabilityStatement.class, respString); for (CapabilityStatementRestResourceComponent nextResource : cs.getRest().get(0).getResource()) { ourLog.info("Testing resource: " + nextResource.getType()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/SubscriptionsDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/SubscriptionsDstu3Test.java index 3420fc5b618..cb8ffd626b0 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/SubscriptionsDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/SubscriptionsDstu3Test.java @@ -4,7 +4,6 @@ import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.util.SubscriptionsRequireManualActivationInterceptorDstu3; import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; -import ca.uhn.fhir.util.TestUtil; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; @@ -14,7 +13,6 @@ import org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType; import org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -217,7 +215,7 @@ public class SubscriptionsDstu3Test extends BaseResourceProviderDstu3Test { myPingCount++; } else if (myGotBound && theMsg.startsWith("add " + mySubsId + "\n")) { String text = theMsg.substring(("add " + mySubsId + "\n").length()); - IBaseResource res = myEncoding.newParser(myFhirCtx).parseResource(text); + IBaseResource res = myEncoding.newParser(myFhirContext).parseResource(text); myReceived.add(res); myPingCount++; } else { diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/SystemProviderTransactionSearchDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/SystemProviderTransactionSearchDstu3Test.java index 9e1020e7957..6fceaafe17f 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/SystemProviderTransactionSearchDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/SystemProviderTransactionSearchDstu3Test.java @@ -155,7 +155,7 @@ public class SystemProviderTransactionSearchDstu3Test extends BaseJpaDstu3Test { myDaoConfig.setMaximumSearchResultCountInTransaction(100); Bundle output = ourClient.transaction().withBundle(input).execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); assertEquals(1, output.getEntry().size()); Bundle respBundle = (Bundle) output.getEntry().get(0).getResource(); @@ -178,7 +178,7 @@ public class SystemProviderTransactionSearchDstu3Test extends BaseJpaDstu3Test { .setUrl("Patient?_count=5&_sort=name"); Bundle output = ourClient.transaction().withBundle(input).execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); assertEquals(1, output.getEntry().size()); Bundle respBundle = (Bundle) output.getEntry().get(0).getResource(); @@ -221,7 +221,7 @@ public class SystemProviderTransactionSearchDstu3Test extends BaseJpaDstu3Test { .getRequest().setUrl(pid1.getValue()); HttpPost post = new HttpPost(ourServerBase); - String encodedRequest = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(input); + String encodedRequest = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(input); ourLog.info("Requet:\n{}", encodedRequest); post.setEntity(new StringEntity(encodedRequest, ContentType.parse(ca.uhn.fhir.rest.api.Constants.CT_FHIR_JSON_NEW+ Constants.CHARSET_UTF8_CTSUFFIX))); try (CloseableHttpResponse response = ourHttpClient.execute(post)) { @@ -253,7 +253,7 @@ public class SystemProviderTransactionSearchDstu3Test extends BaseJpaDstu3Test { myDaoConfig.setMaximumSearchResultCountInTransaction(100); Bundle output = ourClient.transaction().withBundle(input).execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); assertEquals(1, output.getEntry().size()); Bundle respBundle = (Bundle) output.getEntry().get(0).getResource(); @@ -276,7 +276,7 @@ public class SystemProviderTransactionSearchDstu3Test extends BaseJpaDstu3Test { .setUrl("Patient?_count=5&_sort=name"); Bundle output = ourClient.transaction().withBundle(input).execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); assertEquals(1, output.getEntry().size()); Bundle respBundle = (Bundle) output.getEntry().get(0).getResource(); @@ -311,7 +311,7 @@ public class SystemProviderTransactionSearchDstu3Test extends BaseJpaDstu3Test { } Bundle output = ourClient.transaction().withBundle(input).execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); assertEquals(30, output.getEntry().size()); for (int i = 0; i < 30; i++) { @@ -334,7 +334,7 @@ public class SystemProviderTransactionSearchDstu3Test extends BaseJpaDstu3Test { .setUrl("/Patient?_id="+patientId.getIdPart()); Bundle output = ourClient.transaction().withBundle(input).execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); assertThat(output.getEntryFirstRep().getResponse().getStatus(), startsWith("200")); Bundle respBundle = (Bundle) output.getEntry().get(0).getResource(); List actualIds = toIds(respBundle); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/AuthorizationInterceptorJpaR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/AuthorizationInterceptorJpaR4Test.java index 02bfd356f6b..892da26d7e1 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/AuthorizationInterceptorJpaR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/AuthorizationInterceptorJpaR4Test.java @@ -62,7 +62,6 @@ import org.springframework.mock.web.MockHttpServletRequest; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Arrays; -import java.util.Collections; import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; @@ -70,7 +69,6 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.startsWith; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; public class AuthorizationInterceptorJpaR4Test extends BaseResourceProviderR4Test { @@ -522,7 +520,7 @@ public class AuthorizationInterceptorJpaR4Test extends BaseResourceProviderR4Tes .setMethod(Bundle.HTTPVerb.POST) .setIfNoneExist("Patient?identifier=http://uhn.ca/mrns|100"); Bundle response = myClient.transaction().withBundle(request).execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); // Subsequent calls also shouldn't fail myClient.transaction().withBundle(request).execute(); @@ -880,7 +878,7 @@ public class AuthorizationInterceptorJpaR4Test extends BaseResourceProviderR4Tes @Test public void testDeleteCascadeBlocked() { - CascadingDeleteInterceptor cascadingDeleteInterceptor = new CascadingDeleteInterceptor(myFhirCtx, myDaoRegistry, myInterceptorRegistry); + CascadingDeleteInterceptor cascadingDeleteInterceptor = new CascadingDeleteInterceptor(myFhirContext, myDaoRegistry, myInterceptorRegistry); ourRestServer.getInterceptorService().registerInterceptor(cascadingDeleteInterceptor); try { @@ -924,7 +922,7 @@ public class AuthorizationInterceptorJpaR4Test extends BaseResourceProviderR4Tes @Test public void testDeleteCascadeAllowed() { - CascadingDeleteInterceptor cascadingDeleteInterceptor = new CascadingDeleteInterceptor(myFhirCtx, myDaoRegistry, myInterceptorRegistry); + CascadingDeleteInterceptor cascadingDeleteInterceptor = new CascadingDeleteInterceptor(myFhirContext, myDaoRegistry, myInterceptorRegistry); ourRestServer.getInterceptorService().registerInterceptor(cascadingDeleteInterceptor); try { @@ -963,7 +961,7 @@ public class AuthorizationInterceptorJpaR4Test extends BaseResourceProviderR4Tes @Test public void testDeleteCascadeAllowed_ButNotOnTargetType() { - CascadingDeleteInterceptor cascadingDeleteInterceptor = new CascadingDeleteInterceptor(myFhirCtx, myDaoRegistry, myInterceptorRegistry); + CascadingDeleteInterceptor cascadingDeleteInterceptor = new CascadingDeleteInterceptor(myFhirContext, myDaoRegistry, myInterceptorRegistry); ourRestServer.getInterceptorService().registerInterceptor(cascadingDeleteInterceptor); try { @@ -1012,7 +1010,7 @@ public class AuthorizationInterceptorJpaR4Test extends BaseResourceProviderR4Tes Patient pt = new Patient(); pt.addName().setFamily(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPost post = new HttpPost(ourServerBase + "/Patient"); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -1029,7 +1027,7 @@ public class AuthorizationInterceptorJpaR4Test extends BaseResourceProviderR4Tes pt = new Patient(); pt.addName().setFamily("FOOFOOFOO"); - resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + resource = myFhirContext.newXmlParser().encodeResourceToString(pt); post = new HttpPost(ourServerBase + "/Patient"); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -1267,7 +1265,7 @@ public class AuthorizationInterceptorJpaR4Test extends BaseResourceProviderR4Tes .withBundle(bundle) .withAdditionalHeader(Constants.HEADER_PREFER, "return=" + Constants.HEADER_PREFER_RETURN_MINIMAL) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); assertNull(resp.getEntry().get(0).getResource()); // return=OperationOutcome - should succeed @@ -1276,7 +1274,7 @@ public class AuthorizationInterceptorJpaR4Test extends BaseResourceProviderR4Tes .withBundle(bundle) .withAdditionalHeader(Constants.HEADER_PREFER, "return=" + Constants.HEADER_PREFER_RETURN_OPERATION_OUTCOME) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); assertNull(resp.getEntry().get(0).getResource()); // return=Representation - should fail @@ -1380,7 +1378,7 @@ public class AuthorizationInterceptorJpaR4Test extends BaseResourceProviderR4Tes .withAdditionalHeader(Constants.HEADER_PREFER, "return=" + Constants.HEADER_PREFER_RETURN_MINIMAL) .execute(); assertEquals(3, resp.getEntry().size()); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); } @Test diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/AuthorizationInterceptorMultitenantJpaR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/AuthorizationInterceptorMultitenantJpaR4Test.java index d76e06eb332..021e8a20ee5 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/AuthorizationInterceptorMultitenantJpaR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/AuthorizationInterceptorMultitenantJpaR4Test.java @@ -200,7 +200,7 @@ public class AuthorizationInterceptorMultitenantJpaR4Test extends BaseMultitenan .returnBundle(Bundle.class) .count(3) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).setEncodeElements(Sets.newHashSet("Bundle.link")).encodeResourceToString(bundle)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).setEncodeElements(Sets.newHashSet("Bundle.link")).encodeResourceToString(bundle)); assertThat(toUnqualifiedVersionlessIds(bundle).toString(), toUnqualifiedVersionlessIds(bundle), contains(observationIds.get(0), observationIds.get(1), observationIds.get(2), patientIdA)); // Fetch the next 3 @@ -208,7 +208,7 @@ public class AuthorizationInterceptorMultitenantJpaR4Test extends BaseMultitenan .loadPage() .next(bundle) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).setEncodeElements(Sets.newHashSet("Bundle.link")).encodeResourceToString(bundle)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).setEncodeElements(Sets.newHashSet("Bundle.link")).encodeResourceToString(bundle)); assertThat(toUnqualifiedVersionlessIds(bundle).toString(), toUnqualifiedVersionlessIds(bundle), contains(observationIds.get(3), observationIds.get(4), observationIds.get(5), patientIdA)); // Fetch the next 3 - This should fail as the last observation has a cross-partition reference diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/BaseMultitenantResourceProviderR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/BaseMultitenantResourceProviderR4Test.java index bb46d3776ae..1d9c4dc46ba 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/BaseMultitenantResourceProviderR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/BaseMultitenantResourceProviderR4Test.java @@ -136,7 +136,7 @@ public abstract class BaseMultitenantResourceProviderR4Test extends BaseResource @Override public FhirContext getFhirContext() { - return myFhirCtx; + return myFhirContext; } } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/BaseResourceProviderR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/BaseResourceProviderR4Test.java index eebf78270f6..cd40938c64e 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/BaseResourceProviderR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/BaseResourceProviderR4Test.java @@ -5,8 +5,8 @@ import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.api.svc.ISearchCoordinatorSvc; import ca.uhn.fhir.jpa.dao.data.IPartitionDao; import ca.uhn.fhir.jpa.dao.r4.BaseJpaR4Test; -import ca.uhn.fhir.jpa.provider.DiffProvider; import ca.uhn.fhir.jpa.graphql.GraphQLProvider; +import ca.uhn.fhir.jpa.provider.DiffProvider; import ca.uhn.fhir.jpa.provider.JpaCapabilityStatementProvider; import ca.uhn.fhir.jpa.provider.TerminologyUploaderProvider; import ca.uhn.fhir.jpa.provider.ValueSetOperationProvider; @@ -91,19 +91,19 @@ public abstract class BaseResourceProviderR4Test extends BaseJpaR4Test { @AfterEach public void after() throws Exception { - myFhirCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.ONCE); + myFhirContext.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.ONCE); ourRestServer.getInterceptorService().unregisterAllInterceptors(); } @BeforeEach public void before() throws Exception { - myFhirCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); - myFhirCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000); - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); + myFhirContext.getRestfulClientFactory().setSocketTimeout(1200 * 1000); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); myResourceCountsCache = (ResourceCountCache) myAppCtx.getBean("myResourceCountsCache"); if (ourServer == null) { - ourRestServer = new RestfulServer(myFhirCtx); + ourRestServer = new RestfulServer(myFhirContext); ourRestServer.registerProviders(myResourceProviders.createProviders()); ourRestServer.registerProvider(myBinaryAccessProvider); ourRestServer.getInterceptorService().registerInterceptor(myBinaryStorageInterceptor); @@ -176,8 +176,8 @@ public abstract class BaseResourceProviderR4Test extends BaseJpaR4Test { myValidationSupport = wac.getBean(IValidationSupport.class); mySearchCoordinatorSvc = wac.getBean(ISearchCoordinatorSvc.class); - myFhirCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); - myFhirCtx.getRestfulClientFactory().setSocketTimeout(400000); + myFhirContext.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); + myFhirContext.getRestfulClientFactory().setSocketTimeout(400000); PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS); connectionManager.setMaxTotal(10); @@ -194,7 +194,7 @@ public abstract class BaseResourceProviderR4Test extends BaseJpaR4Test { ourRestServer.setPagingProvider(ourPagingProvider); ourRestServer.registerInterceptor(new ResponseHighlighterInterceptor()); - myClient = myFhirCtx.newRestfulGenericClient(ourServerBase); + myClient = myFhirContext.newRestfulGenericClient(ourServerBase); if (shouldLogClient()) { myClient.registerInterceptor(new LoggingInterceptor()); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/BinaryAccessProviderR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/BinaryAccessProviderR4Test.java index 5dc54aea8e5..89e249ac27d 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/BinaryAccessProviderR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/BinaryAccessProviderR4Test.java @@ -23,7 +23,6 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ByteArrayEntity; import org.apache.http.entity.ContentType; -import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.model.Attachment; import org.hl7.fhir.r4.model.Binary; @@ -41,20 +40,17 @@ import org.springframework.beans.factory.annotation.Autowired; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.matchesPattern; import static org.hamcrest.Matchers.notNullValue; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.fail; -import static org.mockito.ArgumentMatchers.notNull; import static org.mockito.Mockito.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.eq; @@ -243,7 +239,7 @@ public class BinaryAccessProviderR4Test extends BaseResourceProviderR4Test { String response = IOUtils.toString(resp.getEntity().getContent(), Constants.CHARSET_UTF8); ourLog.info("Response: {}", response); - DocumentReference ref = myFhirCtx.newJsonParser().parseResource(DocumentReference.class, response); + DocumentReference ref = myFhirContext.newJsonParser().parseResource(DocumentReference.class, response); Attachment attachment = ref.getContentFirstRep().getAttachment(); assertEquals(ContentType.IMAGE_JPEG.getMimeType(), attachment.getContentType()); @@ -301,7 +297,7 @@ public class BinaryAccessProviderR4Test extends BaseResourceProviderR4Test { String response = IOUtils.toString(resp.getEntity().getContent(), Constants.CHARSET_UTF8); ourLog.info("Response: {}", response); - DocumentReference ref = myFhirCtx.newJsonParser().parseResource(DocumentReference.class, response); + DocumentReference ref = myFhirContext.newJsonParser().parseResource(DocumentReference.class, response); Attachment attachment = ref.getContentFirstRep().getAttachment(); assertEquals(ContentType.IMAGE_JPEG.getMimeType(), attachment.getContentType()); @@ -382,7 +378,7 @@ public class BinaryAccessProviderR4Test extends BaseResourceProviderR4Test { String response = IOUtils.toString(resp.getEntity().getContent(), Constants.CHARSET_UTF8); ourLog.info("Response: {}", response); - DocumentReference ref = myFhirCtx.newJsonParser().parseResource(DocumentReference.class, response); + DocumentReference ref = myFhirContext.newJsonParser().parseResource(DocumentReference.class, response); Attachment attachment = ref.getContentFirstRep().getAttachment(); assertEquals(ContentType.IMAGE_JPEG.getMimeType(), attachment.getContentType()); @@ -408,7 +404,7 @@ public class BinaryAccessProviderR4Test extends BaseResourceProviderR4Test { Binary binary = new Binary(); binary.setContentType("image/png"); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(binary)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(binary)); IIdType id = myClient.create().resource(binary).execute().getId().toUnqualifiedVersionless(); @@ -434,7 +430,7 @@ public class BinaryAccessProviderR4Test extends BaseResourceProviderR4Test { String response = IOUtils.toString(resp.getEntity().getContent(), Constants.CHARSET_UTF8); ourLog.info("Response: {}", response); - Binary target = myFhirCtx.newJsonParser().parseResource(Binary.class, response); + Binary target = myFhirContext.newJsonParser().parseResource(Binary.class, response); assertEquals(ContentType.IMAGE_JPEG.getMimeType(), target.getContentType()); assertEquals(null, target.getData()); @@ -477,7 +473,7 @@ public class BinaryAccessProviderR4Test extends BaseResourceProviderR4Test { Binary binary = new Binary(); binary.setContentType("image/png"); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(binary)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(binary)); IIdType id = myClient.create().resource(binary).execute().getId().toUnqualifiedVersionless(); @@ -497,7 +493,7 @@ public class BinaryAccessProviderR4Test extends BaseResourceProviderR4Test { String response = IOUtils.toString(resp.getEntity().getContent(), Constants.CHARSET_UTF8); ourLog.info("Response: {}", response); - Binary target = myFhirCtx.newJsonParser().parseResource(Binary.class, response); + Binary target = myFhirContext.newJsonParser().parseResource(Binary.class, response); assertEquals(ContentType.IMAGE_JPEG.getMimeType(), target.getContentType()); assertEquals(null, target.getData()); @@ -563,7 +559,7 @@ public class BinaryAccessProviderR4Test extends BaseResourceProviderR4Test { String response = IOUtils.toString(resp.getEntity().getContent(), Constants.CHARSET_UTF8); ourLog.info("Response: {}", response); - DocumentReference target = myFhirCtx.newJsonParser().parseResource(DocumentReference.class, response); + DocumentReference target = myFhirContext.newJsonParser().parseResource(DocumentReference.class, response); assertEquals(null, target.getContentFirstRep().getAttachment().getData()); assertEquals("2", target.getMeta().getVersionId()); @@ -613,7 +609,7 @@ public class BinaryAccessProviderR4Test extends BaseResourceProviderR4Test { attachment.setData(SOME_BYTES_2); } - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(documentReference)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(documentReference)); return myClient.create().resource(documentReference).execute().getId().toUnqualifiedVersionless(); } @@ -635,7 +631,7 @@ public class BinaryAccessProviderR4Test extends BaseResourceProviderR4Test { assertEquals(200, resp.getStatusLine().getStatusCode()); assertThat(resp.getEntity().getContentType().getValue(), containsString("application/fhir+json")); String response = IOUtils.toString(resp.getEntity().getContent(), Constants.CHARSET_UTF8); - DocumentReference ref = myFhirCtx.newJsonParser().parseResource(DocumentReference.class, response); + DocumentReference ref = myFhirContext.newJsonParser().parseResource(DocumentReference.class, response); Attachment attachment = ref.getContentFirstRep().getAttachment(); attachmentId = attachment.getDataElement().getExtensionString(HapiExtensions.EXT_EXTERNALIZED_BINARY_ID); assertThat(attachmentId, matchesPattern("[a-zA-Z0-9]{100}")); @@ -698,7 +694,7 @@ public class BinaryAccessProviderR4Test extends BaseResourceProviderR4Test { assertEquals(200, resp.getStatusLine().getStatusCode()); assertThat(resp.getEntity().getContentType().getValue(), containsString("application/fhir+json")); - DocumentReference ref = myFhirCtx.newJsonParser().parseResource(DocumentReference.class, response); + DocumentReference ref = myFhirContext.newJsonParser().parseResource(DocumentReference.class, response); Attachment attachment = ref.getContentFirstRep().getAttachment(); attachmentId = attachment.getDataElement().getExtensionString(HapiExtensions.EXT_EXTERNALIZED_BINARY_ID); assertThat(attachmentId, matchesPattern("[a-zA-Z0-9]{100}")); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/BinaryStorageInterceptorR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/BinaryStorageInterceptorR4Test.java index 561f50446b4..2b4ba862991 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/BinaryStorageInterceptorR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/BinaryStorageInterceptorR4Test.java @@ -21,8 +21,13 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; -import static org.junit.jupiter.api.Assertions.*; +import static org.hamcrest.Matchers.blankOrNullString; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.not; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; public class BinaryStorageInterceptorR4Test extends BaseResourceProviderR4Test { @@ -68,7 +73,7 @@ public class BinaryStorageInterceptorR4Test extends BaseResourceProviderR4Test { // Make sure it was externalized IIdType id = outcome.getId().toUnqualifiedVersionless(); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getResource()); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getResource()); ourLog.info("Encoded: {}", encoded); assertThat(encoded, containsString(HapiExtensions.EXT_EXTERNALIZED_BINARY_ID)); assertThat(encoded, not(containsString("\"data\""))); @@ -92,7 +97,7 @@ public class BinaryStorageInterceptorR4Test extends BaseResourceProviderR4Test { // Make sure it was externalized IIdType id = outcome.getId().toUnqualifiedVersionless(); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getResource()); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getResource()); ourLog.info("Encoded: {}", encoded); assertThat(encoded, containsString(HapiExtensions.EXT_EXTERNALIZED_BINARY_ID)); assertThat(encoded, not(containsString("\"data\""))); @@ -116,7 +121,7 @@ public class BinaryStorageInterceptorR4Test extends BaseResourceProviderR4Test { // Make sure it was externalized IIdType id = outcome.getId().toUnqualifiedVersionless(); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getResource()); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getResource()); ourLog.info("Encoded: {}", encoded); assertThat(encoded, containsString("\"data\": \"BAMCAQ==\"")); assertThat(encoded, not(containsString(HapiExtensions.EXT_EXTERNALIZED_BINARY_ID))); @@ -140,7 +145,7 @@ public class BinaryStorageInterceptorR4Test extends BaseResourceProviderR4Test { // Make sure it was externalized IIdType id = outcome.getId().toUnqualifiedVersionless(); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getResource()); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getResource()); ourLog.info("Encoded: {}", encoded); assertThat(encoded, containsString(HapiExtensions.EXT_EXTERNALIZED_BINARY_ID)); assertThat(encoded, not(containsString("\"data\""))); @@ -165,7 +170,7 @@ public class BinaryStorageInterceptorR4Test extends BaseResourceProviderR4Test { // Make sure it was externalized IIdType id = outcome.getId().toUnqualifiedVersionless(); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getResource()); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getResource()); ourLog.info("Encoded: {}", encoded); assertThat(encoded, containsString(HapiExtensions.EXT_EXTERNALIZED_BINARY_ID)); assertThat(encoded, not(containsString("\"data\""))); @@ -206,7 +211,7 @@ public class BinaryStorageInterceptorR4Test extends BaseResourceProviderR4Test { // Make sure it was externalized IIdType id = outcome.getId().toUnqualifiedVersionless(); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getResource()); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getResource()); ourLog.info("Encoded: {}", encoded); assertThat(encoded, containsString(HapiExtensions.EXT_EXTERNALIZED_BINARY_ID)); assertThat(encoded, not(containsString("\"data\""))); @@ -253,7 +258,7 @@ public class BinaryStorageInterceptorR4Test extends BaseResourceProviderR4Test { // Make sure it was externalized IIdType id = outcome.getId().toUnqualifiedVersionless(); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getResource()); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getResource()); ourLog.info("Encoded: {}", encoded); assertThat(encoded, containsString(HapiExtensions.EXT_EXTERNALIZED_BINARY_ID)); assertThat(encoded, not(containsString("\"data\""))); @@ -299,7 +304,7 @@ public class BinaryStorageInterceptorR4Test extends BaseResourceProviderR4Test { // Make sure it was externalized IIdType id = outcome.getId().toUnqualifiedVersionless(); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getResource()); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getResource()); ourLog.info("Encoded: {}", encoded); assertThat(encoded, containsString(HapiExtensions.EXT_EXTERNALIZED_BINARY_ID)); assertThat(encoded, not(containsString("\"data\""))); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/CompositionDocumentR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/CompositionDocumentR4Test.java index c40516cc60c..fdf7edf16e3 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/CompositionDocumentR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/CompositionDocumentR4Test.java @@ -11,7 +11,14 @@ import com.google.common.base.Charsets; import org.apache.commons.io.IOUtils; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; -import org.hl7.fhir.r4.model.*; +import org.hl7.fhir.r4.model.Bundle; +import org.hl7.fhir.r4.model.Composition; +import org.hl7.fhir.r4.model.Encounter; +import org.hl7.fhir.r4.model.ListResource; +import org.hl7.fhir.r4.model.Observation; +import org.hl7.fhir.r4.model.Organization; +import org.hl7.fhir.r4.model.Patient; +import org.hl7.fhir.r4.model.Reference; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -25,15 +32,17 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.assertNull; -import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; public class CompositionDocumentR4Test extends BaseResourceProviderR4Test { @@ -64,7 +73,7 @@ public class CompositionDocumentR4Test extends BaseResourceProviderR4Test { @BeforeEach public void before() throws Exception { super.before(); - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); myDaoConfig.setAllowMultipleDelete(true); @@ -186,7 +195,7 @@ public class CompositionDocumentR4Test extends BaseResourceProviderR4Test { try (CloseableHttpResponse resp = ourHttpClient.execute(get)) { String resourceString = IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8); - bundle = theEncoding.newParser(myFhirCtx).parseResource(Bundle.class, resourceString); + bundle = theEncoding.newParser(myFhirContext).parseResource(Bundle.class, resourceString); } return bundle; } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ConsentInterceptorResourceProviderR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ConsentInterceptorResourceProviderR4Test.java index 49b7f87c8ad..19d3f3ced9f 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ConsentInterceptorResourceProviderR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ConsentInterceptorResourceProviderR4Test.java @@ -2,7 +2,7 @@ package ca.uhn.fhir.jpa.provider.r4; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.jpa.config.BaseConfig; +import ca.uhn.fhir.jpa.config.JpaConfig; import ca.uhn.fhir.jpa.config.TestR4Config; import ca.uhn.fhir.jpa.entity.Search; import ca.uhn.fhir.jpa.model.search.SearchStatusEnum; @@ -92,7 +92,7 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid private List myObservationIdsEvenOnlyBackwards; private ConsentInterceptor myConsentInterceptor; @Autowired - @Qualifier(BaseConfig.GRAPHQL_PROVIDER_NAME) + @Qualifier(JpaConfig.GRAPHQL_PROVIDER_NAME) private Object myGraphQlProvider; @Override @@ -130,7 +130,7 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid .returnBundle(Bundle.class) .count(15) .execute(); - List resources = BundleUtil.toListOfResources(myFhirCtx, result); + List resources = BundleUtil.toListOfResources(myFhirContext, result); List returnedIdValues = toUnqualifiedVersionlessIdValues(resources); assertThat(returnedIdValues, hasSize(15)); assertEquals(myObservationIdsEvenOnly.subList(0, 15), returnedIdValues); @@ -140,7 +140,7 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid .loadPage() .next(result) .execute(); - resources = BundleUtil.toListOfResources(myFhirCtx, result); + resources = BundleUtil.toListOfResources(myFhirContext, result); returnedIdValues = toUnqualifiedVersionlessIdValues(resources); assertThat(returnedIdValues, hasSize(10)); assertEquals(myObservationIdsEvenOnly.subList(15, 25), returnedIdValues); @@ -171,7 +171,7 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid .returnBundle(Bundle.class) .count(15) .execute(); - List resources = BundleUtil.toListOfResources(myFhirCtx, result); + List resources = BundleUtil.toListOfResources(myFhirContext, result); List returnedIdValues = toUnqualifiedVersionlessIdValues(resources); assertEquals(myObservationIdsEvenOnly.subList(0, 15), returnedIdValues); List cacheOutcome = capture.getLastResponse().getHeaders(Constants.HEADER_X_CACHE); @@ -187,7 +187,7 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid .returnBundle(Bundle.class) .count(15) .execute(); - resources = BundleUtil.toListOfResources(myFhirCtx, result); + resources = BundleUtil.toListOfResources(myFhirContext, result); returnedIdValues = toUnqualifiedVersionlessIdValues(resources); assertEquals(myObservationIdsOddOnly.subList(0, 15), returnedIdValues); cacheOutcome = capture.getLastResponse().getHeaders(Constants.HEADER_X_CACHE); @@ -203,7 +203,7 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid .returnBundle(Bundle.class) .count(15) .execute(); - resources = BundleUtil.toListOfResources(myFhirCtx, result); + resources = BundleUtil.toListOfResources(myFhirContext, result); returnedIdValues = toUnqualifiedVersionlessIdValues(resources); assertEquals(myObservationIds.subList(0, 15), returnedIdValues); cacheOutcome = capture.getLastResponse().getHeaders(Constants.HEADER_X_CACHE); @@ -219,7 +219,7 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid .returnBundle(Bundle.class) .count(15) .execute(); - resources = BundleUtil.toListOfResources(myFhirCtx, result); + resources = BundleUtil.toListOfResources(myFhirContext, result); returnedIdValues = toUnqualifiedVersionlessIdValues(resources); assertEquals(myObservationIds.subList(0, 15), returnedIdValues); cacheOutcome = capture.getLastResponse().getHeaders(Constants.HEADER_X_CACHE); @@ -236,7 +236,7 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid .returnBundle(Bundle.class) .count(15) .execute(); - resources = BundleUtil.toListOfResources(myFhirCtx, result); + resources = BundleUtil.toListOfResources(myFhirContext, result); returnedIdValues = toUnqualifiedVersionlessIdValues(resources); assertEquals(myObservationIds.subList(0, 15), returnedIdValues); cacheOutcome = capture.getLastResponse().getHeaders(Constants.HEADER_X_CACHE); @@ -262,7 +262,7 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid .returnBundle(Bundle.class) .count(15) .execute(); - List resources = BundleUtil.toListOfResources(myFhirCtx, result); + List resources = BundleUtil.toListOfResources(myFhirContext, result); assertEquals(15, resources.size()); assertEquals(16, consentService.getSeeCount()); resources.forEach(t -> { @@ -274,7 +274,7 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid .loadPage() .next(result) .execute(); - resources = BundleUtil.toListOfResources(myFhirCtx, result); + resources = BundleUtil.toListOfResources(myFhirContext, result); assertEquals(15, resources.size()); assertEquals(32, consentService.getSeeCount()); resources.forEach(t -> { @@ -297,7 +297,7 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid .returnBundle(Bundle.class) .count(10) .execute(); - List resources = BundleUtil.toListOfResources(myFhirCtx, result); + List resources = BundleUtil.toListOfResources(myFhirContext, result); List returnedIdValues = toUnqualifiedVersionlessIdValues(resources); assertEquals(myObservationIdsEvenOnlyBackwards.subList(0, 5), returnedIdValues); @@ -442,8 +442,8 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid ourLog.info("Response: {}", responseString); assertEquals(200, status.getStatusLine().getStatusCode()); - Bundle result = myFhirCtx.newJsonParser().parseResource(Bundle.class, responseString); - List resources = BundleUtil.toListOfResources(myFhirCtx, result); + Bundle result = myFhirContext.newJsonParser().parseResource(Bundle.class, responseString); + List resources = BundleUtil.toListOfResources(myFhirContext, result); List returnedIdValues = toUnqualifiedVersionlessIdValues(resources); assertEquals(myObservationIdsOddOnly.subList(0, 5), returnedIdValues); } @@ -502,7 +502,7 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid assertThat(responseString, not(containsString("\"given\":[\"PATIENT_GIVEN1\",\"PATIENT_GIVEN2\"]"))); assertThat(responseString, not(containsString("\"name\":\"ORG_NAME\""))); - OperationOutcome oo = myFhirCtx.newJsonParser().parseResource(OperationOutcome.class, responseString); + OperationOutcome oo = myFhirContext.newJsonParser().parseResource(OperationOutcome.class, responseString); assertThat(oo.getIssueFirstRep().getDiagnostics(), matchesPattern(Msg.code(1147) + "Unable to execute GraphQL Expression: HTTP 404 " + Msg.code(1995) + "Resource Patient/[0-9]+ is not known")); } @@ -541,7 +541,7 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid assertThat(responseString, not(containsString("\"given\":[\"PATIENT_GIVEN1\",\"PATIENT_GIVEN2\"]"))); assertThat(responseString, not(containsString("\"name\":\"ORG_NAME\""))); - OperationOutcome oo = myFhirCtx.newJsonParser().parseResource(OperationOutcome.class, responseString); + OperationOutcome oo = myFhirContext.newJsonParser().parseResource(OperationOutcome.class, responseString); assertThat(oo.getIssueFirstRep().getDiagnostics(), matchesPattern(Msg.code(1147) + "Unable to execute GraphQL Expression: HTTP 404 " + Msg.code(1995) + "Resource Organization/[0-9]+ is not known")); } @@ -594,10 +594,10 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid }); // The paging should have ended now - but the last redacted female result is an empty existing page which should never have been there. - String next = BundleUtil.getLinkUrlOfType(myFhirCtx, response, "next"); + String next = BundleUtil.getLinkUrlOfType(myFhirContext, response, "next"); if (next != null) { response = myClient.loadPage().next(response).execute(); - fail(myFhirCtx.newJsonParser().encodeResourceToString(response)); + fail(myFhirContext.newJsonParser().encodeResourceToString(response)); } } @@ -627,7 +627,7 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid assertNull(response.getTotalElement().getValue()); // The paging should have ended now - but the last redacted female result is an empty existing page which should never have been there. - assertNotNull(BundleUtil.getLinkUrlOfType(myFhirCtx, response, "next")); + assertNotNull(BundleUtil.getLinkUrlOfType(myFhirContext, response, "next")); await() .until( @@ -747,7 +747,7 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid } private HttpEntity toEntity(Patient thePatient) { - String encoded = myFhirCtx.newJsonParser().encodeResourceToString(thePatient); + String encoded = myFhirContext.newJsonParser().encodeResourceToString(thePatient); ContentType cs = ContentType.create(Constants.CT_FHIR_JSON, Constants.CHARSET_UTF8); return new StringEntity(encoded, cs); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/DiffProviderR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/DiffProviderR4Test.java index 53ed0877cdc..68af9686e67 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/DiffProviderR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/DiffProviderR4Test.java @@ -40,7 +40,7 @@ public class DiffProviderR4Test extends BaseResourceProviderR4Test { .useHttpGet() .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(diff)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(diff)); assertEquals(2, diff.getParameter().size()); @@ -71,7 +71,7 @@ public class DiffProviderR4Test extends BaseResourceProviderR4Test { .useHttpGet() .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(diff)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(diff)); assertEquals(4, diff.getParameter().size()); @@ -114,7 +114,7 @@ public class DiffProviderR4Test extends BaseResourceProviderR4Test { .withParameter(Parameters.class, ProviderConstants.DIFF_INCLUDE_META_PARAMETER, new BooleanType(true)) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(diff)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(diff)); assertEquals(5, diff.getParameter().size()); @@ -138,7 +138,7 @@ public class DiffProviderR4Test extends BaseResourceProviderR4Test { .withNoParameters(Parameters.class) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(diff)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(diff)); assertEquals(1, diff.getParameter().size()); @@ -164,7 +164,7 @@ public class DiffProviderR4Test extends BaseResourceProviderR4Test { .andParameter(ProviderConstants.DIFF_INCLUDE_META_PARAMETER, new BooleanType(true)) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(diff)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(diff)); assertEquals(5, diff.getParameter().size()); @@ -191,7 +191,7 @@ public class DiffProviderR4Test extends BaseResourceProviderR4Test { .andParameter(ProviderConstants.DIFF_INCLUDE_META_PARAMETER, new BooleanType(true)) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(diff)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(diff)); assertEquals(3, diff.getParameter().size()); @@ -220,7 +220,7 @@ public class DiffProviderR4Test extends BaseResourceProviderR4Test { .andParameter(ProviderConstants.DIFF_INCLUDE_META_PARAMETER, new BooleanType(true)) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(diff)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(diff)); assertEquals(3, diff.getParameter().size()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ExpungeR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ExpungeR4Test.java index e8db178069b..2db43fad5e4 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ExpungeR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ExpungeR4Test.java @@ -205,7 +205,7 @@ public class ExpungeR4Test extends BaseResourceProviderR4Test { @Test public void testDeleteCascade() throws IOException { - ourRestServer.registerInterceptor(new CascadingDeleteInterceptor(myFhirCtx, myDaoRegistry, myInterceptorRegistry)); + ourRestServer.registerInterceptor(new CascadingDeleteInterceptor(myFhirContext, myDaoRegistry, myInterceptorRegistry)); // setup Organization organization = new Organization(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/MultitenantBatchOperationR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/MultitenantBatchOperationR4Test.java index e2f14461cd5..3516227b430 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/MultitenantBatchOperationR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/MultitenantBatchOperationR4Test.java @@ -7,8 +7,6 @@ import ca.uhn.fhir.interceptor.api.IPointcut; import ca.uhn.fhir.interceptor.api.Pointcut; import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.jpa.batch.BatchJobsConfig; -import ca.uhn.fhir.jpa.dao.BaseJpaTest; import ca.uhn.fhir.jpa.batch.config.BatchConstants; import ca.uhn.fhir.jpa.delete.job.ReindexTestHelper; import ca.uhn.fhir.rest.api.CacheControlDirective; @@ -29,7 +27,6 @@ import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.TestPropertySource; import java.util.ArrayList; import java.util.List; @@ -100,7 +97,7 @@ public class MultitenantBatchOperationR4Test extends BaseMultitenantResourceProv .withParameters(input) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); myBatchJobHelper.awaitAllBulkJobCompletions(BatchConstants.DELETE_EXPUNGE_JOB_NAME); assertThat(interceptor.requestPartitionIds, hasSize(1)); RequestPartitionId partitionId = interceptor.requestPartitionIds.get(0); @@ -124,7 +121,7 @@ public class MultitenantBatchOperationR4Test extends BaseMultitenantResourceProv @Test public void testReindexEverything() { - ReindexTestHelper reindexTestHelper = new ReindexTestHelper(myFhirCtx, myDaoRegistry, mySearchParamRegistry); + ReindexTestHelper reindexTestHelper = new ReindexTestHelper(myFhirContext, myDaoRegistry, mySearchParamRegistry); myTenantClientInterceptor.setTenantId(TENANT_A); IIdType obsFinalA = doCreateResource(reindexTestHelper.buildObservationWithAlleleExtension()); @@ -144,7 +141,7 @@ public class MultitenantBatchOperationR4Test extends BaseMultitenantResourceProv input.addParameter(ProviderConstants.OPERATION_REINDEX_PARAM_BATCH_SIZE, new DecimalType(batchSize)); input.addParameter(ProviderConstants.OPERATION_REINDEX_PARAM_EVERYTHING, new BooleanType(true)); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(input)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(input)); // reindex all of Tenant A myTenantClientInterceptor.setTenantId(TENANT_A); @@ -154,7 +151,7 @@ public class MultitenantBatchOperationR4Test extends BaseMultitenantResourceProv .named(ProviderConstants.OPERATION_REINDEX) .withParameters(input) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); DecimalType jobId = (DecimalType) response.getParameter(ProviderConstants.OPERATION_REINDEX_RESPONSE_JOB_ID); myBatchJobHelper.awaitJobExecution(jobId.getValueAsNumber().longValue()); @@ -171,7 +168,7 @@ public class MultitenantBatchOperationR4Test extends BaseMultitenantResourceProv @Test public void testReindexByUrl() { - ReindexTestHelper reindexTestHelper = new ReindexTestHelper(myFhirCtx, myDaoRegistry, mySearchParamRegistry); + ReindexTestHelper reindexTestHelper = new ReindexTestHelper(myFhirContext, myDaoRegistry, mySearchParamRegistry); myTenantClientInterceptor.setTenantId(TENANT_A); IIdType obsFinalA = doCreateResource(reindexTestHelper.buildObservationWithAlleleExtension(Observation.ObservationStatus.FINAL)); IIdType obsCancelledA = doCreateResource(reindexTestHelper.buildObservationWithAlleleExtension(Observation.ObservationStatus.CANCELLED)); @@ -194,7 +191,7 @@ public class MultitenantBatchOperationR4Test extends BaseMultitenantResourceProv input.addParameter(ProviderConstants.OPERATION_REINDEX_PARAM_BATCH_SIZE, new DecimalType(batchSize)); input.addParameter(ProviderConstants.OPERATION_REINDEX_PARAM_URL, "Observation?status=final"); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(input)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(input)); // Reindex Tenant A by query url myTenantClientInterceptor.setTenantId(TENANT_A); @@ -204,7 +201,7 @@ public class MultitenantBatchOperationR4Test extends BaseMultitenantResourceProv .named(ProviderConstants.OPERATION_REINDEX) .withParameters(input) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); DecimalType jobId = (DecimalType) response.getParameter(ProviderConstants.OPERATION_REINDEX_RESPONSE_JOB_ID); myBatchJobHelper.awaitJobExecution(jobId.getValueAsNumber().longValue()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/PatchProviderR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/PatchProviderR4Test.java index c1a01cb8941..0e55ed8734e 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/PatchProviderR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/PatchProviderR4Test.java @@ -11,7 +11,15 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.hl7.fhir.instance.model.api.IIdType; -import org.hl7.fhir.r4.model.*; +import org.hl7.fhir.r4.model.Binary; +import org.hl7.fhir.r4.model.BooleanType; +import org.hl7.fhir.r4.model.Bundle; +import org.hl7.fhir.r4.model.CodeType; +import org.hl7.fhir.r4.model.Media; +import org.hl7.fhir.r4.model.Observation; +import org.hl7.fhir.r4.model.Parameters; +import org.hl7.fhir.r4.model.Patient; +import org.hl7.fhir.r4.model.StringType; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -20,8 +28,8 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.jupiter.api.Assertions.assertEquals; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; public class PatchProviderR4Test extends BaseResourceProviderR4Test { @@ -88,7 +96,7 @@ public class PatchProviderR4Test extends BaseResourceProviderR4Test { .setMethod(Bundle.HTTPVerb.PATCH); HttpPost post = new HttpPost(ourServerBase); - String encodedRequest = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(input); + String encodedRequest = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(input); ourLog.info("Request:\n{}", encodedRequest); post.setEntity(new StringEntity(encodedRequest, ContentType.parse(Constants.CT_FHIR_JSON_NEW+ Constants.CHARSET_UTF8_CTSUFFIX))); try (CloseableHttpResponse response = ourHttpClient.execute(post)) { @@ -197,7 +205,7 @@ public class PatchProviderR4Test extends BaseResourceProviderR4Test { .setMethod(Bundle.HTTPVerb.PATCH); HttpPost post = new HttpPost(ourServerBase); - String encodedRequest = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(input); + String encodedRequest = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(input); ourLog.info("Request:\n{}", encodedRequest); post.setEntity(new StringEntity(encodedRequest, ContentType.parse(Constants.CT_FHIR_JSON_NEW+ Constants.CHARSET_UTF8_CTSUFFIX))); try (CloseableHttpResponse response = ourHttpClient.execute(post)) { @@ -448,7 +456,7 @@ public class PatchProviderR4Test extends BaseResourceProviderR4Test { .setMethod(Bundle.HTTPVerb.PATCH); HttpPost post = new HttpPost(ourServerBase); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(input); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(input); ourLog.info("Encoded output: {}", encoded); post.setEntity(new StringEntity(encoded, ContentType.parse(Constants.CT_FHIR_JSON_NEW+ Constants.CHARSET_UTF8_CTSUFFIX))); @@ -490,7 +498,7 @@ public class PatchProviderR4Test extends BaseResourceProviderR4Test { .setMethod(Bundle.HTTPVerb.PATCH); HttpPost post = new HttpPost(ourServerBase); - post.setEntity(new StringEntity(myFhirCtx.newJsonParser().encodeResourceToString(input), ContentType.parse(Constants.CT_FHIR_JSON_NEW+ Constants.CHARSET_UTF8_CTSUFFIX))); + post.setEntity(new StringEntity(myFhirContext.newJsonParser().encodeResourceToString(input), ContentType.parse(Constants.CT_FHIR_JSON_NEW+ Constants.CHARSET_UTF8_CTSUFFIX))); try (CloseableHttpResponse response = ourHttpClient.execute(post)) { assertEquals(400, response.getStatusLine().getStatusCode()); String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); @@ -528,7 +536,7 @@ public class PatchProviderR4Test extends BaseResourceProviderR4Test { .setMethod(Bundle.HTTPVerb.PATCH); HttpPost post = new HttpPost(ourServerBase); - post.setEntity(new StringEntity(myFhirCtx.newJsonParser().encodeResourceToString(input), ContentType.parse(Constants.CT_FHIR_JSON_NEW+ Constants.CHARSET_UTF8_CTSUFFIX))); + post.setEntity(new StringEntity(myFhirContext.newJsonParser().encodeResourceToString(input), ContentType.parse(Constants.CT_FHIR_JSON_NEW+ Constants.CHARSET_UTF8_CTSUFFIX))); try (CloseableHttpResponse response = ourHttpClient.execute(post)) { assertEquals(400, response.getStatusLine().getStatusCode()); String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); @@ -567,7 +575,7 @@ public class PatchProviderR4Test extends BaseResourceProviderR4Test { .setMethod(Bundle.HTTPVerb.PATCH); HttpPost post = new HttpPost(ourServerBase); - post.setEntity(new StringEntity(myFhirCtx.newJsonParser().encodeResourceToString(input), ContentType.parse(Constants.CT_FHIR_JSON_NEW+ Constants.CHARSET_UTF8_CTSUFFIX))); + post.setEntity(new StringEntity(myFhirContext.newJsonParser().encodeResourceToString(input), ContentType.parse(Constants.CT_FHIR_JSON_NEW+ Constants.CHARSET_UTF8_CTSUFFIX))); try (CloseableHttpResponse response = ourHttpClient.execute(post)) { assertEquals(400, response.getStatusLine().getStatusCode()); String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); @@ -605,7 +613,7 @@ public class PatchProviderR4Test extends BaseResourceProviderR4Test { .setMethod(Bundle.HTTPVerb.PATCH); HttpPost post = new HttpPost(ourServerBase); - post.setEntity(new StringEntity(myFhirCtx.newJsonParser().encodeResourceToString(input), ContentType.parse(Constants.CT_FHIR_JSON_NEW+ Constants.CHARSET_UTF8_CTSUFFIX))); + post.setEntity(new StringEntity(myFhirContext.newJsonParser().encodeResourceToString(input), ContentType.parse(Constants.CT_FHIR_JSON_NEW+ Constants.CHARSET_UTF8_CTSUFFIX))); try (CloseableHttpResponse response = ourHttpClient.execute(post)) { assertEquals(400, response.getStatusLine().getStatusCode()); String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/PatientEverythingR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/PatientEverythingR4Test.java index c2a15a1006f..ded41b87d4c 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/PatientEverythingR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/PatientEverythingR4Test.java @@ -1,12 +1,5 @@ package ca.uhn.fhir.jpa.provider.r4; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; -import static org.junit.jupiter.api.Assertions.*; - -import java.io.IOException; -import java.util.*; - import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.partition.SystemRequestDetails; import ca.uhn.fhir.parser.StrictErrorHandler; @@ -17,7 +10,6 @@ import org.apache.commons.io.IOUtils; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; -import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent; import org.hl7.fhir.r4.model.Encounter; @@ -28,9 +20,24 @@ import org.hl7.fhir.r4.model.Organization; import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Reference; import org.hl7.fhir.r4.model.StringType; -import org.junit.jupiter.api.*; - +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Set; +import java.util.TreeSet; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.not; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; @SuppressWarnings("Duplicates") public class PatientEverythingR4Test extends BaseResourceProviderR4Test { @@ -64,7 +71,7 @@ public class PatientEverythingR4Test extends BaseResourceProviderR4Test { @BeforeEach public void before() throws Exception { super.before(); - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); myDaoConfig.setAllowMultipleDelete(true); @@ -137,7 +144,7 @@ public class PatientEverythingR4Test extends BaseResourceProviderR4Test { get.addHeader(Constants.HEADER_CACHE_CONTROL, Constants.CACHE_CONTROL_NO_CACHE); try (CloseableHttpResponse resp = ourHttpClient.execute(get)) { assertEquals(EncodingEnum.JSON.getResourceContentTypeNonLegacy(), resp.getFirstHeader(ca.uhn.fhir.rest.api.Constants.HEADER_CONTENT_TYPE).getValue().replaceAll(";.*", "")); - bundle = EncodingEnum.JSON.newParser(myFhirCtx).parseResource(Bundle.class, IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8)); + bundle = EncodingEnum.JSON.newParser(myFhirContext).parseResource(Bundle.class, IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8)); } assertNull(bundle.getLink("next")); actual = new TreeSet<>(); @@ -262,7 +269,7 @@ public class PatientEverythingR4Test extends BaseResourceProviderR4Test { CloseableHttpResponse resp = ourHttpClient.execute(get); try { assertEquals(theEncoding.getResourceContentTypeNonLegacy(), resp.getFirstHeader(ca.uhn.fhir.rest.api.Constants.HEADER_CONTENT_TYPE).getValue().replaceAll(";.*", "")); - bundle = theEncoding.newParser(myFhirCtx).parseResource(Bundle.class, IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8)); + bundle = theEncoding.newParser(myFhirContext).parseResource(Bundle.class, IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8)); } finally { IOUtils.closeQuietly(resp); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/PatientMemberMatchOperationR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/PatientMemberMatchOperationR4Test.java index ff4b7a12f4e..51adc1be042 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/PatientMemberMatchOperationR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/PatientMemberMatchOperationR4Test.java @@ -73,7 +73,7 @@ public class PatientMemberMatchOperationR4Test extends BaseResourceProviderR4Tes @BeforeEach public void before() throws Exception { super.before(); - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); } @@ -255,7 +255,7 @@ public class PatientMemberMatchOperationR4Test extends BaseResourceProviderR4Tes * Validates that second resource from the response is same as the received coverage */ private void validateNewCoverage(Parameters theResponse, Coverage theOriginalCoverage) { - List patientList = ParametersUtil.getNamedParameters(getContext(), theResponse, PARAM_NEW_COVERAGE); + List patientList = ParametersUtil.getNamedParameters(this.getFhirContext(), theResponse, PARAM_NEW_COVERAGE); assertEquals(1, patientList.size()); Coverage respCoverage = (Coverage) theResponse.getParameter().get(1).getResource(); @@ -283,7 +283,7 @@ public class PatientMemberMatchOperationR4Test extends BaseResourceProviderR4Tes // "system": COVERAGE_PATIENT_IDENT_SYSTEM, // "value": COVERAGE_PATIENT_IDENT_VALUE // } - List patientList = ParametersUtil.getNamedParameters(getContext(), response, PARAM_MEMBER_PATIENT); + List patientList = ParametersUtil.getNamedParameters(this.getFhirContext(), response, PARAM_MEMBER_PATIENT); assertEquals(1, patientList.size()); Patient resultPatient = (Patient) response.getParameter().get(0).getResource(); @@ -327,9 +327,9 @@ public class PatientMemberMatchOperationR4Test extends BaseResourceProviderR4Tes private Parameters buildInputParameters(Patient thePatient, Coverage theOldCoverage, Coverage theNewCoverage) { Parameters p = new Parameters(); - ParametersUtil.addParameterToParameters(getContext(), p, PARAM_MEMBER_PATIENT, thePatient); - ParametersUtil.addParameterToParameters(getContext(), p, PARAM_OLD_COVERAGE, theOldCoverage); - ParametersUtil.addParameterToParameters(getContext(), p, PARAM_NEW_COVERAGE, theNewCoverage); + ParametersUtil.addParameterToParameters(this.getFhirContext(), p, PARAM_MEMBER_PATIENT, thePatient); + ParametersUtil.addParameterToParameters(this.getFhirContext(), p, PARAM_OLD_COVERAGE, theOldCoverage); + ParametersUtil.addParameterToParameters(this.getFhirContext(), p, PARAM_NEW_COVERAGE, theNewCoverage); return p; } @@ -339,12 +339,12 @@ public class PatientMemberMatchOperationR4Test extends BaseResourceProviderR4Tes HttpPost post = new HttpPost(theUrl); post.addHeader(Constants.HEADER_ACCEPT_ENCODING, theEncoding.toString()); - post.setEntity(new ResourceEntity(getContext(), theInputParameters)); + post.setEntity(new ResourceEntity(this.getFhirContext(), theInputParameters)); ourLog.info("Request: {}", post); try (CloseableHttpResponse response = ourHttpClient.execute(post)) { assertEquals(200, response.getStatusLine().getStatusCode()); - return theEncoding.newParser(myFhirCtx).parseResource(Parameters.class, + return theEncoding.newParser(myFhirContext).parseResource(Parameters.class, IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8)); } } @@ -355,7 +355,7 @@ public class PatientMemberMatchOperationR4Test extends BaseResourceProviderR4Tes HttpPost post = new HttpPost(theUrl); post.addHeader(Constants.HEADER_ACCEPT_ENCODING, theEncoding.toString()); - post.setEntity(new ResourceEntity(getContext(), theInputParameters)); + post.setEntity(new ResourceEntity(this.getFhirContext(), theInputParameters)); ourLog.info("Request: {}", post); try (CloseableHttpResponse response = ourHttpClient.execute(post)) { String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderConcurrencyR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderConcurrencyR4Test.java index 8cc5fd02918..fc7ab941960 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderConcurrencyR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderConcurrencyR4Test.java @@ -95,7 +95,7 @@ public class ResourceProviderConcurrencyR4Test extends BaseResourceProviderR4Tes try (CloseableHttpResponse outcome = ourHttpClient.execute(get)) { assertEquals(200, outcome.getStatusLine().getStatusCode()); String outcomeString = IOUtils.toString(outcome.getEntity().getContent(), StandardCharsets.UTF_8); - Bundle bundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, outcomeString); + Bundle bundle = myFhirContext.newJsonParser().parseResource(Bundle.class, outcomeString); assertEquals(1, bundle.getEntry().size()); Patient pt = (Patient) bundle.getEntry().get(0).getResource(); String family = pt.getNameFirstRep().getFamily(); @@ -119,7 +119,7 @@ public class ResourceProviderConcurrencyR4Test extends BaseResourceProviderR4Tes try (CloseableHttpResponse outcome = ourHttpClient.execute(get)) { assertEquals(200, outcome.getStatusLine().getStatusCode()); String outcomeString = IOUtils.toString(outcome.getEntity().getContent(), StandardCharsets.UTF_8); - Bundle bundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, outcomeString); + Bundle bundle = myFhirContext.newJsonParser().parseResource(Bundle.class, outcomeString); assertEquals(1, bundle.getEntry().size()); Patient pt = (Patient) bundle.getEntry().get(0).getResource(); String family = pt.getNameFirstRep().getFamily(); @@ -141,7 +141,7 @@ public class ResourceProviderConcurrencyR4Test extends BaseResourceProviderR4Tes try (CloseableHttpResponse outcome = ourHttpClient.execute(get)) { assertEquals(200, outcome.getStatusLine().getStatusCode()); String outcomeString = IOUtils.toString(outcome.getEntity().getContent(), StandardCharsets.UTF_8); - Bundle bundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, outcomeString); + Bundle bundle = myFhirContext.newJsonParser().parseResource(Bundle.class, outcomeString); assertEquals(1, bundle.getEntry().size()); Patient pt = (Patient) bundle.getEntry().get(0).getResource(); String family = pt.getNameFirstRep().getFamily(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderCustomSearchParamR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderCustomSearchParamR4Test.java index 69169b59ad2..4d67a9c4dcc 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderCustomSearchParamR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderCustomSearchParamR4Test.java @@ -303,7 +303,7 @@ public class ResourceProviderCustomSearchParamR4Test extends BaseResourceProvide eyeColourSp.setXpathUsage(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL); eyeColourSp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(eyeColourSp)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(eyeColourSp)); myClient .create() @@ -317,7 +317,7 @@ public class ResourceProviderCustomSearchParamR4Test extends BaseResourceProvide p1.addExtension().setUrl("http://acme.org/eyecolour").setValue(new CodeType("blue")); IIdType p1id = myPatientDao.create(p1).getId().toUnqualifiedVersionless(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p1)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(p1)); Patient p2 = new Patient(); p2.setActive(true); @@ -331,7 +331,7 @@ public class ResourceProviderCustomSearchParamR4Test extends BaseResourceProvide .returnBundle(Bundle.class) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); List foundResources = toUnqualifiedVersionlessIdValues(bundle); assertThat(foundResources, contains(p1id.getValue())); @@ -533,7 +533,7 @@ public class ResourceProviderCustomSearchParamR4Test extends BaseResourceProvide .next(bundle) .execute(); } - List resources = BundleUtil.toListOfResources(myFhirCtx, bundle); + List resources = BundleUtil.toListOfResources(myFhirContext, bundle); resources.forEach(t -> actualIds.add(t.getIdElement().getIdPartAsLong())); foundCount += resources.size(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderExpungeR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderExpungeR4Test.java index 5576a787f1c..46aedec0e9c 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderExpungeR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderExpungeR4Test.java @@ -146,7 +146,7 @@ public class ResourceProviderExpungeR4Test extends BaseResourceProviderR4Test { .setName(ProviderConstants.OPERATION_EXPUNGE_PARAM_EXPUNGE_PREVIOUS_VERSIONS) .setValue(new BooleanType(true)); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(input)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(input)); Parameters output = myClient .operation() @@ -219,7 +219,7 @@ public class ResourceProviderExpungeR4Test extends BaseResourceProviderR4Test { .setName(ProviderConstants.OPERATION_EXPUNGE_PARAM_EXPUNGE_EVERYTHING) .setValue(new BooleanType(true)); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(input)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(input)); Parameters output = myClient .operation() @@ -258,7 +258,7 @@ public class ResourceProviderExpungeR4Test extends BaseResourceProviderR4Test { .setName(ProviderConstants.OPERATION_EXPUNGE_PARAM_EXPUNGE_PREVIOUS_VERSIONS) .setValue(new BooleanType(true)); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(input)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(input)); Parameters output = myClient .operation() @@ -304,7 +304,7 @@ public class ResourceProviderExpungeR4Test extends BaseResourceProviderR4Test { .setName(ProviderConstants.OPERATION_EXPUNGE_PARAM_EXPUNGE_PREVIOUS_VERSIONS) .setValue(new BooleanType(true)); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(input)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(input)); Parameters output = myClient .operation() diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderHasParamR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderHasParamR4Test.java index 25455525c47..981ab4bbcfe 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderHasParamR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderHasParamR4Test.java @@ -1,16 +1,9 @@ package ca.uhn.fhir.jpa.provider.r4; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.contains; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - +import ca.uhn.fhir.jpa.api.config.DaoConfig; +import ca.uhn.fhir.parser.StrictErrorHandler; +import ca.uhn.fhir.rest.client.interceptor.CapturingInterceptor; +import ca.uhn.fhir.util.UrlUtil; import org.apache.commons.io.IOUtils; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; @@ -32,10 +25,16 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.parser.StrictErrorHandler; -import ca.uhn.fhir.rest.client.interceptor.CapturingInterceptor; -import ca.uhn.fhir.util.UrlUtil; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.contains; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; public class ResourceProviderHasParamR4Test extends BaseResourceProviderR4Test { @@ -63,7 +62,7 @@ public class ResourceProviderHasParamR4Test extends BaseResourceProviderR4Test { @Override public void before() throws Exception { super.before(); - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); myDaoConfig.setAllowMultipleDelete(true); myClient.registerInterceptor(myCapturingInterceptor); @@ -109,7 +108,7 @@ public class ResourceProviderHasParamR4Test extends BaseResourceProviderR4Test { obs.setDevice(new Reference(devId)); myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } @@ -161,7 +160,7 @@ public class ResourceProviderHasParamR4Test extends BaseResourceProviderR4Test { myEncounterDao.create(encounter, mySrd); - ourLog.info("Encounter: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); + ourLog.info("Encounter: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); } String uri = ourServerBase + "/Patient?_has:Encounter:subject:class=" + UrlUtil.escapeUrlParam("urn:system|IMP") + "&_has:Encounter:subject:date=gt1950"; @@ -197,7 +196,7 @@ public class ResourceProviderHasParamR4Test extends BaseResourceProviderR4Test { cc.addCoding().setCode("2345-7").setSystem("http://loinc.org"); myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { Device device = new Device(); @@ -218,7 +217,7 @@ public class ResourceProviderHasParamR4Test extends BaseResourceProviderR4Test { encounter.setSubject(new Reference(pid0)); myEncounterDao.create(encounter, mySrd); - ourLog.info("Encounter: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); + ourLog.info("Encounter: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); } String uri = ourServerBase + "/Patient?_has:Observation:patient:code=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-7") + "&_has:Encounter:subject:date=gt1950"; @@ -257,7 +256,7 @@ public class ResourceProviderHasParamR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { Device device = new Device(); @@ -305,7 +304,7 @@ public class ResourceProviderHasParamR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { Device device = new Device(); @@ -361,7 +360,7 @@ public class ResourceProviderHasParamR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { Device device = new Device(); @@ -407,7 +406,7 @@ public class ResourceProviderHasParamR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -421,7 +420,7 @@ public class ResourceProviderHasParamR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { Device device = new Device(); @@ -469,7 +468,7 @@ public class ResourceProviderHasParamR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { Device device = new Device(); @@ -516,7 +515,7 @@ public class ResourceProviderHasParamR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { Device device = new Device(); @@ -566,7 +565,7 @@ public class ResourceProviderHasParamR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { Device device = new Device(); @@ -587,7 +586,7 @@ public class ResourceProviderHasParamR4Test extends BaseResourceProviderR4Test { encounter.setSubject(new Reference(pid0)); myEncounterDao.create(encounter, mySrd); - ourLog.info("Encounter: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); + ourLog.info("Encounter: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); } String uri = ourServerBase + "/Patient?_has:Observation:subject:code-value-quantity=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-7$gt180") + "&_has:Encounter:subject:date=gt1950" + "&_has:Encounter:subject:class=" + UrlUtil.escapeUrlParam("urn:system|IMP"); @@ -631,7 +630,7 @@ public class ResourceProviderHasParamR4Test extends BaseResourceProviderR4Test { try (CloseableHttpResponse response = ourHttpClient.execute(get)) { String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info("Response was: {}", resp); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, resp); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, resp); ids = toUnqualifiedVersionlessIdValues(bundle); } return ids; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderInterceptorR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderInterceptorR4Test.java index 8d02586a564..bb1791cc10c 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderInterceptorR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderInterceptorR4Test.java @@ -168,7 +168,7 @@ public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Tes Patient pt = new Patient(); pt.addName().setFamily(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); IAnonymousInterceptor interceptor = mock(IAnonymousInterceptor.class); ourRestServer.getInterceptorService().registerAnonymousInterceptor(Pointcut.SERVER_INCOMING_REQUEST_PRE_HANDLED, interceptor); @@ -236,7 +236,7 @@ public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Tes .returnBundle(Bundle.class) .execute(); assertEquals(1, observations.getEntry().size()); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(observations)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(observations)); } finally { ourRestServer.unregisterInterceptor(interceptor); @@ -257,7 +257,7 @@ public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Tes pt.addName().setFamily(methodName); pt.setManagingOrganization(new Reference(orgId)); - IParser parser = myFhirCtx.newXmlParser(); + IParser parser = myFhirContext.newXmlParser(); parser.setDontStripVersionsFromReferencesAtPaths("Patient.managingOrganization"); parser.setPrettyPrint(true); String resource = parser.encodeResourceToString(pt); @@ -323,7 +323,7 @@ public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Tes private void transaction(Bundle theBundle) throws IOException { - String resource = myFhirCtx.newXmlParser().encodeResourceToString(theBundle); + String resource = myFhirContext.newXmlParser().encodeResourceToString(theBundle); HttpPost post = new HttpPost(ourServerBase + "/"); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); try (CloseableHttpResponse response = ourHttpClient.execute(post)) { diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderQuestionnaireResponseR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderQuestionnaireResponseR4Test.java index eff9f35f078..90ff93727ba 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderQuestionnaireResponseR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderQuestionnaireResponseR4Test.java @@ -1,37 +1,41 @@ package ca.uhn.fhir.jpa.provider.r4; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.startsWith; -import static org.junit.jupiter.api.Assertions.*; +import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; +import ca.uhn.fhir.rest.api.server.IBundleProvider; +import ca.uhn.fhir.rest.param.TokenParam; +import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; +import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; +import ca.uhn.fhir.validation.IValidatorModule; +import ca.uhn.fhir.validation.ResultSeverityEnum; +import org.apache.commons.io.IOUtils; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.hl7.fhir.instance.model.api.IIdType; +import org.hl7.fhir.r4.model.DecimalType; +import org.hl7.fhir.r4.model.IdType; +import org.hl7.fhir.r4.model.Patient; +import org.hl7.fhir.r4.model.Questionnaire; +import org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType; +import org.hl7.fhir.r4.model.QuestionnaireResponse; +import org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.Collections; -import ca.uhn.fhir.context.RuntimeResourceDefinition; -import ca.uhn.fhir.jpa.entity.Search; -import ca.uhn.fhir.jpa.searchparam.MatchUrlService; -import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; -import ca.uhn.fhir.rest.api.server.IBundleProvider; -import ca.uhn.fhir.rest.param.TokenParam; -import org.apache.commons.io.IOUtils; -import org.apache.http.client.methods.*; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.jena.base.Sys; -import org.hl7.fhir.r4.model.*; -import org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType; -import org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus; -import org.hl7.fhir.instance.model.api.IIdType; -import org.junit.jupiter.api.*; import static org.hamcrest.MatcherAssert.assertThat; - -import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; -import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; -import ca.uhn.fhir.validation.IValidatorModule; -import ca.uhn.fhir.validation.ResultSeverityEnum; -import org.springframework.beans.factory.annotation.Autowired; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.startsWith; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class ResourceProviderQuestionnaireResponseR4Test extends BaseResourceProviderR4Test { @@ -105,7 +109,7 @@ public class ResourceProviderQuestionnaireResponseR4Test extends BaseResourcePro myClient.create().resource(qr1).execute(); fail(); } catch (UnprocessableEntityException e) { - assertThat(myFhirCtx.newJsonParser().encodeResourceToString(e.getOperationOutcome()), containsString("Answer value must be of type string")); + assertThat(myFhirContext.newJsonParser().encodeResourceToString(e.getOperationOutcome()), containsString("Answer value must be of type string")); } } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4BundleTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4BundleTest.java index c95011b3cc4..89f6d0f1213 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4BundleTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4BundleTest.java @@ -1,17 +1,8 @@ package ca.uhn.fhir.jpa.provider.r4; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - +import ca.uhn.fhir.jpa.api.config.DaoConfig; +import ca.uhn.fhir.jpa.model.util.JpaConstants; +import ca.uhn.fhir.rest.server.exceptions.NotImplementedOperationException; import com.google.common.base.Charsets; import org.apache.commons.io.IOUtils; import org.hl7.fhir.instance.model.api.IIdType; @@ -28,9 +19,17 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.jpa.model.util.JpaConstants; -import ca.uhn.fhir.rest.server.exceptions.NotImplementedOperationException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class ResourceProviderR4BundleTest extends BaseResourceProviderR4Test { @@ -68,7 +67,7 @@ public class ResourceProviderR4BundleTest extends BaseResourceProviderR4Test { Bundle retBundle = myClient.read().resource(Bundle.class).withId(id).execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(retBundle)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(retBundle)); assertEquals("http://foo/", bundle.getEntry().get(0).getFullUrl()); } @@ -121,7 +120,7 @@ public class ResourceProviderR4BundleTest extends BaseResourceProviderR4Test { public void testHighConcurrencyWorks() throws IOException, InterruptedException { List bundles = new ArrayList<>(); for (int i =0 ; i < 10; i ++) { - bundles.add(myFhirCtx.newJsonParser().parseResource(Bundle.class, IOUtils.toString(getClass().getResourceAsStream("/r4/identical-tags-batch.json"), Charsets.UTF_8))); + bundles.add(myFhirContext.newJsonParser().parseResource(Bundle.class, IOUtils.toString(getClass().getResourceAsStream("/r4/identical-tags-batch.json"), Charsets.UTF_8))); } ExecutorService tpe = Executors.newFixedThreadPool(4); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CacheTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CacheTest.java index c93002adf6f..65760a6d3f7 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CacheTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CacheTest.java @@ -29,7 +29,6 @@ import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.lessThan; import static org.hamcrest.core.IsNot.not; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.fail; @@ -55,7 +54,7 @@ public class ResourceProviderR4CacheTest extends BaseResourceProviderR4Test { @Override public void before() throws Exception { super.before(); - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); myCapturingInterceptor = new CapturingInterceptor(); myClient.registerInterceptor(myCapturingInterceptor); @@ -228,7 +227,7 @@ public class ResourceProviderR4CacheTest extends BaseResourceProviderR4Test { assertEquals(resp1.getId(), resp2.getId()); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp2)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp2)); assertEquals(1, resp2.getEntry().size()); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CodeSystemDesignationTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CodeSystemDesignationTest.java index 5f53a3afcd9..6bbcb06e0c6 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CodeSystemDesignationTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CodeSystemDesignationTest.java @@ -1,12 +1,5 @@ package ca.uhn.fhir.jpa.provider.r4; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - import org.hl7.fhir.r4.model.BooleanType; import org.hl7.fhir.r4.model.CodeSystem; import org.hl7.fhir.r4.model.CodeType; @@ -18,6 +11,13 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.transaction.annotation.Transactional; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + public class ResourceProviderR4CodeSystemDesignationTest extends BaseResourceProviderR4Test { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderR4CodeSystemDesignationTest.class); @@ -42,7 +42,7 @@ public class ResourceProviderR4CodeSystemDesignationTest extends BaseResourcePro .andParameter("displayLanguage",new CodeType("de-AT")) .execute(); - String resp = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); //-- The designations should have de-AT and default language @@ -68,7 +68,7 @@ public class ResourceProviderR4CodeSystemDesignationTest extends BaseResourcePro .andParameter("displayLanguage",new CodeType("zh-CN")) .execute(); - String resp = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); //-- The designations should have default language only @@ -92,7 +92,7 @@ public class ResourceProviderR4CodeSystemDesignationTest extends BaseResourcePro .andParameter("system", new UriType(CS_ACME_URL)) .execute(); - String resp = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); //-- The designations should have all languages and the default language @@ -121,7 +121,7 @@ public class ResourceProviderR4CodeSystemDesignationTest extends BaseResourcePro .andParameter("displayLanguage",new CodeType("de-AT")) .execute(); - String resp = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); //-- The designations should have de-AT and default language @@ -144,7 +144,7 @@ public class ResourceProviderR4CodeSystemDesignationTest extends BaseResourcePro .andParameter("displayLanguage",new CodeType("zh-CN")) .execute(); - resp = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); //-- The designations should have default language only @@ -165,7 +165,7 @@ public class ResourceProviderR4CodeSystemDesignationTest extends BaseResourcePro .andParameter("system", new UriType(CS_ACME_URL)) .execute(); - resp = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); //-- The designations should have all languages and the default language @@ -189,7 +189,7 @@ public class ResourceProviderR4CodeSystemDesignationTest extends BaseResourcePro .andParameter("displayLanguage",new CodeType("fr-FR")) .execute(); - resp = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); //-- The designations should have fr-FR languages and the default language diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CodeSystemTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CodeSystemTest.java index bd1370277f9..3e5f9596ce1 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CodeSystemTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CodeSystemTest.java @@ -78,7 +78,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test .andParameter("system", new UriType(FhirResourceDaoR4TerminologyTest.URL_MY_CODE_SYSTEM)) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -100,7 +100,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test .useHttpGet() .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -124,7 +124,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test .andParameter("system", new UriType("http://terminology.hl7.org/CodeSystem/v2-0203")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -163,7 +163,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test .andParameter("system", new UriType("http://acme.org")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -199,7 +199,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test .withParameter(Parameters.class, "coding", new Coding().setSystem("http://acme.org").setCode("8450-9")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -268,7 +268,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test .andParameter("system", new UriType("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -292,7 +292,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test .andParameter("system", new UriType(SYSTEM_PARENTCHILD)) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -312,7 +312,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test .andParameter("system", new UriType(SYSTEM_PARENTCHILD)) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -331,7 +331,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test .andParameter("system", new UriType(SYSTEM_PARENTCHILD)) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -398,7 +398,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test .andParameter("codingB", new Coding().setSystem(SYSTEM_PARENTCHILD).setCode("ChildAA")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -417,7 +417,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test .andParameter("codingB", new Coding().setSystem(SYSTEM_PARENTCHILD).setCode("ParentA")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -435,7 +435,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test .andParameter("codingB", new Coding().setSystem(SYSTEM_PARENTCHILD).setCode("ParentB")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -449,7 +449,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test CodeSystem initialCodeSystem = myClient.read().resource(CodeSystem.class).withId(parentChildCsId).execute(); assertEquals("Parent Child CodeSystem", initialCodeSystem.getName()); initialCodeSystem.setName("Updated Parent Child CodeSystem"); - String encoded = myFhirCtx.newJsonParser().encodeResourceToString(initialCodeSystem); + String encoded = myFhirContext.newJsonParser().encodeResourceToString(initialCodeSystem); HttpPut putRequest = new HttpPut(ourServerBase + "/CodeSystem/" + parentChildCsId); putRequest.setEntity(new StringEntity(encoded, ContentType.parse("application/json+fhir"))); CloseableHttpResponse resp = ourHttpClient.execute(putRequest); @@ -472,7 +472,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test Parameters respParam = myClient.operation().onType(CodeSystem.class).named("validate-code").withParameters(inParams).execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -489,7 +489,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test Parameters respParam = myClient.operation().onType(CodeSystem.class).named("validate-code").withParameters(inParams).execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -507,7 +507,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test Parameters respParam = myClient.operation().onType(CodeSystem.class).named("validate-code").withParameters(inParams).execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -525,7 +525,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test Parameters respParam = myClient.operation().onType(CodeSystem.class).named("validate-code").withParameters(inParams).execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -554,7 +554,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test Parameters respParam = myClient.operation().onInstance(myCsId).named("validate-code").withParameters(inParams).execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -616,7 +616,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test Parameters respParam = myClient.operation().onType(CodeSystem.class).named("validate-code").withParameters(inParams).execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -633,7 +633,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test Parameters respParam = myClient.operation().onType(CodeSystem.class).named("validate-code").withParameters(inParams).execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -665,7 +665,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test Parameters respParam = myClient.operation().onType(CodeSystem.class).named("validate-code").withParameters(inParams).execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -682,7 +682,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test Parameters respParam = myClient.operation().onType(CodeSystem.class).named("validate-code").withParameters(inParams).execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -702,7 +702,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test Parameters respParam = myClient.operation().onType(CodeSystem.class).named("validate-code").withParameters(inParams).execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -722,7 +722,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test Parameters respParam = myClient.operation().onType(CodeSystem.class).named("validate-code").withParameters(inParams).execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -742,7 +742,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test Parameters respParam = myClient.operation().onType(CodeSystem.class).named("validate-code").withParameters(inParams).execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -762,7 +762,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test Parameters respParam = myClient.operation().onType(CodeSystem.class).named("validate-code").withParameters(inParams).execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -800,7 +800,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test Parameters respParam = myClient.operation().onType(CodeSystem.class).named("validate-code").withParameters(inParams).execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(true, ((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -820,7 +820,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test Parameters respParam = myClient.operation().onType(CodeSystem.class).named("validate-code").withParameters(inParams).execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(true, ((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -840,7 +840,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test Parameters respParam = myClient.operation().onType(CodeSystem.class).named("validate-code").withParameters(inParams).execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(true, ((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -861,7 +861,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test Parameters respParam = myClient.operation().onType(CodeSystem.class).named("validate-code").withParameters(inParams).execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam)); assertEquals(true, ((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); assertEquals("Code v1 display", ((StringType) respParam.getParameter().get(1).getValue()).getValueAsString()); @@ -882,7 +882,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test Parameters respParam = myClient.operation().onType(CodeSystem.class).named("validate-code").withParameters(inParams).execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam)); assertEquals(true, ((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); assertEquals("Code v2 display", ((StringType) respParam.getParameter().get(1).getValue()).getValueAsString()); @@ -902,7 +902,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test Parameters respParam = myClient.operation().onType(CodeSystem.class).named("validate-code").withParameters(inParams).execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam)); assertEquals(true, ((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); assertEquals("Code v2 display", ((StringType) respParam.getParameter().get(1).getValue()).getValueAsString()); @@ -921,7 +921,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test Parameters respParam = myClient.operation().onType(CodeSystem.class).named("validate-code").withParameters(inParams).execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam)); assertEquals(true, ((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); assertEquals("Code v2 display", ((StringType) respParam.getParameter().get(1).getValue()).getValueAsString()); @@ -941,7 +941,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test Parameters respParam = myClient.operation().onType(CodeSystem.class).named("validate-code").withParameters(inParams).execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam)); assertEquals(true, ((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); assertEquals("Code v2 display", ((StringType) respParam.getParameter().get(1).getValue()).getValueAsString()); @@ -961,7 +961,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test CodeSystem.ConceptDefinitionComponent concept2 = codeSystem.addConcept(); concept2.setCode("2000").setDisplay("Code Dispaly 2000"); - ourLog.info("CodeSystem: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); myCodeSystemDao.create(codeSystem, mySrd); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CodeSystemVersionedTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CodeSystemVersionedTest.java index decae84d973..0cf7519d6cc 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CodeSystemVersionedTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CodeSystemVersionedTest.java @@ -104,7 +104,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("system", new UriType(FhirResourceDaoR4TerminologyTest.URL_MY_CODE_SYSTEM)) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -126,7 +126,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .useHttpGet() .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -148,7 +148,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("version", new StringType("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -171,7 +171,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .useHttpGet() .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -193,7 +193,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("version", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -216,7 +216,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .useHttpGet() .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -240,7 +240,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("system", new UriType("http://terminology.hl7.org/CodeSystem/v2-0203")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -262,7 +262,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("version", new StringType("2.9")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -303,7 +303,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("system", new UriType("http://acme.org")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -325,7 +325,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("version", new StringType("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -347,7 +347,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("version", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -387,7 +387,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .withParameter(Parameters.class, "coding", new Coding().setSystem("http://acme.org").setCode("8450-9")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -407,7 +407,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .withParameter(Parameters.class, "coding", new Coding().setSystem("http://acme.org").setCode("8450-9").setVersion("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -427,7 +427,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .withParameter(Parameters.class, "coding", new Coding().setSystem("http://acme.org").setCode("8450-9").setVersion("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("name", respParam.getParameter().get(0).getName()); @@ -453,7 +453,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("system", new UriType(SYSTEM_PARENTCHILD)) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -471,7 +471,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("version", new StringType("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -489,7 +489,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("version", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -510,7 +510,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("system", new UriType(SYSTEM_PARENTCHILD)) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -528,7 +528,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("version", new StringType("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -546,7 +546,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("version", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -566,7 +566,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("system", new UriType(SYSTEM_PARENTCHILD)) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -584,7 +584,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("version", new StringType("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -602,7 +602,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("version", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -639,7 +639,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("codingB", new Coding().setSystem(SYSTEM_PARENTCHILD).setCode("ParentB")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -655,7 +655,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("codingB", new Coding().setSystem(SYSTEM_PARENTCHILD).setCode("ParentC").setVersion("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -671,7 +671,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("codingB", new Coding().setSystem(SYSTEM_PARENTCHILD).setCode("ParentB").setVersion("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -692,7 +692,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("codingB", new Coding().setSystem(SYSTEM_PARENTCHILD).setCode("ParentA")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -708,7 +708,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("codingB", new Coding().setSystem(SYSTEM_PARENTCHILD).setCode("ParentA").setVersion("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -724,7 +724,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("codingB", new Coding().setSystem(SYSTEM_PARENTCHILD).setCode("ParentA").setVersion("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -744,7 +744,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("codingB", new Coding().setSystem(SYSTEM_PARENTCHILD).setCode("ParentC")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -760,7 +760,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("codingB", new Coding().setSystem(SYSTEM_PARENTCHILD).setCode("ParentB").setVersion("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -776,7 +776,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi .andParameter("codingB", new Coding().setSystem(SYSTEM_PARENTCHILD).setCode("ParentC").setVersion("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(1, respParam.getParameter().size()); @@ -791,7 +791,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi CodeSystem initialCodeSystem = myClient.read().resource(CodeSystem.class).withId(parentChildCs1Id).execute(); assertEquals("Parent Child CodeSystem 1", initialCodeSystem.getName()); initialCodeSystem.setName("Updated Parent Child CodeSystem 1"); - String encoded = myFhirCtx.newJsonParser().encodeResourceToString(initialCodeSystem); + String encoded = myFhirContext.newJsonParser().encodeResourceToString(initialCodeSystem); HttpPut putRequest = new HttpPut(ourServerBase + "/CodeSystem/" + parentChildCs1Id); putRequest.setEntity(new StringEntity(encoded, ContentType.parse("application/json+fhir"))); myCaptureQueriesListener.clear(); @@ -809,7 +809,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi initialCodeSystem = myClient.read().resource(CodeSystem.class).withId(parentChildCs2Id).execute(); assertEquals("Parent Child CodeSystem 2", initialCodeSystem.getName()); initialCodeSystem.setName("Updated Parent Child CodeSystem 2"); - encoded = myFhirCtx.newJsonParser().encodeResourceToString(initialCodeSystem); + encoded = myFhirContext.newJsonParser().encodeResourceToString(initialCodeSystem); putRequest = new HttpPut(ourServerBase + "/CodeSystem/" + parentChildCs2Id); putRequest.setEntity(new StringEntity(encoded, ContentType.parse("application/json+fhir"))); resp = ourHttpClient.execute(putRequest); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ConceptMapTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ConceptMapTest.java index d5eac98d7d4..21b018f8071 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ConceptMapTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ConceptMapTest.java @@ -1,10 +1,6 @@ package ca.uhn.fhir.jpa.provider.r4; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - +import ca.uhn.fhir.rest.api.MethodOutcome; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.model.BooleanType; import org.hl7.fhir.r4.model.Bundle; @@ -26,10 +22,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.transaction.annotation.Transactional; -import ca.uhn.fhir.rest.api.MethodOutcome; - import java.io.IOException; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test { private static final Logger ourLog = LoggerFactory.getLogger(ResourceProviderR4ConceptMapTest.class); @@ -75,14 +74,14 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateByCodeSystemsAndSourceCodeOneToMany() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); Parameters inParams = new Parameters(); inParams.addParameter().setName("system").setValue(new UriType(CS_URL)); inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_3)); inParams.addParameter().setName("code").setValue(new CodeType("12345")); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -91,7 +90,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -133,14 +132,14 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateByCodeSystemsAndSourceCodeOneToOne() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); Parameters inParams = new Parameters(); inParams.addParameter().setName("system").setValue(new UriType(CS_URL)); inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2)); inParams.addParameter().setName("code").setValue(new CodeType("12345")); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -149,7 +148,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -179,7 +178,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateByCodeSystemsAndSourceCodeOneToOne_InBatchOperation() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); Bundle bundle = new Bundle(); bundle.setType(Bundle.BundleType.BATCH); @@ -189,14 +188,14 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .setMethod(Bundle.HTTPVerb.GET) .setUrl("ConceptMap/$translate?system=" + CS_URL + "&code=12345" + "&targetsystem=" + CS_URL_2); - ourLog.info("Request:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info("Request:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); Bundle respBundle = myClient .transaction() .withBundle(bundle) .execute(); - ourLog.info("Response:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respBundle)); + ourLog.info("Response:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respBundle)); assertEquals(1, respBundle.getEntry().size()); Parameters respParams = (Parameters) respBundle.getEntry().get(0).getResource(); @@ -237,14 +236,14 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .setMethod(Bundle.HTTPVerb.GET) .setUrl("ConceptMap/$translate?url=http://hl7.org/fhir/ConceptMap/CMapHie&system=http://fkcfhir.org/fhir/cs/FMCECCOrderAbbreviation&code=IMed_Janssen&targetsystem=http://fkcfhir.org/fhir/cs/FMCHIEOrderAbbreviation"); - ourLog.info("Request:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info("Request:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); Bundle respBundle = myClient .transaction() .withBundle(bundle) .execute(); - ourLog.info("Response:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respBundle)); + ourLog.info("Response:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respBundle)); assertEquals(1, respBundle.getEntry().size()); Parameters respParams = (Parameters) respBundle.getEntry().get(0).getResource(); @@ -273,14 +272,14 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateByCodeSystemsAndSourceCodeUnmapped() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); Parameters inParams = new Parameters(); inParams.addParameter().setName("system").setValue(new UriType(CS_URL)); inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_3)); inParams.addParameter().setName("code").setValue(new CodeType("BOGUS")); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -289,7 +288,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertFalse(((BooleanType) param.getValue()).booleanValue()); @@ -304,7 +303,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateUsingPredicatesWithCodeOnly() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); /* * Provided: @@ -313,7 +312,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test Parameters inParams = new Parameters(); inParams.addParameter().setName("code").setValue(new CodeType("12345")); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -322,7 +321,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -379,7 +378,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateUsingPredicatesCoding() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); /* * Provided: @@ -391,7 +390,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test inParams.addParameter().setName("coding").setValue( new Coding().setSystem(CS_URL).setCode("12345").setVersion("Version 1")); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -400,7 +399,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -429,7 +428,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateUsingPredicatesWithCodeableConcept() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); /* * Provided: @@ -444,7 +443,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test Parameters inParams = new Parameters(); inParams.addParameter().setName("codeableConcept").setValue(codeableConcept); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -453,7 +452,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -524,7 +523,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateUsingPredicatesWithSourceSystem() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); /* * Provided: @@ -535,7 +534,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test inParams.addParameter().setName("code").setValue(new CodeType("12345")); inParams.addParameter().setName("system").setValue(new UriType(CS_URL)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -544,7 +543,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -601,7 +600,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateUsingPredicatesWithSourceSystemAndVersion1() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); /* * Provided: @@ -614,7 +613,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test inParams.addParameter().setName("system").setValue(new UriType(CS_URL)); inParams.addParameter().setName("version").setValue(new StringType("Version 1")); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -623,7 +622,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -652,7 +651,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateUsingPredicatesWithSourceSystemAndVersion3() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); /* * Provided: @@ -665,7 +664,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test inParams.addParameter().setName("system").setValue(new UriType(CS_URL)); inParams.addParameter().setName("version").setValue(new StringType("Version 3")); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -674,7 +673,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -717,7 +716,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateUsingPredicatesWithSourceAndTargetSystem2() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); /* * Provided: @@ -730,7 +729,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test inParams.addParameter().setName("system").setValue(new UriType(CS_URL)); inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -739,7 +738,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -768,7 +767,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateUsingPredicatesWithSourceAndTargetSystem3() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); /* * Provided: @@ -781,7 +780,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test inParams.addParameter().setName("system").setValue(new UriType(CS_URL)); inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_3)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -790,7 +789,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -833,7 +832,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateUsingPredicatesWithSourceValueSet() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); /* * Provided: @@ -844,7 +843,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test inParams.addParameter().setName("code").setValue(new CodeType("12345")); inParams.addParameter().setName("source").setValue(new UriType(VS_URL)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -853,7 +852,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -910,7 +909,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateUsingPredicatesWithTargetValueSet() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); /* * Provided: @@ -921,7 +920,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test inParams.addParameter().setName("code").setValue(new CodeType("12345")); inParams.addParameter().setName("target").setValue(new UriType(VS_URL_2)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -930,7 +929,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -1002,7 +1001,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test IIdType conceptMapId1 = myConceptMapDao.create(conceptMap1, mySrd).getId().toUnqualifiedVersionless(); conceptMap1 = myConceptMapDao.read(conceptMapId1); - ourLog.info("ConceptMap: 2 \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap1)); + ourLog.info("ConceptMap: 2 \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap1)); //- conceptMap1 v2 ConceptMap conceptMap2 = new ConceptMap(); @@ -1020,7 +1019,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test IIdType conceptMapId2 = myConceptMapDao.create(conceptMap2, mySrd).getId().toUnqualifiedVersionless(); conceptMap2 = myConceptMapDao.read(conceptMapId2); - ourLog.info("ConceptMap: 2 \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap2)); + ourLog.info("ConceptMap: 2 \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap2)); Parameters inParams = new Parameters(); @@ -1030,7 +1029,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2)); inParams.addParameter().setName("code").setValue(new CodeType("11111")); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient @@ -1040,7 +1039,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); @@ -1071,12 +1070,12 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateWithInstance() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); Parameters inParams = new Parameters(); inParams.addParameter().setName("code").setValue(new CodeType("12345")); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -1085,7 +1084,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -1142,7 +1141,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateWithReverse() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); /* * Provided: @@ -1157,7 +1156,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_4)); inParams.addParameter().setName("reverse").setValue(new BooleanType(true)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -1166,7 +1165,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -1195,7 +1194,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateWithReverseByCodeSystemsAndSourceCodeUnmapped() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); Parameters inParams = new Parameters(); inParams.addParameter().setName("system").setValue(new UriType(CS_URL_3)); @@ -1203,7 +1202,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test inParams.addParameter().setName("code").setValue(new CodeType("BOGUS")); inParams.addParameter().setName("reverse").setValue(new BooleanType(true)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -1212,7 +1211,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertFalse(((BooleanType) param.getValue()).booleanValue()); @@ -1227,7 +1226,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateWithReverseUsingPredicatesWithCodeOnly() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); /* * Provided: @@ -1238,7 +1237,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test inParams.addParameter().setName("code").setValue(new CodeType("34567")); inParams.addParameter().setName("reverse").setValue(new BooleanType(true)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -1247,7 +1246,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -1290,7 +1289,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateWithReverseUsingPredicatesCoding() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); /* * Provided: @@ -1304,7 +1303,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test new Coding().setSystem(CS_URL_2).setCode("34567").setVersion("Version 2")); inParams.addParameter().setName("reverse").setValue(new BooleanType(true)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -1313,7 +1312,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -1356,7 +1355,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateWithReverseUsingPredicatesWithCodeableConcept() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); /* * Provided: @@ -1374,7 +1373,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test inParams.addParameter().setName("codeableConcept").setValue(codeableConcept); inParams.addParameter().setName("reverse").setValue(new BooleanType(true)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -1383,7 +1382,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -1454,7 +1453,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateWithReverseUsingPredicatesWithSourceSystem() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); /* * Provided: @@ -1467,7 +1466,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test inParams.addParameter().setName("system").setValue(new UriType(CS_URL_2)); inParams.addParameter().setName("reverse").setValue(new BooleanType(true)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -1476,7 +1475,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -1519,7 +1518,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateWithReverseUsingPredicatesWithSourceSystemAndVersion() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); /* * Provided: @@ -1534,7 +1533,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test inParams.addParameter().setName("version").setValue(new StringType("Version 2")); inParams.addParameter().setName("reverse").setValue(new BooleanType(true)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -1543,7 +1542,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -1586,7 +1585,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateWithReverseUsingPredicatesWithSourceAndTargetSystem1() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); /* * Provided: @@ -1601,7 +1600,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL)); inParams.addParameter().setName("reverse").setValue(new BooleanType(true)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -1610,7 +1609,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -1639,7 +1638,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateWithReverseUsingPredicatesWithSourceAndTargetSystem4() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); /* * Provided: @@ -1654,7 +1653,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_4)); inParams.addParameter().setName("reverse").setValue(new BooleanType(true)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -1663,7 +1662,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -1692,7 +1691,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateWithReverseUsingPredicatesWithSourceValueSet() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); /* * Provided: @@ -1705,7 +1704,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test inParams.addParameter().setName("source").setValue(new UriType(VS_URL_2)); inParams.addParameter().setName("reverse").setValue(new BooleanType(true)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -1714,7 +1713,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -1757,7 +1756,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateWithReverseUsingPredicatesWithTargetValueSet() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); /* * Provided: @@ -1770,7 +1769,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test inParams.addParameter().setName("target").setValue(new UriType(VS_URL)); inParams.addParameter().setName("reverse").setValue(new BooleanType(true)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -1779,7 +1778,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); @@ -1837,7 +1836,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test IIdType conceptMapId1 = myConceptMapDao.create(conceptMap1, mySrd).getId().toUnqualifiedVersionless(); conceptMap1 = myConceptMapDao.read(conceptMapId1); - ourLog.info("ConceptMap: 2 \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap1)); + ourLog.info("ConceptMap: 2 \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap1)); //- conceptMap1 v2 ConceptMap conceptMap2 = new ConceptMap(); @@ -1855,7 +1854,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test IIdType conceptMapId2 = myConceptMapDao.create(conceptMap2, mySrd).getId().toUnqualifiedVersionless(); conceptMap2 = myConceptMapDao.read(conceptMapId2); - ourLog.info("ConceptMap: 2 \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap2)); + ourLog.info("ConceptMap: 2 \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap2)); Parameters inParams = new Parameters(); @@ -1864,7 +1863,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test inParams.addParameter().setName("code").setValue(new CodeType("11111")); inParams.addParameter().setName("reverse").setValue(new BooleanType(true)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient @@ -1874,7 +1873,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); @@ -1905,13 +1904,13 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test public void testTranslateWithReverseAndInstance() { ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); Parameters inParams = new Parameters(); inParams.addParameter().setName("code").setValue(new CodeType("34567")); inParams.addParameter().setName("reverse").setValue(new BooleanType(true)); - ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); + ourLog.info("Request Parameters:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams)); Parameters respParams = myClient .operation() @@ -1920,7 +1919,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test .withParameters(inParams) .execute(); - ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); + ourLog.info("Response Parameters\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams)); ParametersParameterComponent param = getParameterByName(respParams, "result"); assertTrue(((BooleanType) param.getValue()).booleanValue()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ElasticTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ElasticTest.java index 99dfcfefa72..367f5b325d1 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ElasticTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ElasticTest.java @@ -30,8 +30,9 @@ import java.util.List; import java.util.Objects; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -76,7 +77,7 @@ public class ResourceProviderR4ElasticTest extends BaseResourceProviderR4Test { // then assertEquals(Constants.STATUS_HTTP_200_OK, response.getStatusLine().getStatusCode()); String text = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); - ValueSet valueSet = myFhirCtx.newXmlParser().parseResource(ValueSet.class, text); + ValueSet valueSet = myFhirContext.newXmlParser().parseResource(ValueSet.class, text); ourLog.info("testAutocompleteDirectionExisting {}", text); assertThat(valueSet, is(not(nullValue()))); List expansions = valueSet.getExpansion().getContains(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4RemoteTerminologyTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4RemoteTerminologyTest.java index 03fbee5460f..7ac385d3e63 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4RemoteTerminologyTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4RemoteTerminologyTest.java @@ -1,7 +1,7 @@ package ca.uhn.fhir.jpa.provider.r4; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.jpa.config.BaseConfig; +import ca.uhn.fhir.jpa.config.JpaConfig; import ca.uhn.fhir.jpa.model.util.JpaConstants; import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.Operation; @@ -61,7 +61,7 @@ public class ResourceProviderR4RemoteTerminologyTest extends BaseResourceProvide private RemoteTerminologyServiceValidationSupport mySvc; @Autowired - @Qualifier(BaseConfig.JPA_VALIDATION_SUPPORT_CHAIN) + @Qualifier(JpaConfig.JPA_VALIDATION_SUPPORT_CHAIN) private ValidationSupportChain myValidationSupportChain; @BeforeEach @@ -104,7 +104,7 @@ public class ResourceProviderR4RemoteTerminologyTest extends BaseResourceProvide .andParameter("url", new UriType("http://terminology.hl7.org/CodeSystem/v2-0247")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(true, ((BooleanType)respParam.getParameter("result")).booleanValue()); @@ -129,7 +129,7 @@ public class ResourceProviderR4RemoteTerminologyTest extends BaseResourceProvide .useHttpGet() .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(true, ((BooleanType)respParam.getParameter("result")).booleanValue()); @@ -153,7 +153,7 @@ public class ResourceProviderR4RemoteTerminologyTest extends BaseResourceProvide .andParameter("system", new UriType("http://loinc.org")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(true, ((BooleanType)respParam.getParameter("result")).booleanValue()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4SearchContainedTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4SearchContainedTest.java index 1419d2182dd..bb790c40aa3 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4SearchContainedTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4SearchContainedTest.java @@ -75,7 +75,7 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR @Override public void before() throws Exception { super.before(); - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); myDaoConfig.setAllowMultipleDelete(true); myClient.registerInterceptor(myCapturingInterceptor); @@ -125,7 +125,7 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR oid1 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -140,7 +140,7 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -155,7 +155,7 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } @@ -208,7 +208,7 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR oid1 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -224,7 +224,7 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -240,7 +240,7 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR oid3 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } //-- Search by date default op @@ -312,13 +312,13 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR imp.getContained().add(risk); imp.getInvestigationFirstRep().getItemFirstRep().setReference("#risk1"); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(imp)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(imp)); cid1 = myClinicalImpressionDao.create(imp, mySrd).getId().toUnqualifiedVersionless(); ClinicalImpression createdImp = myClinicalImpressionDao.read(cid1); - ourLog.info("Output: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdImp)); + ourLog.info("Output: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdImp)); } { @@ -343,13 +343,13 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR imp.getContained().add(risk); imp.getInvestigationFirstRep().getItemFirstRep().setReference("#risk1"); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(imp)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(imp)); IIdType cid2 = myClinicalImpressionDao.create(imp, mySrd).getId().toUnqualifiedVersionless(); ClinicalImpression createdImp = myClinicalImpressionDao.read(cid2); - ourLog.info("Output: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdImp)); + ourLog.info("Output: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdImp)); } { @@ -374,13 +374,13 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR imp.getContained().add(risk); imp.getInvestigationFirstRep().getItemFirstRep().setReference("#risk1"); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(imp)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(imp)); IIdType cid3 = myClinicalImpressionDao.create(imp, mySrd).getId().toUnqualifiedVersionless(); ClinicalImpression createdImp = myClinicalImpressionDao.read(cid3); - ourLog.info("Output: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdImp)); + ourLog.info("Output: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdImp)); } //-- Search by number @@ -437,13 +437,13 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR encounter.addReasonReference().setReference("#obs1"); encounter.getContained().add(obs); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); eid1 = myEncounterDao.create(encounter, mySrd).getId().toUnqualifiedVersionless(); Encounter createdEncounter = myEncounterDao.read(eid1); - ourLog.info("Output: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEncounter)); + ourLog.info("Output: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEncounter)); } @@ -468,13 +468,13 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR encounter.addReasonReference().setReference("#obs1"); encounter.getContained().add(obs); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); IIdType eid2 = myEncounterDao.create(encounter, mySrd).getId().toUnqualifiedVersionless(); Encounter createdEncounter = myEncounterDao.read(eid2); - ourLog.info("Output: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEncounter)); + ourLog.info("Output: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEncounter)); } { @@ -498,13 +498,13 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR encounter.addReasonReference().setReference("#obs1"); encounter.getContained().add(obs); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); IIdType eid3 = myEncounterDao.create(encounter, mySrd).getId().toUnqualifiedVersionless(); Encounter createdEncounter = myEncounterDao.read(eid3); - ourLog.info("Output: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEncounter)); + ourLog.info("Output: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEncounter)); } //-- Search by quantity @@ -548,13 +548,13 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR encounter.addReasonReference().setReference("#obs1"); encounter.getContained().add(obs); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); eid1 = myEncounterDao.create(encounter, mySrd).getId().toUnqualifiedVersionless(); Encounter createdEncounter = myEncounterDao.read(eid1); - ourLog.info("Output: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEncounter)); + ourLog.info("Output: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEncounter)); } @@ -579,13 +579,13 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR encounter.addReasonReference().setReference("#obs1"); encounter.getContained().add(obs); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); IIdType eid2 = myEncounterDao.create(encounter, mySrd).getId().toUnqualifiedVersionless(); Encounter createdEncounter = myEncounterDao.read(eid2); - ourLog.info("Output: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEncounter)); + ourLog.info("Output: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEncounter)); } { @@ -609,13 +609,13 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR encounter.addReasonReference().setReference("#obs1"); encounter.getContained().add(obs); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); IIdType eid3 = myEncounterDao.create(encounter, mySrd).getId().toUnqualifiedVersionless(); Encounter createdEncounter = myEncounterDao.read(eid3); - ourLog.info("Output: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEncounter)); + ourLog.info("Output: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEncounter)); } //-- Search by code @@ -652,13 +652,13 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR encounter.addReasonReference().setReference("#obs1"); encounter.getContained().add(obs); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); IIdType eid1 = myEncounterDao.create(encounter, mySrd).getId().toUnqualifiedVersionless(); Encounter createdEncounter = myEncounterDao.read(eid1); - ourLog.info("Output: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEncounter)); + ourLog.info("Output: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEncounter)); } @@ -683,13 +683,13 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR encounter.addReasonReference().setReference("#obs1"); encounter.getContained().add(obs); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); eid2 = myEncounterDao.create(encounter, mySrd).getId().toUnqualifiedVersionless(); Encounter createdEncounter = myEncounterDao.read(eid2); - ourLog.info("Output: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEncounter)); + ourLog.info("Output: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEncounter)); } { @@ -713,13 +713,13 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR encounter.addReasonReference().setReference("#obs1"); encounter.getContained().add(obs); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter)); IIdType eid3 = myEncounterDao.create(encounter, mySrd).getId().toUnqualifiedVersionless(); Encounter createdEncounter = myEncounterDao.read(eid3); - ourLog.info("Output: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEncounter)); + ourLog.info("Output: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdEncounter)); } //-- Search by composite @@ -766,11 +766,11 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR oid1 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); Observation createdObs = myObservationDao.read(oid1); - ourLog.info("Output: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); + ourLog.info("Output: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs)); } { @@ -795,7 +795,7 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -820,7 +820,7 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } //-- Search by uri @@ -862,7 +862,7 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR oid1 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); logAllStringIndexes("subject.family"); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); Observation createdObs = myObservationDao.read(oid1); @@ -897,7 +897,7 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); logAllStringIndexes("subject.family"); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } @@ -913,7 +913,7 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } @@ -958,14 +958,14 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR obs.getContained().add(p2); obs.getSubject().setReference("#patient2"); - ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Input: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); // -- update oid1 = myObservationDao.update(obs, mySrd).getId().toUnqualifiedVersionless(); Observation updatedObs = myObservationDao.read(oid1); - ourLog.info("Output: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedObs)); + ourLog.info("Output: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedObs)); } //-- No Obs with Patient Smith @@ -995,7 +995,7 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR try (CloseableHttpResponse response = ourHttpClient.execute(get)) { String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(resp); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, resp); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, resp); ids = toUnqualifiedVersionlessIdValues(bundle); } return ids; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4StructureDefinitionTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4StructureDefinitionTest.java index 390a850ead2..208e851a4bb 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4StructureDefinitionTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4StructureDefinitionTest.java @@ -24,7 +24,7 @@ public class ResourceProviderR4StructureDefinitionTest extends BaseResourceProvi @Test public void testSearchAllStructureDefinitions() throws IOException { - StructureDefinition sd = loadResource(myFhirCtx, StructureDefinition.class, "/r4/sd-david-dhtest7.json"); + StructureDefinition sd = loadResource(myFhirContext, StructureDefinition.class, "/r4/sd-david-dhtest7.json"); myStructureDefinitionDao.update(sd); Bundle response = myClient @@ -33,7 +33,7 @@ public class ResourceProviderR4StructureDefinitionTest extends BaseResourceProvi .returnBundle(Bundle.class) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); assertEquals(1, response.getEntry().size()); assertEquals("dhtest7", response.getEntry().get(0).getResource().getIdElement().getIdPart()); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java index 92926561cc6..fcc7f0b51d3 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java @@ -2,7 +2,6 @@ package ca.uhn.fhir.jpa.provider.r4; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome; import ca.uhn.fhir.jpa.config.TestR4Config; import ca.uhn.fhir.jpa.dao.data.ISearchDao; import ca.uhn.fhir.jpa.entity.Search; @@ -27,7 +26,6 @@ import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.client.api.IHttpRequest; import ca.uhn.fhir.rest.client.api.IHttpResponse; import ca.uhn.fhir.rest.client.interceptor.CapturingInterceptor; -import ca.uhn.fhir.rest.gclient.IGetPageUntyped; import ca.uhn.fhir.rest.gclient.StringClientParam; import ca.uhn.fhir.rest.param.DateRangeParam; import ca.uhn.fhir.rest.param.NumberParam; @@ -229,7 +227,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { @Override public void before() throws Exception { super.before(); - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); myDaoConfig.setAllowMultipleDelete(true); myClient.registerInterceptor(myCapturingInterceptor); @@ -470,7 +468,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { assertThat(linkNext, containsString("_getpagesoffset=3300")); Bundle nextPageBundle = myClient.loadPage().byUrl(linkNext).andReturnBundle(Bundle.class).execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(nextPageBundle)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(nextPageBundle)); assertEquals(null, nextPageBundle.getLink("next")); } @@ -712,7 +710,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { Patient p = new Patient(); p.setActive(true); p.setId("AAA"); - String encoded = myFhirCtx.newJsonParser().encodeResourceToString(p); + String encoded = myFhirContext.newJsonParser().encodeResourceToString(p); HttpPut httpPut = new HttpPut(ourServerBase + "/Patient/AAA"); httpPut.setEntity(new StringEntity(encoded, ContentType.parse("application/json+fhir"))); try (CloseableHttpResponse status = ourHttpClient.execute(httpPut)) { @@ -734,7 +732,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { p = new Patient(); p.setActive(true); p.setId("AAA"); - encoded = myFhirCtx.newJsonParser().encodeResourceToString(p); + encoded = myFhirContext.newJsonParser().encodeResourceToString(p); httpPut = new HttpPut(ourServerBase + "/Patient/AAA"); httpPut.setEntity(new StringEntity(encoded, ContentType.parse("application/json+fhir"))); try (CloseableHttpResponse status = ourHttpClient.execute(httpPut)) { @@ -785,7 +783,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { String respString = myClient.transaction().withBundle(input).prettyPrint().execute(); ourLog.info(respString); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, respString); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, respString); IdType id = new IdType(bundle.getEntry().get(0).getResponse().getLocation()); Basic basic = myClient.read().resource(Basic.class).withId(id).execute(); @@ -802,7 +800,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { try (CloseableHttpResponse response = ourHttpClient.execute(get)) { String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(resp); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, resp); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, resp); ids = toUnqualifiedIdValues(bundle); } return ids; @@ -815,9 +813,9 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { try (CloseableHttpResponse response = ourHttpClient.execute(get)) { String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(resp); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, resp); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, resp); ids = toUnqualifiedVersionlessIdValues(bundle); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); } return ids; @@ -843,7 +841,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { Bundle bundle = client.read().resource(Bundle.class).withId(id).execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); } @Test @@ -909,7 +907,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { @Test public void testCreateAndReadBackResourceWithContainedReferenceToContainer() { - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); String input = "{\n" + " \"resourceType\": \"Organization\",\n" + @@ -960,11 +958,11 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { " \"name\": \"testOrg\"\n" + "}"; - Organization org = myFhirCtx.newJsonParser().parseResource(Organization.class, input); + Organization org = myFhirContext.newJsonParser().parseResource(Organization.class, input); IIdType id = myOrganizationDao.create(org).getId(); org = myOrganizationDao.read(id); - String output = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(org); + String output = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(org); ourLog.info(output); Location loc = (Location) org.getContained().get(0); @@ -1063,7 +1061,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { arr[0] = 3; fromDB.setContent(arr); - String encoded = myFhirCtx.newJsonParser().encodeResourceToString(fromDB); + String encoded = myFhirContext.newJsonParser().encodeResourceToString(fromDB); putRequest = new HttpPut(ourServerBase + "/Binary/" + resource.getIdPart()); putRequest.setEntity(new StringEntity(encoded, ContentType.parse("application/json+fhir"))); resp = ourHttpClient.execute(putRequest); @@ -1081,7 +1079,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { arr[0] = 4; binary.setId(""); - encoded = myFhirCtx.newJsonParser().encodeResourceToString(binary); + encoded = myFhirContext.newJsonParser().encodeResourceToString(binary); putRequest = new HttpPut(ourServerBase + "/Binary/" + resource.getIdPart()); putRequest.setEntity(new StringEntity(encoded, ContentType.parse("application/json+fhir"))); resp = ourHttpClient.execute(putRequest); @@ -1147,14 +1145,14 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { obs.addIdentifier().setSystem("urn:foo").setValue("bar"); IBaseResource outcome = myClient.create().resource(obs).execute().getOperationOutcome(); - String encodedOo = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String encodedOo = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(encodedOo); assertThat(encodedOo, containsString("cvc-complex-type.2.4.b")); assertThat(encodedOo, containsString("Successfully created resource \\\"Observation/")); interceptor.setAddValidationResultsToResponseOperationOutcome(false); outcome = myClient.create().resource(obs).execute().getOperationOutcome(); - encodedOo = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + encodedOo = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(encodedOo); assertThat(encodedOo, not(containsString("cvc-complex-type.2.4.b"))); assertThat(encodedOo, containsString("Successfully created resource \\\"Observation/")); @@ -1243,7 +1241,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { Patient pt = new Patient(); pt.addName().setFamily(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPost post = new HttpPost(ourServerBase + "/Patient"); post.addHeader(Constants.HEADER_IF_NONE_EXIST, "Patient?name=" + methodName); @@ -1277,7 +1275,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { public void testCreateResourceConditionalComplex() throws IOException { Patient pt = new Patient(); pt.addIdentifier().setSystem("http://general-hospital.co.uk/Identifiers").setValue("09832345234543876876"); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPost post = new HttpPost(ourServerBase + "/Patient"); post.addHeader(Constants.HEADER_IF_NONE_EXIST, "Patient?identifier=http://general-hospital.co.uk/Identifiers|09832345234543876876"); @@ -1370,7 +1368,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(responseString); assertEquals(400, response.getStatusLine().getStatusCode()); - OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString); + OperationOutcome oo = myFhirContext.newXmlParser().parseResource(OperationOutcome.class, responseString); assertEquals(Msg.code(365) + "Can not create resource with ID \"2\", ID must not be supplied on a create (POST) operation (use an HTTP PUT / update operation if you wish to supply an ID)", oo.getIssue().get(0).getDiagnostics()); @@ -1420,7 +1418,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { .returnBundle(Bundle.class) .execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(res)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(res)); assertEquals(3, res.getEntry().size()); assertEquals(1, genResourcesOfType(res, Encounter.class).size()); @@ -1446,7 +1444,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { .returnBundle(Bundle.class) .execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(res)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(res)); assertEquals(1, res.getEntry().size()); assertEquals(1, genResourcesOfType(res, Encounter.class).size()); @@ -1459,7 +1457,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { .returnBundle(Bundle.class) .execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(res)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(res)); assertEquals(2, res.getEntry().size()); assertEquals(1, genResourcesOfType(res, Encounter.class).size()); @@ -1509,7 +1507,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { .where(Patient.IDENTIFIER.exactly().code(methodName)) .execute(); - String encoded = myFhirCtx.newXmlParser().encodeResourceToString(response.getOperationOutcome()); + String encoded = myFhirContext.newXmlParser().encodeResourceToString(response.getOperationOutcome()); ourLog.info(encoded); assertThat(encoded, containsString( " ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output)); + List ids = toUnqualifiedVersionlessIds(myFhirContext.newXmlParser().parseResource(Bundle.class, output)); ourLog.info(ids.toString()); assertThat(ids, containsInAnyOrder(pId, cId, oId)); } finally { @@ -2399,7 +2397,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); response.getEntity().getContent().close(); ourLog.info(output); - List ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output)); + List ids = toUnqualifiedVersionlessIds(myFhirContext.newXmlParser().parseResource(Bundle.class, output)); ourLog.info(ids.toString()); assertThat(ids, containsInAnyOrder(pId, cId, oId)); } finally { @@ -2449,7 +2447,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { public void testEverythingWithLargeSet() throws Exception { String inputString = IOUtils.toString(getClass().getResourceAsStream("/david_big_bundle.json"), StandardCharsets.UTF_8); - Bundle inputBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, inputString); + Bundle inputBundle = myFhirContext.newJsonParser().parseResource(Bundle.class, inputString); inputBundle.setType(BundleType.TRANSACTION); assertEquals(53, inputBundle.getEntry().size()); @@ -2474,7 +2472,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { .returnResourceType(Bundle.class) .execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(responseBundle)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(responseBundle)); List ids = new ArrayList<>(); for (BundleEntryComponent nextEntry : responseBundle.getEntry()) { @@ -2585,7 +2583,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { p.setActive(true); IIdType id = myClient.create().resource(p).execute().getId().toUnqualifiedVersionless(); - myFhirCtx.getRestfulClientFactory().setSocketTimeout(300 * 1000); + myFhirContext.getRestfulClientFactory().setSocketTimeout(300 * 1000); Bundle response = myClient .operation() @@ -2675,7 +2673,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { input.setStatus(ObservationStatus.FINAL); HttpPost post = new HttpPost(ourServerBase + "/Observation/$validate?_pretty=true"); - post.setEntity(new ResourceEntity(myFhirCtx, input)); + post.setEntity(new ResourceEntity(myFhirContext, input)); try (CloseableHttpResponse resp = ourHttpClient.execute(post)) { String respString = IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8); @@ -2902,12 +2900,12 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { assertEquals(id.withVersion("1").getValue(), history.getEntry().get(2).getResource().getId()); assertEquals(1, ((Patient) history.getEntry().get(2).getResource()).getName().size()); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(history)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(history)); try { myBundleDao.validate(history, null, null, null, null, null, mySrd); } catch (PreconditionFailedException e) { - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); throw e; } } @@ -3044,7 +3042,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { Patient pt = new Patient(); pt.setId("Patient/AAA/_history/4"); pt.addName().setFamily(methodName); - String resource = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(pt); ourLog.info("Input: {}", resource); @@ -3086,7 +3084,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { Patient pt = new Patient(); pt.setId("Patient/AAA/_history/4"); pt.addName().setFamily(methodName); - String resource = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(pt); ourLog.info("Input: {}", resource); @@ -3115,7 +3113,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { String respString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info("Response: {}", respString); assertEquals(400, response.getStatusLine().getStatusCode()); - OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, respString); + OperationOutcome oo = myFhirContext.newXmlParser().parseResource(OperationOutcome.class, respString); assertEquals( Msg.code(420) + "Can not update resource, resource body must contain an ID element which matches the request URL for update (PUT) operation - Resource body ID of \"AAA\" does not match URL ID of \"" + id.getIdPart() + "\"", @@ -3168,7 +3166,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { .returnBundle(Bundle.class) .execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(bundle)); assertEquals(3, bundle.getEntry().size()); assertEquals("Patient", bundle.getEntry().get(0).getResource().getIdElement().getResourceType()); @@ -3655,7 +3653,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { myCaptureQueriesListener.logAllQueriesForCurrentThread(); Bundle bundle = myClient.search().forResource("Patient").returnBundle(Bundle.class).execute(); - ourLog.info("Result: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info("Result: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); assertEquals(2, bundle.getTotal()); assertEquals(1, bundle.getEntry().size()); assertEquals(id2.getIdPart(), bundle.getEntry().get(0).getResource().getIdElement().getIdPart()); @@ -3700,7 +3698,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { Patient p = myClient.read().resource(Patient.class).withId("B").execute(); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(p); ourLog.info(encoded); assertThat(encoded, containsString("http://foo")); @@ -3885,7 +3883,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { String output = IOUtils.toString(resp.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(output); - Bundle b = myFhirCtx.newXmlParser().parseResource(Bundle.class, output); + Bundle b = myFhirContext.newXmlParser().parseResource(Bundle.class, output); assertEquals("http://localhost:" + ourPort + "/fhir/context/Patient?_count=5&_pretty=true&name=Jernel%C3%B6v", b.getLink("self").getUrl()); @@ -4058,7 +4056,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); response.getEntity().getContent().close(); ourLog.info(output); - List ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output)); + List ids = toUnqualifiedVersionlessIds(myFhirContext.newXmlParser().parseResource(Bundle.class, output)); ourLog.info(ids.toString()); assertThat(ids, containsInAnyOrder(pid1)); } finally { @@ -4074,7 +4072,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); response.getEntity().getContent().close(); ourLog.info(output); - List ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output)); + List ids = toUnqualifiedVersionlessIds(myFhirContext.newXmlParser().parseResource(Bundle.class, output)); ourLog.info(ids.toString()); assertThat(ids, containsInAnyOrder(pid2)); } finally { @@ -4113,7 +4111,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); response.getEntity().getContent().close(); ourLog.info(output); - List ids = toUnqualifiedVersionlessIdValues(myFhirCtx.newXmlParser().parseResource(Bundle.class, output)); + List ids = toUnqualifiedVersionlessIdValues(myFhirContext.newXmlParser().parseResource(Bundle.class, output)); ourLog.info(ids.toString()); assertThat(ids, containsInAnyOrder("Practitioner/PRAC", "Encounter/E2")); } finally { @@ -4127,7 +4125,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); response.getEntity().getContent().close(); ourLog.info(output); - List ids = toUnqualifiedVersionlessIdValues(myFhirCtx.newXmlParser().parseResource(Bundle.class, output)); + List ids = toUnqualifiedVersionlessIdValues(myFhirContext.newXmlParser().parseResource(Bundle.class, output)); ourLog.info(ids.toString()); assertThat(ids, empty()); } finally { @@ -4363,7 +4361,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { HttpGet get = new HttpGet(ourServerBase + "/Observation?value-quantity=gt-15"); try (CloseableHttpResponse resp = ourHttpClient.execute(get)) { assertEquals(200, resp.getStatusLine().getStatusCode()); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, IOUtils.toString(resp.getEntity().getContent(), Constants.CHARSET_UTF8)); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, IOUtils.toString(resp.getEntity().getContent(), Constants.CHARSET_UTF8)); List ids = toUnqualifiedVersionlessIdValues(bundle); assertThat(ids, contains(oid1)); @@ -4414,7 +4412,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); response.getEntity().getContent().close(); ourLog.info(resp); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, resp); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, resp); matches = bundle.getEntry().size(); assertThat(matches, greaterThan(0)); @@ -4468,7 +4466,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -4481,7 +4479,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -4494,7 +4492,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -4507,7 +4505,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } // > 1m @@ -4549,7 +4547,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -4560,7 +4558,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -4571,7 +4569,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -4583,7 +4581,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } String uri; @@ -4621,7 +4619,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -4632,7 +4630,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -4645,7 +4643,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } myCaptureQueriesListener.clear(); @@ -5082,7 +5080,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { try (CloseableHttpResponse resp = ourHttpClient.execute(get)) { assertEquals(200, resp.getStatusLine().getStatusCode()); String respString = IOUtils.toString(resp.getEntity().getContent(), Constants.CHARSET_UTF8); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, respString); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, respString); assertEquals(1, bundle.getEntry().size()); } } @@ -5216,7 +5214,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { oid1 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -5228,7 +5226,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { oid2 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -5240,7 +5238,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { oid3 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -5252,7 +5250,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { oid4 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } String uri = ourServerBase + "/Observation?_sort=code-value-quantity"; @@ -5261,10 +5259,10 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { HttpGet get = new HttpGet(uri); try (CloseableHttpResponse resp = ourHttpClient.execute(get)) { String output = IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8); - found = myFhirCtx.newXmlParser().parseResource(Bundle.class, output); + found = myFhirContext.newXmlParser().parseResource(Bundle.class, output); } - ourLog.info("Bundle: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(found)); + ourLog.info("Bundle: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(found)); List list = toUnqualifiedVersionlessIds(found); assertEquals(4, found.getEntry().size()); @@ -5301,7 +5299,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { oid1 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -5317,7 +5315,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { oid2 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -5333,7 +5331,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { oid3 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -5348,7 +5346,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { comp.setValue(new Quantity().setValue(250)); oid4 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } String uri = ourServerBase + "/Observation?_sort=combo-code-value-quantity"; @@ -5357,10 +5355,10 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { HttpGet get = new HttpGet(uri); try (CloseableHttpResponse resp = ourHttpClient.execute(get)) { String output = IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8); - found = myFhirCtx.newXmlParser().parseResource(Bundle.class, output); + found = myFhirContext.newXmlParser().parseResource(Bundle.class, output); } - ourLog.info("Bundle: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(found)); + ourLog.info("Bundle: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(found)); List list = toUnqualifiedVersionlessIds(found); assertEquals(4, found.getEntry().size()); @@ -5468,7 +5466,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { HttpGet get = new HttpGet(ourServerBase + "/MedicationRequest?date:missing=false"); try (CloseableHttpResponse resp = ourHttpClient.execute(get)) { assertEquals(200, resp.getStatusLine().getStatusCode()); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, IOUtils.toString(resp.getEntity().getContent(), Constants.CHARSET_UTF8)); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, IOUtils.toString(resp.getEntity().getContent(), Constants.CHARSET_UTF8)); List ids = toUnqualifiedVersionlessIdValues(bundle); assertThat(ids, contains(id1.getValue())); @@ -5751,14 +5749,14 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { // Read back directly from the DAO { Organization returned = myOrganizationDao.read(orgId, mySrd); - String val = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned); + String val = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned); ourLog.info(val); assertThat(val, containsString("")); } // Read back through the HTTP API { Organization returned = myClient.read(Organization.class, orgId.getIdPart()); - String val = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned); + String val = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned); ourLog.info(val); assertThat(val, containsString("")); } @@ -5798,7 +5796,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { Patient pt = new Patient(); pt.addName().setFamily(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPut post = new HttpPut(ourServerBase + "/Patient"); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -5806,7 +5804,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(responseString); assertEquals(400, response.getStatusLine().getStatusCode()); - OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString); + OperationOutcome oo = myFhirContext.newXmlParser().parseResource(OperationOutcome.class, responseString); assertThat(oo.getIssue().get(0).getDiagnostics(), containsString("Can not update resource, request URL must contain an ID element for update (PUT) operation (it must be of the form [base]/[resource type]/[id])")); } @@ -5819,7 +5817,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { Patient pt = new Patient(); pt.setId("2"); pt.addName().setFamily(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPut post = new HttpPut(ourServerBase + "/Patient"); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -5842,7 +5840,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { Patient pt = new Patient(); pt.addName().setFamily(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPut post = new HttpPut(ourServerBase + "/Patient/FOO"); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -5867,7 +5865,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { p1.setId("FOO"); p1.addAddress().addLine("NEWLINE"); - String encoded = myFhirCtx.newJsonParser().encodeResourceToString(p1); + String encoded = myFhirContext.newJsonParser().encodeResourceToString(p1); ourLog.info(encoded); HttpPut put = new HttpPut(ourServerBase + "/Patient/" + p1id.getIdPart()); @@ -5876,7 +5874,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { CloseableHttpResponse response = ourHttpClient.execute(put); try { assertEquals(400, response.getStatusLine().getStatusCode()); - OperationOutcome oo = myFhirCtx.newJsonParser().parseResource(OperationOutcome.class, new InputStreamReader(response.getEntity().getContent())); + OperationOutcome oo = myFhirContext.newJsonParser().parseResource(OperationOutcome.class, new InputStreamReader(response.getEntity().getContent())); assertEquals( Msg.code(420) + "Can not update resource, resource body must contain an ID element which matches the request URL for update (PUT) operation - Resource body ID of \"FOO\" does not match URL ID of \"" + p1id.getIdPart() + "\"", @@ -5888,14 +5886,14 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { // Try to update with the no ID in the resource body p1.setId((String) null); - encoded = myFhirCtx.newJsonParser().encodeResourceToString(p1); + encoded = myFhirContext.newJsonParser().encodeResourceToString(p1); put = new HttpPut(ourServerBase + "/Patient/" + p1id.getIdPart()); put.setEntity(new StringEntity(encoded, ContentType.create(Constants.CT_FHIR_JSON, "UTF-8"))); put.addHeader("Accept", Constants.CT_FHIR_JSON); response = ourHttpClient.execute(put); try { assertEquals(400, response.getStatusLine().getStatusCode()); - OperationOutcome oo = myFhirCtx.newJsonParser().parseResource(OperationOutcome.class, new InputStreamReader(response.getEntity().getContent())); + OperationOutcome oo = myFhirContext.newJsonParser().parseResource(OperationOutcome.class, new InputStreamReader(response.getEntity().getContent())); assertEquals(Msg.code(419) + "Can not update resource, resource body must contain an ID element for update (PUT) operation", oo.getIssue().get(0).getDiagnostics()); } finally { response.close(); @@ -5904,7 +5902,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { // Try to update with the to correct ID in the resource body p1.setId(p1id.getIdPart()); - encoded = myFhirCtx.newJsonParser().encodeResourceToString(p1); + encoded = myFhirContext.newJsonParser().encodeResourceToString(p1); put = new HttpPut(ourServerBase + "/Patient/" + p1id.getIdPart()); put.setEntity(new StringEntity(encoded, ContentType.create(Constants.CT_FHIR_JSON, "UTF-8"))); response = ourHttpClient.execute(put); @@ -5949,7 +5947,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { Patient pt = new Patient(); pt.addName().setFamily(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPost post = new HttpPost(ourServerBase + "/Patient?name=" + methodName); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -5965,7 +5963,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { } pt.addAddress().addLine("AAAAAAAAAAAAAAAAAAA"); - resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPut put = new HttpPut(ourServerBase + "/Patient?name=" + methodName); put.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); response = ourHttpClient.execute(put); @@ -5984,7 +5982,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { public void testUpdateResourceConditionalComplex() throws IOException { Patient pt = new Patient(); pt.addIdentifier().setSystem("http://general-hospital.co.uk/Identifiers").setValue("09832345234543876876"); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPost post = new HttpPost(ourServerBase + "/Patient"); post.addHeader(Constants.HEADER_IF_NONE_EXIST, "Patient?identifier=http://general-hospital.co.uk/Identifiers|09832345234543876876"); @@ -6002,7 +6000,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { } pt.addName().setFamily("FOO"); - resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPut put = new HttpPut(ourServerBase + "/Patient?identifier=" + ("http://general-hospital.co.uk/Identifiers|09832345234543876876".replace("|", UrlUtil.escapeUrlParam("|")))); put.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -6028,7 +6026,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { Patient pt = new Patient(); pt.addName().setFamily(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPost post = new HttpPost(ourServerBase + "/Patient"); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -6048,7 +6046,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { pt = new Patient(); pt.setId(id.getIdPart()); - resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPut put = new HttpPut(ourServerBase + "/Patient/" + id.getIdPart()); put.addHeader(Constants.HEADER_PREFER, Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_REPRESENTATION); @@ -6059,7 +6057,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); response.getEntity().getContent().close(); - Patient respPt = myFhirCtx.newXmlParser().parseResource(Patient.class, responseString); + Patient respPt = myFhirContext.newXmlParser().parseResource(Patient.class, responseString); assertEquals("2", respPt.getIdElement().getVersionIdPart()); InstantType updateTime = respPt.getMeta().getLastUpdatedElement(); @@ -6077,7 +6075,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { Patient p = new Patient(); p.setId("A"); p.setActive(true); - String encoded = myFhirCtx.newJsonParser().encodeResourceToString(p); + String encoded = myFhirContext.newJsonParser().encodeResourceToString(p); HttpPut put = new HttpPut(ourServerBase + "/Patient/A"); put.setEntity(new StringEntity(encoded, ContentType.create("application/fhir+json", "UTF-8"))); @@ -6092,7 +6090,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { p = new Patient(); p.setId("A"); p.setActive(false); - encoded = myFhirCtx.newJsonParser().encodeResourceToString(p); + encoded = myFhirContext.newJsonParser().encodeResourceToString(p); put = new HttpPut(ourServerBase + "/Patient/A"); put.setEntity(new StringEntity(encoded, ContentType.create("application/fhir+json", "UTF-8"))); @@ -6121,7 +6119,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { Patient p = new Patient(); p.setId(id); - String encoded = myFhirCtx.newJsonParser().encodeResourceToString(p); + String encoded = myFhirContext.newJsonParser().encodeResourceToString(p); HttpPut put = new HttpPut(ourServerBase + "/Patient/" + id); put.setEntity(new StringEntity(encoded, ContentType.create("application/fhir+json", "UTF-8"))); @@ -6202,7 +6200,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { pt.addName().setFamily("FAM2"); pt.setId(id.toUnqualifiedVersionless()); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPut put = new HttpPut(ourServerBase + "/Patient/" + id.getIdPart()); put.addHeader(Constants.HEADER_IF_MATCH, "W/\"44\""); @@ -6212,7 +6210,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(responseString); assertEquals(409, response.getStatusLine().getStatusCode()); - OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString); + OperationOutcome oo = myFhirContext.newXmlParser().parseResource(OperationOutcome.class, responseString); assertThat(oo.getIssue().get(0).getDiagnostics(), containsString("Trying to update Patient/" + id.getIdPart() + "/_history/44 but this is not the current version")); } finally { response.close(); @@ -6240,7 +6238,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { Patient pt = new Patient(); pt.setId("333"); pt.addName().setFamily(methodName); - String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); + String resource = myFhirContext.newXmlParser().encodeResourceToString(pt); HttpPut post = new HttpPut(ourServerBase + "/Patient/A2"); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -6248,7 +6246,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(responseString); assertEquals(400, response.getStatusLine().getStatusCode()); - OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString); + OperationOutcome oo = myFhirContext.newXmlParser().parseResource(OperationOutcome.class, responseString); assertEquals( Msg.code(420) + "Can not update resource, resource body must contain an ID element which matches the request URL for update (PUT) operation - Resource body ID of \"333\" does not match URL ID of \"A2\"", oo.getIssue().get(0).getDiagnostics()); @@ -6291,7 +6289,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { Parameters input = new Parameters(); input.addParameter().setName("mode").setValue(new CodeType("create")); - String inputStr = myFhirCtx.newXmlParser().encodeResourceToString(input); + String inputStr = myFhirContext.newXmlParser().encodeResourceToString(input); ourLog.info(inputStr); HttpPost post = new HttpPost(ourServerBase + "/Patient/$validate"); @@ -6316,7 +6314,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { patient.addName().addGiven("James"); patient.setBirthDateElement(new DateType("2011-02-02")); - String inputStr = myFhirCtx.newXmlParser().encodeResourceToString(patient); + String inputStr = myFhirContext.newXmlParser().encodeResourceToString(patient); HttpPost post = new HttpPost(ourServerBase + "/Patient/$validate"); post.setEntity(new StringEntity(inputStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -6362,7 +6360,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { Parameters input = new Parameters(); input.addParameter().setName("resource").setResource(patient); - String inputStr = myFhirCtx.newXmlParser().encodeResourceToString(input); + String inputStr = myFhirContext.newXmlParser().encodeResourceToString(input); ourLog.debug(inputStr); HttpPost post = new HttpPost(ourServerBase + "/Patient/$validate"); @@ -6415,7 +6413,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { Parameters input = new Parameters(); input.addParameter().setName("resource").setResource(patient); - String inputStr = myFhirCtx.newXmlParser().encodeResourceToString(input); + String inputStr = myFhirContext.newXmlParser().encodeResourceToString(input); ourLog.info(inputStr); HttpPost post = new HttpPost(ourServerBase + "/Patient/A123/$validate"); @@ -6442,7 +6440,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { Parameters input = new Parameters(); input.addParameter().setName("resource").setResource(patient); - String inputStr = myFhirCtx.newXmlParser().encodeResourceToString(input); + String inputStr = myFhirContext.newXmlParser().encodeResourceToString(input); HttpPost post = new HttpPost(ourServerBase + "/Patient/$validate?_pretty=true"); post.setEntity(new StringEntity(inputStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -6467,7 +6465,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { patient.addName().addGiven("James"); patient.setBirthDateElement(new DateType("2011-02-02")); - String inputStr = myFhirCtx.newXmlParser().encodeResourceToString(patient); + String inputStr = myFhirContext.newXmlParser().encodeResourceToString(patient); HttpPost post = new HttpPost(ourServerBase + "/Patient/$validate"); post.setEntity(new StringEntity(inputStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); @@ -6489,10 +6487,10 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { @Test public void testValueSetExpandOperation() throws IOException { - CodeSystem cs = myFhirCtx.newXmlParser().parseResource(CodeSystem.class, new InputStreamReader(ResourceProviderR4Test.class.getResourceAsStream("/extensional-case-3-cs.xml"))); + CodeSystem cs = myFhirContext.newXmlParser().parseResource(CodeSystem.class, new InputStreamReader(ResourceProviderR4Test.class.getResourceAsStream("/extensional-case-3-cs.xml"))); myClient.create().resource(cs).execute(); - ValueSet upload = myFhirCtx.newXmlParser().parseResource(ValueSet.class, new InputStreamReader(ResourceProviderR4Test.class.getResourceAsStream("/extensional-case-3-vs.xml"))); + ValueSet upload = myFhirContext.newXmlParser().parseResource(ValueSet.class, new InputStreamReader(ResourceProviderR4Test.class.getResourceAsStream("/extensional-case-3-vs.xml"))); IIdType vsid = myClient.create().resource(upload).execute().getId().toUnqualifiedVersionless(); HttpGet get = new HttpGet(ourServerBase + "/ValueSet/" + vsid.getIdPart() + "/$expand"); @@ -6567,7 +6565,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { cc.addCoding().setCode("2345-7").setSystem("http://loinc.org"); obs.setValue(new Quantity().setValueElement(new DecimalType(125.12)).setUnit("CM").setSystem(UcumServiceUtil.UCUM_CODESYSTEM_URL).setCode("cm")); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); IIdType opid1 = myObservationDao.create(obs, mySrd).getId(); @@ -6580,7 +6578,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { cc.addCoding().setCode("2345-7").setSystem("http://loinc.org"); obs.setValue(new Quantity().setValueElement(new DecimalType(24.12)).setUnit("CM").setSystem(UcumServiceUtil.UCUM_CODESYSTEM_URL).setCode("cm")); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); myObservationDao.update(obs, mySrd); } @@ -6596,7 +6594,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -6609,7 +6607,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } { @@ -6622,7 +6620,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { myObservationDao.create(obs, mySrd); - ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs)); } // > 1m @@ -6657,7 +6655,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { patient.setBirthDateElement(new DateType("2073")); pid0 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless(); - ourLog.info("Patient: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); + ourLog.info("Patient: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient)); System.out.println("pid0 " + pid0); } @@ -6670,9 +6668,9 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { try (CloseableHttpResponse response = ourHttpClient.execute(get)) { String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(resp); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, resp); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, resp); ids = toUnqualifiedVersionlessIdValues(bundle); - ourLog.info("Patient: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info("Patient: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); } uri = ourServerBase + "/Patient?_total=accurate&birthdate=gt2072-01-01"; @@ -6682,9 +6680,9 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { try (CloseableHttpResponse response = ourHttpClient.execute(get)) { String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(resp); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, resp); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, resp); ids = toUnqualifiedVersionlessIdValues(bundle); - ourLog.info("Patient: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info("Patient: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); } } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetLuceneDisabledTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetLuceneDisabledTest.java index e88bead5b55..880937138f0 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetLuceneDisabledTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetLuceneDisabledTest.java @@ -140,7 +140,7 @@ public class ResourceProviderR4ValueSetLuceneDisabledTest extends BaseJpaTest { } @Override - protected FhirContext getContext() { + protected FhirContext getFhirContext() { return myFhirCtx; } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetNoVerCSNoVerTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetNoVerCSNoVerTest.java index ae93c93111f..d55832612db 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetNoVerCSNoVerTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetNoVerCSNoVerTest.java @@ -235,7 +235,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, containsString("")); @@ -273,7 +273,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, containsString("")); @@ -303,7 +303,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, not(containsString("\"Foo Code\""))); @@ -331,7 +331,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, not(containsString("\"Foo Code\""))); @@ -359,7 +359,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, not(containsString("\"Foo Code\""))); @@ -384,7 +384,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, not(containsString(""))); assertThat(resp, not(containsString("\"Foo Code\""))); @@ -403,7 +403,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -424,7 +424,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -469,7 +469,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -511,7 +511,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -536,7 +536,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -557,7 +557,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, is(containsStringIgnoringCase(""))); @@ -577,7 +577,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsStringIgnoringCase("")); @@ -668,7 +668,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsStringIgnoringCase("")); @@ -687,7 +687,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsStringIgnoringCase("")); @@ -707,7 +707,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsStringIgnoringCase("")); @@ -727,7 +727,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsStringIgnoringCase("")); @@ -776,7 +776,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .withNoParameters(Parameters.class) .returnResourceType(ValueSet.class) .execute(); - ourLog.info("Expanded: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expanded)); + ourLog.info("Expanded: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expanded)); assertEquals(1, expanded.getExpansion().getContains().size()); // Update the CodeSystem URL and Codes @@ -800,7 +800,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .withNoParameters(Parameters.class) .returnResourceType(ValueSet.class) .execute(); - ourLog.info("Expanded: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expanded)); + ourLog.info("Expanded: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expanded)); assertEquals(1, expanded.getExpansion().getContains().size()); } @@ -834,10 +834,10 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv loadAndPersistCodeSystemAndValueSetWithDesignations(); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); String initialValueSetName = valueSet.getName(); validateTermValueSetNotExpanded(initialValueSetName); @@ -849,7 +849,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv updatedValueSet.setName(valueSet.getName().concat(" - MODIFIED")); persistValueSet(updatedValueSet, HttpVerb.PUT); updatedValueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("Updated ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet)); + ourLog.info("Updated ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet)); String updatedValueSetName = valueSet.getName(); validateTermValueSetNotExpanded(updatedValueSetName); @@ -864,10 +864,10 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv loadAndPersistCodeSystemAndValueSetWithDesignations(); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); String initialValueSetName = valueSet.getName(); validateTermValueSetNotExpanded(initialValueSetName); @@ -888,11 +888,11 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .getRequest() .setMethod(Bundle.HTTPVerb.PUT) .setUrl(myExtensionalVsId.getValueAsString()); - ourLog.info("Transaction Bundle:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info("Transaction Bundle:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); myClient.transaction().withBundle(bundle).execute(); updatedValueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("Updated ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet)); + ourLog.info("Updated ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet)); String updatedValueSetName = valueSet.getName(); validateTermValueSetNotExpanded(updatedValueSetName); @@ -972,7 +972,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .andParameter("system", new UriType("http://acme.org")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(true, ((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1001,7 +1001,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(true, ((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1034,7 +1034,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv String respString = IOUtils.toString(response.getEntity().getContent(), Charsets.UTF_8); ourLog.info(respString); - Parameters respParam = myFhirCtx.newJsonParser().parseResource(Parameters.class, respString); + Parameters respParam = myFhirContext.newJsonParser().parseResource(Parameters.class, respString); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); } } @@ -1073,7 +1073,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .withParameter(Parameters.class, "url", new UrlType(URL_MY_VALUE_SET)) .returnResourceType(ValueSet.class) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); assertThat(toDirectCodes(expansion.getExpansion().getContains()), containsInAnyOrder("A", "AA", "AB", "AAA")); assertEquals(11, myCaptureQueriesListener.getSelectQueries().size()); assertEquals("ValueSet \"ValueSet.url[http://example.com/my_value_set]\" has not yet been pre-expanded. Performing in-memory expansion without parameters. Current status: NOT_EXPANDED | The ValueSet is waiting to be picked up and pre-expanded by a scheduled task.", expansion.getMeta().getExtensionString(EXT_VALUESET_EXPANSION_MESSAGE)); @@ -1088,7 +1088,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .andParameter(JpaConstants.OPERATION_EXPAND_PARAM_INCLUDE_HIERARCHY, new BooleanType("true")) .returnResourceType(ValueSet.class) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); assertThat(toDirectCodes(expansion.getExpansion().getContains()), containsInAnyOrder("A")); assertThat(toDirectCodes(expansion.getExpansion().getContains().get(0).getContains()), containsInAnyOrder("AA", "AB")); assertThat(toDirectCodes(expansion.getExpansion().getContains().get(0).getContains().stream().filter(t -> t.getCode().equals("AA")).findFirst().orElseThrow(() -> new IllegalArgumentException()).getContains()), containsInAnyOrder("AAA")); @@ -1113,7 +1113,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .withParameter(Parameters.class, "valueSet", myLocalVs) .returnResourceType(ValueSet.class) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); assertThat(toDirectCodes(expansion.getExpansion().getContains()), containsInAnyOrder("A", "AA", "AB", "AAA")); assertEquals(7, myCaptureQueriesListener.getSelectQueries().size()); assertEquals("ValueSet with URL \"Unidentified ValueSet\" was expanded using an in-memory expansion", expansion.getMeta().getExtensionString(EXT_VALUESET_EXPANSION_MESSAGE)); @@ -1128,7 +1128,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .andParameter(JpaConstants.OPERATION_EXPAND_PARAM_INCLUDE_HIERARCHY, new BooleanType("true")) .returnResourceType(ValueSet.class) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); assertThat(toDirectCodes(expansion.getExpansion().getContains()), containsInAnyOrder("A")); assertThat(toDirectCodes(expansion.getExpansion().getContains().get(0).getContains()), containsInAnyOrder("AA", "AB")); assertThat(toDirectCodes(expansion.getExpansion().getContains().get(0).getContains().stream().filter(t -> t.getCode().equals("AA")).findFirst().orElseThrow(() -> new IllegalArgumentException()).getContains()), containsInAnyOrder("AAA")); @@ -1167,7 +1167,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .withParameter(Parameters.class, "url", new UrlType(URL_MY_VALUE_SET)) .returnResourceType(ValueSet.class) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); assertThat(toDirectCodes(expansion.getExpansion().getContains()), containsInAnyOrder("A", "AA", "AB", "AAA")); assertEquals(0, myCaptureQueriesListener.getSelectQueries().size()); assertThat(expansion.getMeta().getExtensionString(EXT_VALUESET_EXPANSION_MESSAGE), containsString("ValueSet was expanded using an expansion that was pre-calculated")); @@ -1182,7 +1182,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .andParameter(JpaConstants.OPERATION_EXPAND_PARAM_INCLUDE_HIERARCHY, new BooleanType("true")) .returnResourceType(ValueSet.class) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); assertThat(toDirectCodes(expansion.getExpansion().getContains()), containsInAnyOrder("A")); assertThat(toDirectCodes(expansion.getExpansion().getContains().get(0).getContains()), containsInAnyOrder("AA", "AB")); assertThat(toDirectCodes(expansion.getExpansion().getContains().get(0).getContains().stream().filter(t -> t.getCode().equals("AA")).findFirst().orElseThrow(() -> new IllegalArgumentException()).getContains()), containsInAnyOrder("AAA")); @@ -1229,7 +1229,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv String respString = IOUtils.toString(response.getEntity().getContent(), Charsets.UTF_8); ourLog.info(respString); - Parameters respParam = myFhirCtx.newJsonParser().parseResource(Parameters.class, respString); + Parameters respParam = myFhirContext.newJsonParser().parseResource(Parameters.class, respString); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); } } @@ -1256,7 +1256,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .andParameter("system", new UriType("http://acme.org")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(true, ((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1292,7 +1292,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .useHttpGet() .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals("result", respParam.getParameter().get(0).getName()); @@ -1337,7 +1337,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv try (CloseableHttpResponse status = ourHttpClient.execute(validateCodeGet)) { String response = IOUtils.toString(status.getEntity().getContent(), Charsets.UTF_8); ourLog.info("Response: {}", response); - Parameters output = myFhirCtx.newXmlParser().parseResource(Parameters.class, response); + Parameters output = myFhirContext.newXmlParser().parseResource(Parameters.class, response); assertEquals(true, output.getParameterBool("result")); } @@ -1345,7 +1345,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv try (CloseableHttpResponse status = ourHttpClient.execute(validateCodeGet2)) { String response = IOUtils.toString(status.getEntity().getContent(), Charsets.UTF_8); ourLog.info("Response: {}", response); - Parameters output = myFhirCtx.newXmlParser().parseResource(Parameters.class, response); + Parameters output = myFhirContext.newXmlParser().parseResource(Parameters.class, response); assertEquals(false, output.getParameterBool("result")); } @@ -1379,7 +1379,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -1444,7 +1444,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder("", "")); } @@ -1464,7 +1464,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, not(stringContainsInOrder("", ""))); @@ -1485,7 +1485,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, not(stringContainsInOrder("", ""))); @@ -1504,7 +1504,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -1524,7 +1524,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv .andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetVerCSNoVerTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetVerCSNoVerTest.java index c2e1178e3cf..29ee809aea6 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetVerCSNoVerTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetVerCSNoVerTest.java @@ -201,7 +201,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, containsString("")); @@ -239,7 +239,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, containsString("")); @@ -269,7 +269,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, not(containsString("\"Foo Code\""))); @@ -296,7 +296,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, not(containsString("\"Foo Code\""))); @@ -315,7 +315,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -336,7 +336,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -381,7 +381,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -423,7 +423,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -448,7 +448,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -469,7 +469,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsStringIgnoringCase("")); @@ -489,7 +489,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsStringIgnoringCase("")); @@ -580,7 +580,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsStringIgnoringCase("")); @@ -599,7 +599,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsStringIgnoringCase("")); @@ -619,7 +619,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsStringIgnoringCase("")); @@ -639,7 +639,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsStringIgnoringCase("")); @@ -688,7 +688,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .withNoParameters(Parameters.class) .returnResourceType(ValueSet.class) .execute(); - ourLog.info("Expanded: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expanded)); + ourLog.info("Expanded: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expanded)); assertEquals(1, expanded.getExpansion().getContains().size()); // Update the CodeSystem URL and Codes @@ -712,7 +712,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .withNoParameters(Parameters.class) .returnResourceType(ValueSet.class) .execute(); - ourLog.info("Expanded: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expanded)); + ourLog.info("Expanded: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expanded)); assertEquals(1, expanded.getExpansion().getContains().size()); assertNotNull(expanded.getId()); } @@ -724,10 +724,10 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid loadAndPersistCodeSystemAndValueSetWithDesignations(); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); String initialValueSetName = valueSet.getName(); validateTermValueSetNotExpanded(initialValueSetName); @@ -739,7 +739,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid updatedValueSet.setName(valueSet.getName().concat(" - MODIFIED")); persistValueSet(updatedValueSet, HttpVerb.PUT); updatedValueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("Updated ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet)); + ourLog.info("Updated ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet)); String updatedValueSetName = valueSet.getName(); validateTermValueSetNotExpanded(updatedValueSetName); @@ -754,10 +754,10 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid loadAndPersistCodeSystemAndValueSetWithDesignations(); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); String initialValueSetName = valueSet.getName(); validateTermValueSetNotExpanded(initialValueSetName); @@ -778,11 +778,11 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .getRequest() .setMethod(Bundle.HTTPVerb.PUT) .setUrl(myExtensionalVsId.getValueAsString()); - ourLog.info("Transaction Bundle:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info("Transaction Bundle:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); myClient.transaction().withBundle(bundle).execute(); updatedValueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("Updated ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet)); + ourLog.info("Updated ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet)); String updatedValueSetName = valueSet.getName(); validateTermValueSetNotExpanded(updatedValueSetName); @@ -862,7 +862,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .andParameter("system", new UriType("http://acme.org")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(true, ((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -891,7 +891,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .andParameter("system", new UriType("http://acme.org")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(true, ((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -920,7 +920,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertEquals(true, ((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -958,7 +958,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid try (CloseableHttpResponse status = ourHttpClient.execute(validateCodeGet)) { String response = IOUtils.toString(status.getEntity().getContent(), Charsets.UTF_8); ourLog.info("Response: {}", response); - Parameters output = myFhirCtx.newXmlParser().parseResource(Parameters.class, response); + Parameters output = myFhirContext.newXmlParser().parseResource(Parameters.class, response); assertEquals(true, output.getParameterBool("result")); } @@ -966,7 +966,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid try (CloseableHttpResponse status = ourHttpClient.execute(validateCodeGet2)) { String response = IOUtils.toString(status.getEntity().getContent(), Charsets.UTF_8); ourLog.info("Response: {}", response); - Parameters output = myFhirCtx.newXmlParser().parseResource(Parameters.class, response); + Parameters output = myFhirContext.newXmlParser().parseResource(Parameters.class, response); assertEquals(false, output.getParameterBool("result")); } @@ -997,7 +997,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid .andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetVerCSVerTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetVerCSVerTest.java index 92a2f776ab4..82a79ec4131 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetVerCSVerTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetVerCSVerTest.java @@ -1,6 +1,5 @@ package ca.uhn.fhir.jpa.provider.r4; -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; import ca.uhn.fhir.jpa.dao.data.IResourceTableDao; @@ -220,7 +219,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, containsString("")); @@ -245,7 +244,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .execute(); expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, containsString("")); @@ -284,7 +283,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, containsString("")); @@ -309,7 +308,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .execute(); expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, containsString("")); @@ -340,7 +339,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, not(containsString("\"Foo Code\""))); @@ -354,7 +353,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .execute(); expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, not(containsString("\"Foo Code\""))); @@ -383,7 +382,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); @@ -396,7 +395,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .execute(); expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsString("")); assertThat(resp, not(containsString("\"Foo Code\""))); @@ -417,7 +416,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -433,7 +432,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider expanded = (ValueSet) respParam.getParameter().get(0).getResource(); // Should return v2 as this was the last version loaded. - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -449,7 +448,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .execute(); expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -472,7 +471,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -488,7 +487,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider expanded = (ValueSet) respParam.getParameter().get(0).getResource(); // Should return v2 as this was the last version loaded. - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -504,7 +503,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .execute(); expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -553,7 +552,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -569,7 +568,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider expanded = (ValueSet) respParam.getParameter().get(0).getResource(); // Should return v2 as this was the last version loaded. - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -585,7 +584,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .execute(); expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -630,7 +629,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); // Should return v2 as this was the last updated. - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -651,7 +650,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider expanded = (ValueSet) respParam.getParameter().get(0).getResource(); // Should return v1. - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -672,7 +671,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider expanded = (ValueSet) respParam.getParameter().get(0).getResource(); // Should return v2. - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -699,7 +698,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); // Should return v2 as this was the last updated. - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -720,7 +719,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider expanded = (ValueSet) respParam.getParameter().get(0).getResource(); // Should return v1. - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -741,7 +740,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider expanded = (ValueSet) respParam.getParameter().get(0).getResource(); // Should return v2. - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, stringContainsInOrder( "", @@ -765,7 +764,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsStringIgnoringCase("")); @@ -781,7 +780,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .execute(); expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsStringIgnoringCase("")); @@ -805,7 +804,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .execute(); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsStringIgnoringCase("")); @@ -821,7 +820,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .execute(); expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsStringIgnoringCase("")); @@ -847,7 +846,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider assertEquals(1, respParam.getParameter().size()); ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded); ourLog.info(resp); assertThat(resp, containsStringIgnoringCase("")); @@ -880,7 +879,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .withNoParameters(Parameters.class) .returnResourceType(ValueSet.class) .execute(); - ourLog.info("Expanded: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expanded)); + ourLog.info("Expanded: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expanded)); assertEquals(1, expanded.getExpansion().getContains().size()); // Update the CodeSystem Version and Codes @@ -905,7 +904,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .withNoParameters(Parameters.class) .returnResourceType(ValueSet.class) .execute(); - ourLog.info("Expanded: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expanded)); + ourLog.info("Expanded: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expanded)); assertEquals(1, expanded.getExpansion().getContains().size()); } @@ -917,14 +916,14 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider loadAndPersistCodeSystemAndValueSetWithDesignations(); CodeSystem codeSystem_v1 = myCodeSystemDao.read(myExtensionalCsId_v1); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem_v1)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem_v1)); CodeSystem codeSystem_v2 = myCodeSystemDao.read(myExtensionalCsId_v2); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem_v2)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem_v2)); ValueSet valueSet_v1 = myValueSetDao.read(myExtensionalVsId_v1); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet_v1)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet_v1)); ValueSet valueSet_v2 = myValueSetDao.read(myExtensionalVsId_v2); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet_v2)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet_v2)); String initialValueSetName_v1 = valueSet_v1.getName(); validateTermValueSetNotExpanded(initialValueSetName_v1, "1", myExtensionalVsIdOnResourceTable_v1); @@ -939,7 +938,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider updatedValueSet_v1.setName(valueSet_v1.getName().concat(" - MODIFIED")); persistSingleValueSet(updatedValueSet_v1, HttpVerb.PUT); updatedValueSet_v1 = myValueSetDao.read(myExtensionalVsId_v1); - ourLog.info("Updated ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet_v1)); + ourLog.info("Updated ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet_v1)); String updatedValueSetName_v1 = valueSet_v1.getName(); validateTermValueSetNotExpanded(updatedValueSetName_v1, "1", myExtensionalVsIdOnResourceTable_v1); @@ -948,7 +947,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider updatedValueSet_v2.setName(valueSet_v2.getName().concat(" - MODIFIED")); persistSingleValueSet(updatedValueSet_v2, HttpVerb.PUT); updatedValueSet_v2 = myValueSetDao.read(myExtensionalVsId_v2); - ourLog.info("Updated ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet_v2)); + ourLog.info("Updated ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet_v2)); String updatedValueSetName_v2 = valueSet_v2.getName(); validateTermValueSetNotExpanded(updatedValueSetName_v2, "2", myExtensionalVsIdOnResourceTable_v2); @@ -966,14 +965,14 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider loadAndPersistCodeSystemAndValueSetWithDesignations(); CodeSystem codeSystem_v1 = myCodeSystemDao.read(myExtensionalCsId_v1); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem_v1)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem_v1)); CodeSystem codeSystem_v2 = myCodeSystemDao.read(myExtensionalCsId_v2); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem_v2)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem_v2)); ValueSet valueSet_v1 = myValueSetDao.read(myExtensionalVsId_v1); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet_v1)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet_v1)); ValueSet valueSet_v2 = myValueSetDao.read(myExtensionalVsId_v2); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet_v2)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet_v2)); String initialValueSetName_v1 = valueSet_v1.getName(); validateTermValueSetNotExpanded(initialValueSetName_v1, "1", myExtensionalVsIdOnResourceTable_v1); @@ -997,11 +996,11 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .getRequest() .setMethod(Bundle.HTTPVerb.PUT) .setUrl(myExtensionalVsId_v1.getValueAsString()); - ourLog.info("Transaction Bundle:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info("Transaction Bundle:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); myClient.transaction().withBundle(bundle).execute(); updatedValueSet_v1 = myValueSetDao.read(myExtensionalVsId_v1); - ourLog.info("Updated ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet_v1)); + ourLog.info("Updated ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet_v1)); String updatedValueSetName_v1 = valueSet_v1.getName(); validateTermValueSetNotExpanded(updatedValueSetName_v1, "1", myExtensionalVsIdOnResourceTable_v1); @@ -1019,11 +1018,11 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .getRequest() .setMethod(Bundle.HTTPVerb.PUT) .setUrl(myExtensionalVsId_v2.getValueAsString()); - ourLog.info("Transaction Bundle:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + ourLog.info("Transaction Bundle:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); myClient.transaction().withBundle(bundle).execute(); updatedValueSet_v2 = myValueSetDao.read(myExtensionalVsId_v2); - ourLog.info("Updated ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet_v2)); + ourLog.info("Updated ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(updatedValueSet_v2)); String updatedValueSetName_v2 = valueSet_v2.getName(); validateTermValueSetNotExpanded(updatedValueSetName_v2, "2", myExtensionalVsIdOnResourceTable_v2); @@ -1146,7 +1145,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("valueSetVersion", new StringType("1")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1162,7 +1161,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("valueSetVersion", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1178,7 +1177,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1193,7 +1192,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1210,7 +1209,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("valueSetVersion", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1226,7 +1225,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("valueSetVersion", new StringType("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1242,7 +1241,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1273,7 +1272,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("systemVersion", new StringType("1")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1287,7 +1286,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("systemVersion", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1303,7 +1302,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("system", new UriType("http://acme.org")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1316,7 +1315,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("system", new UriType("http://acme.org")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1331,7 +1330,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("systemVersion", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1345,7 +1344,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("systemVersion", new StringType("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1384,7 +1383,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("valueSetVersion", new StringType("1")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1398,7 +1397,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("valueSetVersion", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1412,7 +1411,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1427,7 +1426,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("valueSetVersion", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1441,7 +1440,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("valueSetVersion", new StringType("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1455,7 +1454,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1470,7 +1469,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("valueSetVersion", new StringType("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1484,7 +1483,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("valueSetVersion", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1497,7 +1496,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1540,7 +1539,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("valueSetVersion", new StringType("1")) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1554,7 +1553,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("valueSetVersion", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1568,7 +1567,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1583,7 +1582,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("valueSetVersion", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1597,7 +1596,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("valueSetVersion", new StringType("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1611,7 +1610,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1626,7 +1625,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("valueSetVersion", new StringType("1")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1640,7 +1639,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("valueSetVersion", new StringType("2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); @@ -1653,7 +1652,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider .andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2")) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderSearchModifierR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderSearchModifierR4Test.java index b4b0250c9b4..71743880434 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderSearchModifierR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderSearchModifierR4Test.java @@ -1,15 +1,10 @@ package ca.uhn.fhir.jpa.provider.r4; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; - import ca.uhn.fhir.i18n.Msg; +import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.model.entity.ModelConfig; +import ca.uhn.fhir.parser.StrictErrorHandler; +import ca.uhn.fhir.rest.client.interceptor.CapturingInterceptor; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import org.apache.commons.io.IOUtils; import org.apache.http.client.methods.CloseableHttpResponse; @@ -26,9 +21,13 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.parser.StrictErrorHandler; -import ca.uhn.fhir.rest.client.interceptor.CapturingInterceptor; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class ResourceProviderSearchModifierR4Test extends BaseResourceProviderR4Test { @@ -58,7 +57,7 @@ public class ResourceProviderSearchModifierR4Test extends BaseResourceProviderR4 @Override public void before() throws Exception { super.before(); - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); myDaoConfig.setAllowMultipleDelete(true); myClient.registerInterceptor(myCapturingInterceptor); @@ -282,8 +281,8 @@ public class ResourceProviderSearchModifierR4Test extends BaseResourceProviderR4 try (CloseableHttpResponse response = ourHttpClient.execute(get)) { String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info("Response was: {}", resp); - Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, resp); - ourLog.info("Bundle: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, resp); + ourLog.info("Bundle: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); ids = toUnqualifiedVersionlessIdValues(bundle); } return ids; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ServerCapabilityStatementProviderJpaR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ServerCapabilityStatementProviderJpaR4Test.java index 920b5a14a7f..0a93384dae6 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ServerCapabilityStatementProviderJpaR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ServerCapabilityStatementProviderJpaR4Test.java @@ -6,9 +6,8 @@ import ca.uhn.fhir.rest.api.CacheControlDirective; import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.server.provider.ServerCapabilityStatementProvider; import org.apache.commons.lang3.StringUtils; -import org.hl7.fhir.instance.model.api.IAnyResource; -import org.hl7.fhir.r4.model.Bundle; import org.hamcrest.Matchers; +import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.CapabilityStatement; import org.hl7.fhir.r4.model.Enumerations; import org.hl7.fhir.r4.model.SearchParameter; @@ -80,7 +79,7 @@ public class ServerCapabilityStatementProviderJpaR4Test extends BaseResourceProv @Test public void testNoDuplicateResourceOperationNames() { CapabilityStatement cs = myClient.capabilities().ofType(CapabilityStatement.class).execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(cs)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(cs)); for (CapabilityStatement.CapabilityStatementRestResourceComponent next : cs.getRestFirstRep().getResource()) { List opNames = next .getOperation() @@ -96,7 +95,7 @@ public class ServerCapabilityStatementProviderJpaR4Test extends BaseResourceProv @Test public void testNoDuplicateSystemOperationNames() { CapabilityStatement cs = myClient.capabilities().ofType(CapabilityStatement.class).execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(cs)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(cs)); List systemOpNames = cs .getRestFirstRep() .getOperation() diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ServerR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ServerR4Test.java index 7a6f1009202..f813fb74953 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ServerR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ServerR4Test.java @@ -41,12 +41,12 @@ public class ServerR4Test extends BaseResourceProviderR4Test { ourLog.info(respString); - CapabilityStatement cs = myFhirCtx.newJsonParser().parseResource(CapabilityStatement.class, respString); + CapabilityStatement cs = myFhirContext.newJsonParser().parseResource(CapabilityStatement.class, respString); try { myCapabilityStatementDao.validate(cs, null, respString, EncodingEnum.JSON, null, null, null); } catch (PreconditionFailedException e) { - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); fail(); } } @@ -67,7 +67,7 @@ public class ServerR4Test extends BaseResourceProviderR4Test { String respString = IOUtils.toString(resp.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(respString); - CapabilityStatement cs = myFhirCtx.newXmlParser().parseResource(CapabilityStatement.class, respString); + CapabilityStatement cs = myFhirContext.newXmlParser().parseResource(CapabilityStatement.class, respString); for (CapabilityStatementRestResourceComponent nextResource : cs.getRest().get(0).getResource()) { ourLog.info("Testing resource: " + nextResource.getType()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/StaleSearchDeletingSvcR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/StaleSearchDeletingSvcR4Test.java index 1972a386f5a..93e29190b68 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/StaleSearchDeletingSvcR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/StaleSearchDeletingSvcR4Test.java @@ -90,7 +90,7 @@ public class StaleSearchDeletingSvcR4Test extends BaseResourceProviderR4Test { assertThat(nextLinkUrl, not(blankOrNullString())); Bundle resp2 = myClient.search().byUrl(nextLinkUrl).returnBundle(Bundle.class).execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp2)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp2)); myStaleSearchDeletingSvc.pollForStaleSearchesAndDeleteThem(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/SubscriptionsR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/SubscriptionsR4Test.java index 02d7fcc6e99..58a6133b2c2 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/SubscriptionsR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/SubscriptionsR4Test.java @@ -21,7 +21,8 @@ import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class SubscriptionsR4Test extends BaseResourceProviderR4Test { @@ -211,7 +212,7 @@ public class SubscriptionsR4Test extends BaseResourceProviderR4Test { myPingCount++; } else if (myGotBound && theMsg.startsWith("add " + mySubsId + "\n")) { String text = theMsg.substring(("add " + mySubsId + "\n").length()); - IBaseResource res = myEncoding.newParser(myFhirCtx).parseResource(text); + IBaseResource res = myEncoding.newParser(myFhirContext).parseResource(text); myReceived.add(res); myPingCount++; } else { diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/SystemProviderR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/SystemProviderR4Test.java index 0fa20570230..8970af9e6e5 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/SystemProviderR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/SystemProviderR4Test.java @@ -294,7 +294,7 @@ public class SystemProviderR4Test extends BaseJpaR4Test { public void testMarkResourcesForReindexingTyped() throws Exception { HttpPost post = new HttpPost(ourServerBase + "/$mark-all-resources-for-reindexing?type=Patient"); - post.setEntity(new ResourceEntity(myFhirCtx, new Parameters().addParameter("type", new CodeType("Patient")))); + post.setEntity(new ResourceEntity(myFhirContext, new Parameters().addParameter("type", new CodeType("Patient")))); CloseableHttpResponse http = ourHttpClient.execute(post); try { String output = IOUtils.toString(http.getEntity().getContent(), StandardCharsets.UTF_8); @@ -305,7 +305,7 @@ public class SystemProviderR4Test extends BaseJpaR4Test { } post = new HttpPost(ourServerBase + "/$mark-all-resources-for-reindexing?type=FOO"); - post.setEntity(new ResourceEntity(myFhirCtx, new Parameters().addParameter("type", new CodeType("FOO")))); + post.setEntity(new ResourceEntity(myFhirContext, new Parameters().addParameter("type", new CodeType("FOO")))); http = ourHttpClient.execute(post); try { String output = IOUtils.toString(http.getEntity().getContent(), StandardCharsets.UTF_8); @@ -406,7 +406,7 @@ public class SystemProviderR4Test extends BaseJpaR4Test { for (int i = 0; i < 10; i++) { ourLog.info("** Beginning pass {}", i); - Bundle input = myFhirCtx.newJsonParser().parseResource(Bundle.class, IOUtils.toString(getClass().getResourceAsStream("/r4/createdeletebundle.json"), Charsets.UTF_8)); + Bundle input = myFhirContext.newJsonParser().parseResource(Bundle.class, IOUtils.toString(getClass().getResourceAsStream("/r4/createdeletebundle.json"), Charsets.UTF_8)); myClient.transaction().withBundle(input).execute(); myPatientDao.read(new IdType("Patient/Patient1063259")); @@ -442,7 +442,7 @@ public class SystemProviderR4Test extends BaseJpaR4Test { } private void deleteAllOfType(String theType) { - BundleUtil.toListOfResources(myFhirCtx, myClient.search().forResource(theType).execute()) + BundleUtil.toListOfResources(myFhirContext, myClient.search().forResource(theType).execute()) .forEach(t -> { myClient.delete().resourceById(t.getIdElement()).execute(); }); @@ -463,7 +463,7 @@ public class SystemProviderR4Test extends BaseJpaR4Test { inputBundle.addEntry().getRequest().setMethod(HTTPVerb.DELETE).setUrl(id.getValue()); inputBundle.addEntry().getRequest().setMethod(HTTPVerb.DELETE).setUrl(id.getValue()); inputBundle.addEntry().getRequest().setMethod(HTTPVerb.DELETE).setUrl("Patient?name=Pietercx85ioqWJbI"); - String input = myFhirCtx.newXmlParser().encodeResourceToString(inputBundle); + String input = myFhirContext.newXmlParser().encodeResourceToString(inputBundle); HttpPost req = new HttpPost(ourServerBase + "?_pretty=true"); req.setEntity(new StringEntity(input, ContentType.parse(Constants.CT_FHIR_XML + "; charset=utf-8"))); @@ -475,7 +475,7 @@ public class SystemProviderR4Test extends BaseJpaR4Test { assertThat(encoded, containsString("transaction-response")); - Bundle response = myFhirCtx.newXmlParser().parseResource(Bundle.class, encoded); + Bundle response = myFhirContext.newXmlParser().parseResource(Bundle.class, encoded); assertEquals(3, response.getEntry().size()); } finally { @@ -584,7 +584,7 @@ public class SystemProviderR4Test extends BaseJpaR4Test { for (int pass = 0; pass < 10000; pass++) { - BundleBuilder bb = new BundleBuilder(myFhirCtx); + BundleBuilder bb = new BundleBuilder(myFhirContext); for (int i = 0; i < 100; i++) { Patient pt = new Patient(); pt.setId(org.hl7.fhir.dstu3.model.IdType.newRandomUuid()); @@ -857,12 +857,12 @@ public class SystemProviderR4Test extends BaseJpaR4Test { // validate Bundle obsBundle = getAllResourcesOfType("Observation"); - List observations = BundleUtil.toListOfResourcesOfType(myFhirCtx, obsBundle, Observation.class); + List observations = BundleUtil.toListOfResourcesOfType(myFhirContext, obsBundle, Observation.class); assertThat(observations, hasSize(1)); assertEquals(oKeepId, observations.get(0).getIdElement()); Bundle patientBundle = getAllResourcesOfType("Patient"); - List patients = BundleUtil.toListOfResourcesOfType(myFhirCtx, patientBundle, Patient.class); + List patients = BundleUtil.toListOfResourcesOfType(myFhirContext, patientBundle, Patient.class); assertThat(patients, hasSize(1)); assertEquals(pKeepId, patients.get(0).getIdElement()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/SystemProviderTransactionSearchR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/SystemProviderTransactionSearchR4Test.java index 249c93b2166..9a5acfe386b 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/SystemProviderTransactionSearchR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/SystemProviderTransactionSearchR4Test.java @@ -157,7 +157,7 @@ public class SystemProviderTransactionSearchR4Test extends BaseJpaR4Test { myDaoConfig.setMaximumSearchResultCountInTransaction(100); Bundle output = ourClient.transaction().withBundle(input).execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); assertEquals(1, output.getEntry().size()); Bundle respBundle = (Bundle) output.getEntry().get(0).getResource(); @@ -180,7 +180,7 @@ public class SystemProviderTransactionSearchR4Test extends BaseJpaR4Test { .setUrl("Patient?_count=5&_sort=name"); Bundle output = ourClient.transaction().withBundle(input).execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); assertEquals(1, output.getEntry().size()); Bundle respBundle = (Bundle) output.getEntry().get(0).getResource(); @@ -215,7 +215,7 @@ public class SystemProviderTransactionSearchR4Test extends BaseJpaR4Test { } Bundle output = ourClient.transaction().withBundle(input).execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); assertEquals(30, output.getEntry().size()); for (int i = 0; i < 30; i++) { @@ -283,7 +283,7 @@ public class SystemProviderTransactionSearchR4Test extends BaseJpaR4Test { .setUrl("MedicationRequest?intent=plan,order&medication.code=50580-0449-23&patient=P3000254749"); Bundle resp = ourClient.transaction().withBundle(b).execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp)); b = (Bundle) resp.getEntry().get(0).getResource(); assertEquals(1, b.getEntry().size()); assertEquals("MedicationRequest/MR635079", b.getEntry().get(0).getResource().getIdElement().toUnqualifiedVersionless().getValue()); @@ -304,7 +304,7 @@ public class SystemProviderTransactionSearchR4Test extends BaseJpaR4Test { myDaoConfig.setMaximumSearchResultCountInTransaction(100); Bundle output = ourClient.transaction().withBundle(input).execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); assertEquals(1, output.getEntry().size()); Bundle respBundle = (Bundle) output.getEntry().get(0).getResource(); @@ -327,7 +327,7 @@ public class SystemProviderTransactionSearchR4Test extends BaseJpaR4Test { .setUrl("Patient?_count=5&_sort=name"); Bundle output = ourClient.transaction().withBundle(input).execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); assertEquals(1, output.getEntry().size()); Bundle respBundle = (Bundle) output.getEntry().get(0).getResource(); @@ -362,7 +362,7 @@ public class SystemProviderTransactionSearchR4Test extends BaseJpaR4Test { } Bundle output = ourClient.transaction().withBundle(input).execute(); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(output)); assertEquals(30, output.getEntry().size()); for (int i = 0; i < 30; i++) { diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/TerminologyUploaderProviderR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/TerminologyUploaderProviderR4Test.java index 5f5f48fa1a5..7a31047561d 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/TerminologyUploaderProviderR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/TerminologyUploaderProviderR4Test.java @@ -109,7 +109,7 @@ public class TerminologyUploaderProviderR4Test extends BaseResourceProviderR4Tes .andParameter(TerminologyUploaderProvider.PARAM_FILE, new Attachment().setUrl("icd10cm_tabular_2021.xml").setData(packageBytes)) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertThat(((IntegerType) respParam.getParameter().get(1).getValue()).getValue(), greaterThan(1)); @@ -128,7 +128,7 @@ public class TerminologyUploaderProviderR4Test extends BaseResourceProviderR4Tes .andParameter(TerminologyUploaderProvider.PARAM_FILE, new Attachment().setUrl("file.zip").setData(packageBytes)) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertThat(((IntegerType) respParam.getParameter().get(1).getValue()).getValue(), greaterThan(1)); @@ -146,7 +146,7 @@ public class TerminologyUploaderProviderR4Test extends BaseResourceProviderR4Tes .andParameter(TerminologyUploaderProvider.PARAM_FILE, new Attachment().setUrl("file.zip").setData(packageBytes)) .execute(); - resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); } @@ -196,7 +196,7 @@ public class TerminologyUploaderProviderR4Test extends BaseResourceProviderR4Tes .andParameter(TerminologyUploaderProvider.PARAM_FILE, new Attachment().setUrl("file.zip").setData(packageBytes)) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertThat(((IntegerType) respParam.getParameter().get(1).getValue()).getValue(), greaterThan(1)); @@ -220,7 +220,7 @@ public class TerminologyUploaderProviderR4Test extends BaseResourceProviderR4Tes .andParameter(TerminologyUploaderProvider.PARAM_FILE, new Attachment().setUrl("localfile:" + tempFile.getAbsolutePath())) .execute(); - String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); + String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); ourLog.info(resp); assertThat(((IntegerType) respParam.getParameter().get(1).getValue()).getValue(), greaterThan(1)); @@ -252,7 +252,7 @@ public class TerminologyUploaderProviderR4Test extends BaseResourceProviderR4Tes .execute(); myClient.unregisterInterceptor(interceptor); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(encoded); assertThat(encoded, stringContainsInOrder( "\"name\": \"conceptCount\"", @@ -293,7 +293,7 @@ public class TerminologyUploaderProviderR4Test extends BaseResourceProviderR4Tes .execute(); myClient.unregisterInterceptor(interceptor); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(encoded); assertThat(encoded, stringContainsInOrder( "\"name\": \"conceptCount\"", @@ -340,7 +340,7 @@ public class TerminologyUploaderProviderR4Test extends BaseResourceProviderR4Tes .execute(); myClient.unregisterInterceptor(interceptor); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(encoded); assertThat(encoded, stringContainsInOrder( "\"name\": \"conceptCount\"", @@ -380,7 +380,7 @@ public class TerminologyUploaderProviderR4Test extends BaseResourceProviderR4Tes .execute(); myClient.unregisterInterceptor(interceptor); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(encoded); assertThat(encoded, stringContainsInOrder( "\"name\": \"conceptCount\"", @@ -450,7 +450,7 @@ public class TerminologyUploaderProviderR4Test extends BaseResourceProviderR4Tes myClient.unregisterInterceptor(interceptor); } - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(encoded); assertThat(encoded, stringContainsInOrder( "\"name\": \"conceptCount\"", @@ -520,7 +520,7 @@ public class TerminologyUploaderProviderR4Test extends BaseResourceProviderR4Tes myClient.unregisterInterceptor(interceptor); } - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(encoded); assertThat(encoded, stringContainsInOrder( "\"name\": \"conceptCount\"", @@ -621,7 +621,7 @@ public class TerminologyUploaderProviderR4Test extends BaseResourceProviderR4Tes .execute(); myClient.unregisterInterceptor(interceptor); - String encoded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info(encoded); assertThat(encoded, containsString("\"valueInteger\": 5")); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/PagingMultinodeProviderDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/PagingMultinodeProviderDstu3Test.java index 9da71c6c110..2dd971b8a5f 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/PagingMultinodeProviderDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/PagingMultinodeProviderDstu3Test.java @@ -36,7 +36,7 @@ public class PagingMultinodeProviderDstu3Test extends BaseResourceProviderDstu3T @BeforeEach public void before() throws Exception { super.before(); - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); myDaoConfig.setAllowMultipleDelete(true); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/autocomplete/TokenAutocompleteElasticsearchIT.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/autocomplete/TokenAutocompleteElasticsearchIT.java index 04d1f037e6e..27149ead657 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/autocomplete/TokenAutocompleteElasticsearchIT.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/autocomplete/TokenAutocompleteElasticsearchIT.java @@ -80,7 +80,7 @@ public class TokenAutocompleteElasticsearchIT extends BaseJpaTest { } @Override - protected FhirContext getContext() { + protected FhirContext getFhirContext() { return myFhirCtx; } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/r4/PagingMultinodeProviderR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/r4/PagingMultinodeProviderR4Test.java index 2facd279d15..92a1f405e96 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/r4/PagingMultinodeProviderR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/r4/PagingMultinodeProviderR4Test.java @@ -1,18 +1,19 @@ package ca.uhn.fhir.jpa.search.r4; -import static org.apache.commons.lang3.StringUtils.leftPad; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.MatcherAssert.assertThat; - -import org.hl7.fhir.r4.model.Bundle; -import org.hl7.fhir.r4.model.Patient; -import org.junit.jupiter.api.*; import static org.hamcrest.MatcherAssert.assertThat; -import org.springframework.test.util.AopTestUtils; - import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.provider.r4.BaseResourceProviderR4Test; import ca.uhn.fhir.jpa.search.SearchCoordinatorSvcImpl; import ca.uhn.fhir.parser.StrictErrorHandler; +import org.hl7.fhir.r4.model.Bundle; +import org.hl7.fhir.r4.model.Patient; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.test.util.AopTestUtils; + +import static org.apache.commons.lang3.StringUtils.leftPad; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.contains; public class PagingMultinodeProviderR4Test extends BaseResourceProviderR4Test { @@ -35,7 +36,7 @@ public class PagingMultinodeProviderR4Test extends BaseResourceProviderR4Test { @Override public void before() throws Exception { super.before(); - myFhirCtx.setParserErrorHandler(new StrictErrorHandler()); + myFhirContext.setParserErrorHandler(new StrictErrorHandler()); myDaoConfig.setAllowMultipleDelete(true); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/reindex/ResourceReindexingSvcImplTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/reindex/ResourceReindexingSvcImplTest.java index d97f519cd9c..c159ae0e75b 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/reindex/ResourceReindexingSvcImplTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/reindex/ResourceReindexingSvcImplTest.java @@ -54,7 +54,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) public class ResourceReindexingSvcImplTest extends BaseJpaTest { - private static final FhirContext ourCtx = FhirContext.forR4Cached(); + private static final FhirContext ourFhirContext = FhirContext.forR4Cached(); @Mock private PlatformTransactionManager myTxManager; @@ -87,13 +87,13 @@ public class ResourceReindexingSvcImplTest extends BaseJpaTest { @Mock private ISchedulerService mySchedulerService; @InjectMocks - private final ResourceReindexer myResourceReindexer = new ResourceReindexer(ourCtx); + private final ResourceReindexer myResourceReindexer = new ResourceReindexer(ourFhirContext); @InjectMocks private final ResourceReindexingSvcImpl mySvc = new ResourceReindexingSvcImpl(); @Override - protected FhirContext getContext() { - return ourCtx; + public FhirContext getFhirContext() { + return ourFhirContext; } @Override @@ -105,7 +105,7 @@ public class ResourceReindexingSvcImplTest extends BaseJpaTest { public void before() { myDaoConfig.setReindexThreadCount(2); - mySvc.setContextForUnitTest(ourCtx); + mySvc.setContextForUnitTest(ourFhirContext); mySvc.setDaoConfigForUnitTest(myDaoConfig); mySvc.setResourceReindexerForUnitTest(myResourceReindexer); mySvc.start(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/searchparam/MatchUrlServiceTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/searchparam/MatchUrlServiceTest.java index 363fc9f8b75..5b97f82d2d5 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/searchparam/MatchUrlServiceTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/searchparam/MatchUrlServiceTest.java @@ -98,7 +98,7 @@ public class MatchUrlServiceTest extends BaseJpaTest { } @Override - protected FhirContext getContext() { + protected FhirContext getFhirContext() { return ourCtx; } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/stresstest/GiantTransactionPerfTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/stresstest/GiantTransactionPerfTest.java index 59b10f57422..060f2167b3d 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/stresstest/GiantTransactionPerfTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/stresstest/GiantTransactionPerfTest.java @@ -111,7 +111,7 @@ import static org.mockito.Mockito.when; public class GiantTransactionPerfTest { private static final Logger ourLog = LoggerFactory.getLogger(GiantTransactionPerfTest.class); - private final FhirContext myCtx = FhirContext.forR4Cached(); + private static final FhirContext ourFhirContext = FhirContext.forR4Cached(); private FhirSystemDaoR4 mySystemDao; private IInterceptorBroadcaster myInterceptorSvc; private TransactionProcessor myTransactionProcessor; @@ -163,7 +163,7 @@ public class GiantTransactionPerfTest { myInterceptorSvc = new InterceptorService(); - myDaoRegistry = new DaoRegistry(myCtx); + myDaoRegistry = new DaoRegistry(ourFhirContext); myPartitionSettings = new PartitionSettings(); @@ -173,7 +173,7 @@ public class GiantTransactionPerfTest { myHapiTransactionService.start(); myTransactionProcessor = new TransactionProcessor(); - myTransactionProcessor.setContext(myCtx); + myTransactionProcessor.setContext(ourFhirContext); myTransactionProcessor.setDao(mySystemDao); myTransactionProcessor.setTxManager(myTransactionManager); myTransactionProcessor.setEntityManagerForUnitTest(myEntityManager); @@ -184,7 +184,7 @@ public class GiantTransactionPerfTest { myTransactionProcessor.setDaoRegistry(myDaoRegistry); myTransactionProcessor.setPartitionSettingsForUnitTest(this.myPartitionSettings); myTransactionProcessor.setIdHelperServiceForUnitTest(myIdHelperService); - myTransactionProcessor.setFhirContextForUnitTest(myCtx); + myTransactionProcessor.setFhirContextForUnitTest(ourFhirContext); myTransactionProcessor.start(); mySystemDao = new FhirSystemDaoR4(); @@ -203,7 +203,7 @@ public class GiantTransactionPerfTest { myResourceChangeListenerCacheRefresher.setSchedulerService(new MockSchedulerSvc()); myResourceChangeListenerCacheRefresher.setResourceVersionSvc(myResourceVersionSvc); - when(myResourceChangeListenerCacheFactory.create(any(), any(), any(), anyLong())).thenAnswer(t -> { + when(myResourceChangeListenerCacheFactory.newResourceChangeListenerCache(any(), any(), any(), anyLong())).thenAnswer(t -> { String resourceName = t.getArgument(0, String.class); SearchParameterMap searchParameterMap = t.getArgument(1, SearchParameterMap.class); IResourceChangeListener changeListener = t.getArgument(2, IResourceChangeListener.class); @@ -213,28 +213,25 @@ public class GiantTransactionPerfTest { return retVal; }); - myResourceChangeListenerRegistry = new ResourceChangeListenerRegistryImpl(); - myResourceChangeListenerRegistry.setFhirContext(myCtx); - myResourceChangeListenerRegistry.setInMemoryResourceMatcher(myInMemoryResourceMatcher); - myResourceChangeListenerRegistry.setResourceChangeListenerCacheFactory(myResourceChangeListenerCacheFactory); + myResourceChangeListenerRegistry = new ResourceChangeListenerRegistryImpl(ourFhirContext, myResourceChangeListenerCacheFactory, myInMemoryResourceMatcher); myResourceChangeListenerCacheRefresher.setResourceChangeListenerRegistry(myResourceChangeListenerRegistry); mySearchParamRegistry = new SearchParamRegistryImpl(); mySearchParamRegistry.setResourceChangeListenerRegistry(myResourceChangeListenerRegistry); - mySearchParamRegistry.setSearchParameterCanonicalizerForUnitTest(new SearchParameterCanonicalizer(myCtx)); - mySearchParamRegistry.setFhirContext(myCtx); + mySearchParamRegistry.setSearchParameterCanonicalizerForUnitTest(new SearchParameterCanonicalizer(ourFhirContext)); + mySearchParamRegistry.setFhirContext(ourFhirContext); mySearchParamRegistry.setModelConfig(myDaoConfig.getModelConfig()); mySearchParamRegistry.registerListener(); mySearchParamExtractor = new SearchParamExtractorR4(); - mySearchParamExtractor.setContext(myCtx); + mySearchParamExtractor.setContext(ourFhirContext); mySearchParamExtractor.setSearchParamRegistry(mySearchParamRegistry); mySearchParamExtractor.setPartitionSettings(this.myPartitionSettings); mySearchParamExtractor.setModelConfig(myDaoConfig.getModelConfig()); mySearchParamExtractor.start(); mySearchParamExtractorSvc = new SearchParamExtractorService(); - mySearchParamExtractorSvc.setContext(myCtx); + mySearchParamExtractorSvc.setContext(ourFhirContext); mySearchParamExtractorSvc.setSearchParamExtractor(mySearchParamExtractor); mySearchParamExtractorSvc.setModelConfig(myDaoConfig.getModelConfig()); @@ -243,14 +240,14 @@ public class GiantTransactionPerfTest { mySearchParamWithInlineReferencesExtractor = new SearchParamWithInlineReferencesExtractor(); mySearchParamWithInlineReferencesExtractor.setDaoConfig(myDaoConfig); - mySearchParamWithInlineReferencesExtractor.setContext(myCtx); + mySearchParamWithInlineReferencesExtractor.setContext(ourFhirContext); mySearchParamWithInlineReferencesExtractor.setPartitionSettings(this.myPartitionSettings); mySearchParamWithInlineReferencesExtractor.setSearchParamExtractorService(mySearchParamExtractorSvc); mySearchParamWithInlineReferencesExtractor.setSearchParamRegistry(mySearchParamRegistry); mySearchParamWithInlineReferencesExtractor.setDaoSearchParamSynchronizer(myDaoSearchParamSynchronizer); myEobDao = new JpaResourceDao<>(); - myEobDao.setContext(myCtx); + myEobDao.setContext(ourFhirContext); myEobDao.setDaoConfigForUnitTest(myDaoConfig); myEobDao.setResourceType(ExplanationOfBenefit.class); myEobDao.setApplicationContext(myAppCtx); @@ -272,7 +269,7 @@ public class GiantTransactionPerfTest { @Test public void testTransaction() { - Bundle input = ClasspathUtil.loadResource(myCtx, Bundle.class, "/r4/large-transaction.json"); + Bundle input = ClasspathUtil.loadResource(ourFhirContext, Bundle.class, "/r4/large-transaction.json"); while (input.getEntry().size() > 1) { input.getEntry().remove(1); } @@ -296,7 +293,7 @@ public class GiantTransactionPerfTest { myDaoConfig.setAllowInlineMatchUrlReferences(false); - Bundle input = ClasspathUtil.loadResource(myCtx, Bundle.class, "/r4/large-transaction.json"); + Bundle input = ClasspathUtil.loadResource(ourFhirContext, Bundle.class, "/r4/large-transaction.json"); ServletRequestDetails requestDetails = new ServletRequestDetails(myInterceptorSvc); requestDetails.setServletRequest(new MockServletRequest()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/stresstest/StressTestR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/stresstest/StressTestR4Test.java index 15b596726a5..2b30c3c75c5 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/stresstest/StressTestR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/stresstest/StressTestR4Test.java @@ -8,7 +8,6 @@ import ca.uhn.fhir.jpa.provider.r4.BaseResourceProviderR4Test; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; import ca.uhn.fhir.jpa.search.SearchCoordinatorSvcImpl; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; -import ca.uhn.fhir.jpa.util.SqlQuery; import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.server.IBundleProvider; @@ -18,7 +17,6 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; import ca.uhn.fhir.rest.server.provider.ProviderConstants; import ca.uhn.fhir.test.utilities.BatchJobHelper; -import ca.uhn.fhir.util.BundleUtil; import ca.uhn.fhir.util.StopWatch; import com.google.common.base.Charsets; import com.google.common.collect.Lists; @@ -30,7 +28,6 @@ import org.hamcrest.Matchers; import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; -import org.hl7.fhir.r4.hapi.rest.server.helper.BatchHelperR4; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.Bundle.BundleType; import org.hl7.fhir.r4.model.Bundle.HTTPVerb; @@ -46,10 +43,10 @@ import org.hl7.fhir.r4.model.Parameters; import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Reference; import org.hl7.fhir.r4.model.Resource; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.TestPropertySource; @@ -72,8 +69,6 @@ import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.not; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; @@ -119,7 +114,7 @@ public class StressTestR4Test extends BaseResourceProviderR4Test { super.before(); myRequestValidatingInterceptor = new RequestValidatingInterceptor(); - FhirInstanceValidator module = new FhirInstanceValidator(myFhirCtx); + FhirInstanceValidator module = new FhirInstanceValidator(myFhirContext); module.setValidationSupport(myValidationSupport); myRequestValidatingInterceptor.addValidatorModule(module); @@ -603,7 +598,7 @@ public class StressTestR4Test extends BaseResourceProviderR4Test { .withParameters(input) .execute(); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); myBatchJobHelper.awaitAllBulkJobCompletions(BatchConstants.DELETE_EXPUNGE_JOB_NAME); int deleteCount = myCaptureQueriesListener.countDeleteQueries(); @@ -657,7 +652,7 @@ public class StressTestR4Test extends BaseResourceProviderR4Test { try { String respBundleString = IOUtils.toString(getResp.getEntity().getContent(), Charsets.UTF_8); assertEquals(200, getResp.getStatusLine().getStatusCode(), respBundleString); - respBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, respBundleString); + respBundle = myFhirContext.newJsonParser().parseResource(Bundle.class, respBundleString); myTaskCount++; } finally { IOUtils.closeQuietly(getResp); @@ -670,7 +665,7 @@ public class StressTestR4Test extends BaseResourceProviderR4Test { try { assertEquals(200, getResp.getStatusLine().getStatusCode()); String respBundleString = IOUtils.toString(getResp.getEntity().getContent(), Charsets.UTF_8); - respBundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, respBundleString); + respBundle = myFhirContext.newJsonParser().parseResource(Bundle.class, respBundleString); myTaskCount++; } finally { IOUtils.closeQuietly(getResp); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/BaseSubscriptionsR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/BaseSubscriptionsR4Test.java index 83764562c06..c7a64326371 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/BaseSubscriptionsR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/BaseSubscriptionsR4Test.java @@ -92,7 +92,7 @@ public abstract class BaseSubscriptionsR4Test extends BaseResourceProviderR4Test // Delete all Subscriptions if (myClient != null) { Bundle allSubscriptions = myClient.search().forResource(Subscription.class).returnBundle(Bundle.class).execute(); - for (IBaseResource next : BundleUtil.toListOfResources(myFhirCtx, allSubscriptions)) { + for (IBaseResource next : BundleUtil.toListOfResources(myFhirContext, allSubscriptions)) { myClient.delete().resource(next).execute(); } waitForActivatedSubscriptionCount(0); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestDstu3Test.java index a01dbdaf665..9e1923de84d 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestDstu3Test.java @@ -186,7 +186,7 @@ public class RestHookTestDstu3Test extends BaseResourceProviderDstu3Test { public void testMemoryStrategyMeta() throws InterruptedException { String inMemoryCriteria = "Observation?code=17861-6"; Subscription subscription = createSubscription(inMemoryCriteria, null, ourNotificationListenerServer); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(subscription)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(subscription)); List tag = subscription.getMeta().getTag(); assertEquals(HapiExtensions.EXT_SUBSCRIPTION_MATCHING_STRATEGY, tag.get(0).getSystem()); assertEquals(SubscriptionMatchingStrategy.IN_MEMORY.toString(), tag.get(0).getCode()); @@ -280,7 +280,7 @@ public class RestHookTestDstu3Test extends BaseResourceProviderDstu3Test { waitForQueueToDrain(); Observation observation = new Observation(); - MetaUtil.setSource(myFhirCtx, observation, source); + MetaUtil.setSource(myFhirContext, observation, source); ourClient.create().resource(observation).execute(); // Should see 1 subscription notification diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestR4Test.java index 9eed122c13d..8bc6a5df4f7 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestR4Test.java @@ -934,7 +934,7 @@ public class RestHookTestR4Test extends BaseSubscriptionsR4Test { assertEquals(Constants.CT_FHIR_XML_NEW, ourRestfulServer.getRequestContentTypes().get(0)); Observation obs = ourObservationProvider.getStoredResources().get(0); - ourLog.info("Observation content: {}", myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(obs)); + ourLog.info("Observation content: {}", myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(obs)); } @Test @@ -1228,7 +1228,7 @@ public class RestHookTestR4Test extends BaseSubscriptionsR4Test { { Subscription subscription = newSubscription("Observation?", "application/json"); subscription.addExtension(HapiExtensions.EXT_SUBSCRIPTION_PAYLOAD_SEARCH_CRITERIA, new StringType("Observation?_id=${matched_resource_id}&_include=*")); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(subscription)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(subscription)); MethodOutcome methodOutcome = myClient.create().resource(subscription).execute(); mySubscriptionIds.add(methodOutcome.getId()); waitForActivatedSubscriptionCount(1); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TermConceptMappingSvcImplTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TermConceptMappingSvcImplTest.java index 76c59ca4d5d..f6d36d5cec6 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TermConceptMappingSvcImplTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TermConceptMappingSvcImplTest.java @@ -1,9 +1,9 @@ package ca.uhn.fhir.jpa.term; import ca.uhn.fhir.context.support.TranslateConceptResult; +import ca.uhn.fhir.context.support.TranslateConceptResults; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.api.model.TranslationRequest; -import ca.uhn.fhir.context.support.TranslateConceptResults; import ca.uhn.fhir.jpa.entity.TermConceptMap; import ca.uhn.fhir.jpa.entity.TermConceptMapGroup; import ca.uhn.fhir.jpa.entity.TermConceptMapGroupElement; @@ -64,7 +64,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -118,7 +118,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -160,7 +160,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -213,7 +213,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -281,7 +281,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -329,7 +329,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -389,7 +389,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -459,7 +459,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -507,7 +507,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -567,7 +567,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -637,7 +637,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -707,7 +707,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -756,7 +756,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -779,7 +779,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -835,7 +835,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -884,7 +884,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -933,7 +933,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -991,7 +991,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -1051,7 +1051,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -1109,7 +1109,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -1194,7 +1194,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -1373,7 +1373,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test { createAndPersistConceptMap(); ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId); - ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.info("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcIntegrationDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcIntegrationDstu3Test.java index 3027c125dd7..0ba1720aa54 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcIntegrationDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcIntegrationDstu3Test.java @@ -83,7 +83,7 @@ public class TerminologyLoaderSvcIntegrationDstu3Test extends BaseJpaDstu3Test { .setValue("LP7753-9"); ValueSet expanded = myValueSetDao.expand(input, null); Set codes = toExpandedCodes(expanded); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded)); ourLog.info("Codes: {}", codes); assertThat(codes, containsInAnyOrder("10013-1")); @@ -99,7 +99,7 @@ public class TerminologyLoaderSvcIntegrationDstu3Test extends BaseJpaDstu3Test { .setValue("Qn"); expanded = myValueSetDao.expand(input, null); codes = toExpandedCodes(expanded); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded)); assertThat(codes, containsInAnyOrder("10013-1")); // Search by something that doesn't match @@ -114,7 +114,7 @@ public class TerminologyLoaderSvcIntegrationDstu3Test extends BaseJpaDstu3Test { .setValue("Qn999"); expanded = myValueSetDao.expand(input, null); codes = toExpandedCodes(expanded); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded)); assertThat(codes, empty()); } @@ -146,7 +146,7 @@ public class TerminologyLoaderSvcIntegrationDstu3Test extends BaseJpaDstu3Test { .setValue("EKG.MEAS"); ValueSet expanded = myValueSetDao.expand(input, null); Set codes = toExpandedCodes(expanded); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded)); ourLog.info("Codes: {}", codes); assertThat(codes, containsInAnyOrder("10013-1")); } @@ -158,9 +158,9 @@ public class TerminologyLoaderSvcIntegrationDstu3Test extends BaseJpaDstu3Test { myLoader.loadLoinc(files.getFiles(), mySrd); IValidationSupport.LookupCodeResult result = myCodeSystemDao.lookupCode(new StringType("10013-1"), new StringType(ITermLoaderSvc.LOINC_URI), null, mySrd); - Parameters parameters = (Parameters) result.toParameters(myFhirCtx, null); + Parameters parameters = (Parameters) result.toParameters(myFhirContext, null); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(parameters)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(parameters)); Optional propertyValue = findProperty(parameters, "SCALE_TYP"); assertTrue(propertyValue.isPresent()); @@ -188,9 +188,9 @@ public class TerminologyLoaderSvcIntegrationDstu3Test extends BaseJpaDstu3Test { myLoader.loadLoinc(files.getFiles(), mySrd); IValidationSupport.LookupCodeResult result = myCodeSystemDao.lookupCode(new StringType("10013-1"), new StringType(ITermLoaderSvc.LOINC_URI), null, mySrd); - Parameters parameters = (Parameters) result.toParameters(myFhirCtx, null); + Parameters parameters = (Parameters) result.toParameters(myFhirContext, null); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(parameters)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(parameters)); Optional propertyValue = findProperty(parameters, "COMPONENT"); assertTrue(propertyValue.isPresent()); @@ -207,9 +207,9 @@ public class TerminologyLoaderSvcIntegrationDstu3Test extends BaseJpaDstu3Test { IValidationSupport.LookupCodeResult result = myCodeSystemDao.lookupCode(new StringType("10013-1"), new StringType(ITermLoaderSvc.LOINC_URI), null, mySrd); List> properties = Lists.newArrayList(new CodeType("SCALE_TYP")); - Parameters parameters = (Parameters) result.toParameters(myFhirCtx, properties); + Parameters parameters = (Parameters) result.toParameters(myFhirContext, properties); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(parameters)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(parameters)); Optional propertyValueCoding = findProperty(parameters, "SCALE_TYP"); assertTrue(propertyValueCoding.isPresent()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcDeltaR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcDeltaR4Test.java index 9894c340308..717c5e0f14a 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcDeltaR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcDeltaR4Test.java @@ -489,8 +489,8 @@ public class TerminologySvcDeltaR4Test extends BaseJpaR4Test { assertEquals("lunch", result.getSearchedForCode()); assertEquals("http://foo/cs", result.getSearchedForSystem()); - Parameters output = (Parameters) result.toParameters(myFhirCtx, null); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); + Parameters output = (Parameters) result.toParameters(myFhirContext, null); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); assertEquals("Description of my life", ((StringType) output.getParameter("name")).getValue()); assertEquals("1.2.3", ((StringType) output.getParameter("version")).getValue()); @@ -603,7 +603,7 @@ public class TerminologySvcDeltaR4Test extends BaseJpaR4Test { vs.setUrl("http://foo/vs"); vs.getCompose().addInclude().setSystem("http://foo/cs"); vs = myValueSetDao.expand(vs, null); - ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(vs)); + ourLog.info(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(vs)); return vs; } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplCurrentVersionR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplCurrentVersionR4Test.java index 9a1af779089..6d4a8d40168 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplCurrentVersionR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplCurrentVersionR4Test.java @@ -3,7 +3,7 @@ package ca.uhn.fhir.jpa.term; import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.ValidationSupportContext; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; -import ca.uhn.fhir.jpa.config.BaseConfig; +import ca.uhn.fhir.jpa.config.JpaConfig; import ca.uhn.fhir.jpa.dao.r4.BaseJpaR4Test; import ca.uhn.fhir.jpa.entity.TermCodeSystem; import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion; @@ -134,7 +134,7 @@ public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test { @Autowired private ITermReadSvc myITermReadSvc; - @Autowired @Qualifier(BaseConfig.JPA_VALIDATION_SUPPORT) + @Autowired @Qualifier(JpaConfig.JPA_VALIDATION_SUPPORT) private IValidationSupport myJpaPersistedResourceValidationSupport; @Autowired private BatchJobHelper myBatchJobHelper; @@ -455,7 +455,7 @@ public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test { // _ current CS is present and has no version CodeSystem codeSystem = myCodeSystemDao.read(new IdType(LOINC_LOW)); - String csString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem); + String csString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem); ourLog.info("CodeSystem:\n" + csString); HashSet shouldNotBePresentVersions = new HashSet<>(possibleVersions); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplDstu3Test.java index 243ad34c57f..ea0d2d94d94 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplDstu3Test.java @@ -1853,7 +1853,7 @@ public class TerminologySvcImplDstu3Test extends BaseJpaDstu3Test { public void testStoreTermCodeSystemAndNestedChildren() { IIdType codeSystemId = createCodeSystem(); CodeSystem codeSystemResource = myCodeSystemDao.read(codeSystemId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystemResource)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystemResource)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplR4Test.java index 34c1b975289..dc189607b93 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplR4Test.java @@ -127,15 +127,15 @@ public class TerminologySvcImplR4Test extends BaseTermR4Test { loadAndPersistCodeSystemAndValueSetWithDesignations(HttpVerb.POST); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); myTermSvc.preExpandDeferredValueSetsToTerminologyTables(); ValueSet expandedValueSet = myTermSvc.expandValueSet(null, valueSet); - ourLog.info("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); + ourLog.info("Expanded ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); TermValueSet termValueSet = runInTransaction(()-> { TermValueSet vs = myTermValueSetDao.findByResourcePid(myExtensionalVsIdOnResourceTable).get(); @@ -168,15 +168,15 @@ public class TerminologySvcImplR4Test extends BaseTermR4Test { loadAndPersistCodeSystemAndValueSetWithDesignations(HttpVerb.PUT); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); myTermSvc.preExpandDeferredValueSetsToTerminologyTables(); ValueSet expandedValueSet = myTermSvc.expandValueSet(null, valueSet); - ourLog.info("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); + ourLog.info("Expanded ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); Long termValueSetId = runInTransaction(()-> { TermValueSet termValueSet = myTermValueSetDao.findByResourcePid(myExtensionalVsIdOnResourceTable).get(); @@ -249,10 +249,10 @@ public class TerminologySvcImplR4Test extends BaseTermR4Test { loadAndPersistCodeSystemAndValueSetWithDesignations(HttpVerb.POST); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); myTermSvc.preExpandDeferredValueSetsToTerminologyTables(); @@ -297,10 +297,10 @@ public class TerminologySvcImplR4Test extends BaseTermR4Test { loadAndPersistCodeSystemAndValueSetWithDesignations(HttpVerb.PUT); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); myTermSvc.preExpandDeferredValueSetsToTerminologyTables(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/ValueSetExpansionR4ElasticsearchIT.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/ValueSetExpansionR4ElasticsearchIT.java index 89d9b51a540..cc5f1ff0b6d 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/ValueSetExpansionR4ElasticsearchIT.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/ValueSetExpansionR4ElasticsearchIT.java @@ -213,7 +213,7 @@ public class ValueSetExpansionR4ElasticsearchIT extends BaseJpaTest { @Override - protected FhirContext getContext() { + protected FhirContext getFhirContext() { return myFhirContext; } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/ValueSetExpansionR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/ValueSetExpansionR4Test.java index f4e29a9e087..704bc802d47 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/ValueSetExpansionR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/ValueSetExpansionR4Test.java @@ -86,10 +86,10 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { loadAndPersistCodeSystemAndValueSetWithDesignations(HttpVerb.POST); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); myTermSvc.preExpandDeferredValueSetsToTerminologyTables(); @@ -118,7 +118,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { .addInclude() .setSystem("http://acme.org"); ValueSet expandedValueSet = myTermSvc.expandValueSet(new ValueSetExpansionOptions(), input); - ourLog.info("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); + ourLog.info("Expanded ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); assertEquals(24, expandedValueSet.getExpansion().getTotal()); } @@ -137,7 +137,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { .setValue("Systolic blood pressure--inspiration"); ValueSet expandedValueSet = myTermSvc.expandValueSet(new ValueSetExpansionOptions(), input); - ourLog.info("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); + ourLog.info("Expanded ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); assertEquals(1, expandedValueSet.getExpansion().getTotal()); assertThat(expandedValueSet.getExpansion().getContains().stream().map(t -> t.getDisplay()).collect(Collectors.toList()), containsInAnyOrder( @@ -159,7 +159,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { .setValue("Systolic blood pressure 1"); ValueSet expandedValueSet = myTermSvc.expandValueSet(new ValueSetExpansionOptions(), input); - ourLog.info("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); + ourLog.info("Expanded ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); assertEquals(3, expandedValueSet.getExpansion().getTotal()); assertThat(expandedValueSet.getExpansion().getContains().stream().map(t -> t.getDisplay()).collect(Collectors.toList()), containsInAnyOrder( @@ -185,7 +185,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { myCaptureQueriesListener.clear(); ValueSet expandedValueSet = myTermSvc.expandValueSet(new ValueSetExpansionOptions(), input); - ourLog.debug("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); + ourLog.debug("Expanded ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); assertThat(ValueSetTestUtil.toCodes(expandedValueSet).toString(), ValueSetTestUtil.toCodes(expandedValueSet), containsInAnyOrder( "code9", "code90", "code91", "code92", "code93", "code94", "code95", "code96", "code97", "code98", "code99" @@ -271,7 +271,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { ValueSet expandedValueSet = myTermSvc.expandValueSet(expansionOptions, input); - ourLog.debug("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); + ourLog.debug("Expanded ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); //Take our intial expanded list, and only get the elements that are relevant. expandedConceptCodes.removeIf(concept -> !concept.startsWith("code9")); @@ -303,7 +303,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { myCaptureQueriesListener.clear(); ValueSet expandedValueSet = myTermSvc.expandValueSet(null, input); - ourLog.debug("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); + ourLog.debug("Expanded ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); assertThat(ValueSetTestUtil.toCodes(expandedValueSet).toString(), ValueSetTestUtil.toCodes(expandedValueSet), contains("code99")); @@ -337,7 +337,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { myCaptureQueriesListener.clear(); ValueSet expandedValueSet = myTermSvc.expandValueSet(new ValueSetExpansionOptions(), input); - ourLog.debug("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); + ourLog.debug("Expanded ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); assertThat(ValueSetTestUtil.toCodes(expandedValueSet).toString(), ValueSetTestUtil.toCodes(expandedValueSet), containsInAnyOrder( "code9", "code91", "code92", "code93", "code94", "code95", "code96", "code97", "code98", "code99" @@ -436,7 +436,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { myCaptureQueriesListener.clear(); ValueSet expandedValueSet = myTermSvc.expandValueSet(new ValueSetExpansionOptions(), input); - ourLog.debug("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); + ourLog.debug("Expanded ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); assertThat(ValueSetTestUtil.toCodes(expandedValueSet).toString(), ValueSetTestUtil.toCodes(expandedValueSet), containsInAnyOrder( "code9", "code90", "code91", "code92", "code93", "code94", "code95", "code96", "code97", "code98", "code99" @@ -484,17 +484,17 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { loadAndPersistCodeSystemAndValueSetWithDesignations(HttpVerb.POST); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); myTermSvc.preExpandDeferredValueSetsToTerminologyTables(); myCaptureQueriesListener.clear(); ValueSet expandedValueSet = myTermSvc.expandValueSet(null, valueSet); - ourLog.info("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); + ourLog.info("Expanded ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); myCaptureQueriesListener.logSelectQueriesForCurrentThread(); assertEquals(3, myCaptureQueriesListener.getSelectQueriesForCurrentThread().size()); @@ -524,10 +524,10 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { public void testExpandTermValueSetAndChildren2() throws Exception { myDaoConfig.setPreExpandValueSets(true); - CodeSystem codeSystem = loadResource(myFhirCtx, CodeSystem.class, "/r4/CodeSystem-iar-chymh-cb-calculated-cap-10.xml"); + CodeSystem codeSystem = loadResource(myFhirContext, CodeSystem.class, "/r4/CodeSystem-iar-chymh-cb-calculated-cap-10.xml"); myCodeSystemDao.create(codeSystem); - ValueSet valueSet = loadResource(myFhirCtx, ValueSet.class, "/r4/ValueSet-iar-chymh-cb-calculated-cap-10.xml"); + ValueSet valueSet = loadResource(myFhirContext, ValueSet.class, "/r4/ValueSet-iar-chymh-cb-calculated-cap-10.xml"); myValueSetDao.create(valueSet); @@ -536,7 +536,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { myCaptureQueriesListener.clear(); ValueSet expandedValueSet = myTermSvc.expandValueSet(null, valueSet); - ourLog.info("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); + ourLog.info("Expanded ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); assertEquals(3, expandedValueSet.getExpansion().getContains().size()); } @@ -548,13 +548,13 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { myDaoConfig.setPreExpandValueSets(true); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); ValueSet expandedValueSet = myTermSvc.expandValueSet(null, valueSet); - ourLog.info("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); + ourLog.info("Expanded ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); assertEquals(codeSystem.getConcept().size(), expandedValueSet.getExpansion().getTotal()); assertEquals(myDaoConfig.getPreExpandValueSetsDefaultOffset(), expandedValueSet.getExpansion().getOffset()); @@ -572,7 +572,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { assertExpandedValueSetContainsConcept(expandedValueSet, "http://acme.org", "8492-1", "Systolic blood pressure 8 hour minimum", 0); ValueSet reexpandedValueSet = myTermSvc.expandValueSet(null, valueSet); - ourLog.info("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(reexpandedValueSet)); + ourLog.info("Expanded ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(reexpandedValueSet)); assertEquals(codeSystem.getConcept().size(), reexpandedValueSet.getExpansion().getTotal()); assertEquals(myDaoConfig.getPreExpandValueSetsDefaultOffset(), reexpandedValueSet.getExpansion().getOffset()); @@ -604,15 +604,15 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { loadAndPersistCodeSystemAndValueSetWithDesignations(HttpVerb.PUT); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); myTermSvc.preExpandDeferredValueSetsToTerminologyTables(); ValueSet expandedValueSet = myTermSvc.expandValueSet(null, valueSet); - ourLog.info("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); + ourLog.info("Expanded ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); assertEquals(codeSystem.getConcept().size(), expandedValueSet.getExpansion().getTotal()); assertEquals(myDaoConfig.getPreExpandValueSetsDefaultOffset(), expandedValueSet.getExpansion().getOffset()); @@ -643,10 +643,10 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { loadAndPersistCodeSystemAndValueSetWithDesignations(HttpVerb.POST); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); myTermSvc.preExpandDeferredValueSetsToTerminologyTables(); @@ -656,7 +656,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { .setOffset(0) .setCount(23); ValueSet expandedValueSet = myTermSvc.expandValueSet(options, valueSet); - ourLog.info("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); + ourLog.info("Expanded ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); assertEquals(codeSystem.getConcept().size(), expandedValueSet.getExpansion().getTotal()); assertEquals(myDaoConfig.getPreExpandValueSetsDefaultOffset(), expandedValueSet.getExpansion().getOffset()); @@ -678,7 +678,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { loadAndPersistCodeSystemAndValueSetWithDesignations(HttpVerb.PUT); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); // If this ever fails, it just means that new codes have been added to the // code system used by this test, so the numbers below may also need to be @@ -686,7 +686,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { assertEquals(24, codeSystem.getConcept().size()); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); myTermSvc.preExpandDeferredValueSetsToTerminologyTables(); @@ -694,7 +694,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { .setOffset(0) .setCount(24); ValueSet expandedValueSet = myTermSvc.expandValueSet(options, valueSet); - String expandedValueSetString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet); + String expandedValueSetString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet); ourLog.info("Expanded ValueSet:\n" + expandedValueSetString); assertThat(expandedValueSetString, containsString("ValueSet was expanded using an expansion that was pre-calculated")); @@ -726,10 +726,10 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { loadAndPersistCodeSystemAndValueSetWithDesignations(HttpVerb.POST); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); myTermSvc.preExpandDeferredValueSetsToTerminologyTables(); @@ -737,7 +737,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { .setOffset(0) .setCount(0); ValueSet expandedValueSet = myTermSvc.expandValueSet(options, valueSet); - String expanded = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet); + String expanded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet); ourLog.info("Expanded ValueSet:\n" + expanded); assertEquals(codeSystem.getConcept().size(), expandedValueSet.getExpansion().getTotal()); @@ -758,10 +758,10 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { loadAndPersistCodeSystemAndValueSetWithDesignations(HttpVerb.PUT); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); myTermSvc.preExpandDeferredValueSetsToTerminologyTables(); @@ -769,7 +769,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { .setOffset(0) .setCount(0); ValueSet expandedValueSet = myTermSvc.expandValueSet(options, valueSet); - ourLog.info("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); + ourLog.info("Expanded ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); assertEquals(codeSystem.getConcept().size(), expandedValueSet.getExpansion().getTotal()); assertEquals(myDaoConfig.getPreExpandValueSetsDefaultOffset(), expandedValueSet.getExpansion().getOffset()); @@ -789,10 +789,10 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { loadAndPersistCodeSystemAndValueSetWithDesignations(HttpVerb.POST); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); myTermSvc.preExpandDeferredValueSetsToTerminologyTables(); List expandedConcepts = getExpandedConceptsByValueSetUrl("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2"); @@ -800,7 +800,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { .setOffset(1) .setCount(1000); ValueSet expandedValueSet = myTermSvc.expandValueSet(options, valueSet); - ourLog.info("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); + ourLog.info("Expanded ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); assertEquals(codeSystem.getConcept().size(), expandedValueSet.getExpansion().getTotal()); assertEquals(1, expandedValueSet.getExpansion().getOffset()); @@ -821,10 +821,10 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { loadAndPersistCodeSystemAndValueSetWithDesignations(HttpVerb.PUT); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); myTermSvc.preExpandDeferredValueSetsToTerminologyTables(); List expandedConcepts = getExpandedConceptsByValueSetUrl("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2"); @@ -832,7 +832,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { .setOffset(1) .setCount(1000); ValueSet expandedValueSet = myTermSvc.expandValueSet(options, valueSet); - ourLog.info("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); + ourLog.info("Expanded ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); assertEquals(codeSystem.getConcept().size(), expandedValueSet.getExpansion().getTotal()); assertEquals(1, expandedValueSet.getExpansion().getOffset()); @@ -853,10 +853,10 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { loadAndPersistCodeSystemAndValueSetWithDesignations(HttpVerb.POST); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); myTermSvc.preExpandDeferredValueSetsToTerminologyTables(); @@ -866,7 +866,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { .setOffset(1) .setCount(22); ValueSet expandedValueSet = myTermSvc.expandValueSet(options, valueSet); - ourLog.info("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); + ourLog.info("Expanded ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); assertEquals(codeSystem.getConcept().size(), expandedValueSet.getExpansion().getTotal()); assertEquals(1, expandedValueSet.getExpansion().getOffset()); @@ -949,10 +949,10 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { loadAndPersistCodeSystemAndValueSetWithDesignations(HttpVerb.PUT); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); myTermSvc.preExpandDeferredValueSetsToTerminologyTables(); @@ -962,7 +962,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { .setOffset(1) .setCount(22); ValueSet expandedValueSet = myTermSvc.expandValueSet(options, valueSet); - ourLog.info("Expanded ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); + ourLog.info("Expanded ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expandedValueSet)); assertEquals(codeSystem.getConcept().size(), expandedValueSet.getExpansion().getTotal()); assertEquals(1, expandedValueSet.getExpansion().getOffset()); @@ -1079,7 +1079,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { loadAndPersistCodeSystemWithDesignations(HttpVerb.POST); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -1147,7 +1147,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { loadAndPersistCodeSystemWithDesignations(HttpVerb.PUT); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -1213,7 +1213,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { public void testStoreTermCodeSystemAndNestedChildren() { IIdType codeSystemId = createCodeSystem(); CodeSystem codeSystemResource = myCodeSystemDao.read(codeSystemId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystemResource)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystemResource)); new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() { @Override @@ -1315,10 +1315,10 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { loadAndPersistCodeSystemAndValueSetWithDesignations(HttpVerb.POST); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); runInTransaction(() -> { Optional optionalValueSetByResourcePid = myTermValueSetDao.findByResourcePid(myExtensionalVsIdOnResourceTable); @@ -1376,10 +1376,10 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { loadAndPersistCodeSystemAndValueSetWithDesignations(HttpVerb.PUT); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); runInTransaction(() -> { Optional optionalValueSetByResourcePid = myTermValueSetDao.findByResourcePid(myExtensionalVsIdOnResourceTable); @@ -1434,10 +1434,10 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { loadAndPersistCodeSystemAndValueSetWithDesignationsAndExclude(HttpVerb.POST); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); runInTransaction(() -> { Optional optionalValueSetByResourcePid = myTermValueSetDao.findByResourcePid(myExtensionalVsIdOnResourceTable); @@ -1494,10 +1494,10 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { loadAndPersistCodeSystemAndValueSetWithDesignationsAndExclude(HttpVerb.PUT); CodeSystem codeSystem = myCodeSystemDao.read(myExtensionalCsId); - ourLog.info("CodeSystem:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); + ourLog.info("CodeSystem:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem)); ValueSet valueSet = myValueSetDao.read(myExtensionalVsId); - ourLog.info("ValueSet:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); + ourLog.info("ValueSet:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(valueSet)); runInTransaction(() -> { Optional optionalValueSetByResourcePid = myTermValueSetDao.findByResourcePid(myExtensionalVsIdOnResourceTable); @@ -1706,7 +1706,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { // In memory expansion ValueSet expansion = myValueSetDao.expand(vs, new ValueSetExpansionOptions()); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); assertThat(ValueSetTestUtil.extractExpansionMessage(expansion), containsString("has not yet been pre-expanded")); assertThat(ValueSetTestUtil.extractExpansionMessage(expansion), containsString("Current status: NOT_EXPANDED")); assertThat(ValueSetTestUtil.toCodes(expansion), contains("28571000087109")); @@ -1729,7 +1729,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { // Try expansion again expansion = myValueSetDao.expand(vs, new ValueSetExpansionOptions()); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); assertThat(ValueSetTestUtil.extractExpansionMessage(expansion), containsString("ValueSet was expanded using an expansion that was pre-calculated")); assertThat(ValueSetTestUtil.toCodes(expansion), contains("28571000087109")); } @@ -1971,7 +1971,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { // Expand ValueSet expansion = myValueSetDao.expand(new IdType("ValueSet/vs"), new ValueSetExpansionOptions(), mySrd); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); assertThat(ValueSetTestUtil.extractExpansionMessage(expansion), containsString("ValueSet was expanded using an expansion that was pre-calculated")); assertThat(ValueSetTestUtil.toCodes(expansion), contains("A")); @@ -1989,7 +1989,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { // Expand (should not use a precalculated expansion) expansion = myValueSetDao.expand(new IdType("ValueSet/vs"), new ValueSetExpansionOptions(), mySrd); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); assertThat(ValueSetTestUtil.extractExpansionMessage(expansion), containsString("Performing in-memory expansion without parameters")); assertThat(ValueSetTestUtil.toCodes(expansion), contains("B")); @@ -1999,7 +1999,7 @@ public class ValueSetExpansionR4Test extends BaseTermR4Test { // Expand (should use the new precalculated expansion) expansion = myValueSetDao.expand(new IdType("ValueSet/vs"), new ValueSetExpansionOptions(), mySrd); - ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); + ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); assertThat(ValueSetTestUtil.extractExpansionMessage(expansion), containsString("ValueSet was expanded using an expansion that was pre-calculated")); assertThat(ValueSetTestUtil.toCodes(expansion), contains("B")); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/util/jsonpatch/JsonPatchUtilsTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/util/jsonpatch/JsonPatchUtilsTest.java index b475b2d561e..a2f2351bd4d 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/util/jsonpatch/JsonPatchUtilsTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/util/jsonpatch/JsonPatchUtilsTest.java @@ -120,7 +120,7 @@ public class JsonPatchUtilsTest extends BaseJpaTest { } @Override - protected FhirContext getContext() { + protected FhirContext getFhirContext() { return ourCtx; } diff --git a/hapi-fhir-jpaserver-cql/pom.xml b/hapi-fhir-jpaserver-cql/pom.xml index d401b369888..3f6ce83f705 100644 --- a/hapi-fhir-jpaserver-cql/pom.xml +++ b/hapi-fhir-jpaserver-cql/pom.xml @@ -7,7 +7,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml @@ -144,6 +144,14 @@ + + ca.uhn.hapi.fhir + hapi-fhir-jpaserver-base + ${project.version} + tests + test-jar + test + org.testcontainers junit-jupiter diff --git a/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/BaseCqlDstu3Test.java b/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/BaseCqlDstu3Test.java index 40023219d7f..084453c5c94 100644 --- a/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/BaseCqlDstu3Test.java +++ b/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/BaseCqlDstu3Test.java @@ -7,8 +7,8 @@ import ca.uhn.fhir.cql.config.CqlDstu3Config; import ca.uhn.fhir.cql.config.TestCqlConfig; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; +import ca.uhn.fhir.jpa.dao.dstu3.BaseJpaDstu3Test; import ca.uhn.fhir.jpa.subscription.match.config.SubscriptionProcessorConfig; -import ca.uhn.fhir.jpa.test.BaseJpaDstu3Test; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.test.utilities.RequestDetailsHelper; import org.apache.commons.io.FileUtils; @@ -38,9 +38,6 @@ public class BaseCqlDstu3Test extends BaseJpaDstu3Test implements CqlProviderTes protected DaoRegistry myDaoRegistry; @Autowired - protected - FhirContext myFhirContext; - @Autowired IFhirSystemDao mySystemDao; @Autowired @RegisterExtension @@ -72,11 +69,6 @@ public class BaseCqlDstu3Test extends BaseJpaDstu3Test implements CqlProviderTes return count; } - @Override - public FhirContext getFhirContext() { - return myFhirContext; - } - @Override public DaoRegistry getDaoRegistry() { return myDaoRegistry; @@ -105,5 +97,8 @@ public class BaseCqlDstu3Test extends BaseJpaDstu3Test implements CqlProviderTes return loadBundle(bundle); } - + @Override + public FhirContext getTestFhirContext() { + return myFhirContext; + } } diff --git a/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/BaseCqlR4Test.java b/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/BaseCqlR4Test.java index c72f603cca3..11a4b371f94 100644 --- a/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/BaseCqlR4Test.java +++ b/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/BaseCqlR4Test.java @@ -8,8 +8,9 @@ import ca.uhn.fhir.cql.config.TestCqlConfig; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; +import ca.uhn.fhir.jpa.dao.r4.BaseJpaR4Test; import ca.uhn.fhir.jpa.subscription.match.config.SubscriptionProcessorConfig; -import ca.uhn.fhir.jpa.test.BaseJpaR4Test; +import ca.uhn.fhir.parser.LenientErrorHandler; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.test.utilities.RequestDetailsHelper; import org.apache.commons.io.FileUtils; @@ -46,9 +47,6 @@ public class BaseCqlR4Test extends BaseJpaR4Test implements CqlProviderTestBase protected DaoRegistry myDaoRegistry; @Autowired - protected - FhirContext myFhirContext; - @Autowired IFhirSystemDao mySystemDao; @Autowired DaoConfig myDaoConfig; @@ -56,6 +54,8 @@ public class BaseCqlR4Test extends BaseJpaR4Test implements CqlProviderTestBase @BeforeEach public void beforeEach() { myDaoConfig.setMaximumExpansionSize(5000); + // We load some dstu3 resources using a R4 FhirContext. Disable strict handling so this doesn't throw errors. + myFhirContext.setParserErrorHandler(new LenientErrorHandler()); } @AfterEach @@ -89,11 +89,6 @@ public class BaseCqlR4Test extends BaseJpaR4Test implements CqlProviderTestBase return count; } - @Override - public FhirContext getFhirContext() { - return myFhirContext; - } - @Override public DaoRegistry getDaoRegistry() { return myDaoRegistry; @@ -121,4 +116,9 @@ public class BaseCqlR4Test extends BaseJpaR4Test implements CqlProviderTestBase return new PartitionHelper(); } } + + @Override + public FhirContext getTestFhirContext() { + return myFhirContext; + } } diff --git a/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/common/helper/TranslatorHelperTest.java b/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/common/helper/TranslatorHelperTest.java index 3d67a741603..d4bcdc4a17d 100644 --- a/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/common/helper/TranslatorHelperTest.java +++ b/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/common/helper/TranslatorHelperTest.java @@ -17,7 +17,6 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.MockedStatic; import org.mockito.MockitoAnnotations; @@ -204,7 +203,7 @@ public class TranslatorHelperTest implements CqlProviderTestBase { } @Override - public FhirContext getFhirContext() { + public FhirContext getTestFhirContext() { return null; } diff --git a/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/common/provider/CqlProviderTestBase.java b/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/common/provider/CqlProviderTestBase.java index b7112ea95c4..0520be9d523 100644 --- a/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/common/provider/CqlProviderTestBase.java +++ b/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/common/provider/CqlProviderTestBase.java @@ -17,13 +17,13 @@ import java.io.InputStream; public interface CqlProviderTestBase { - FhirContext getFhirContext(); + FhirContext getTestFhirContext(); DaoRegistry getDaoRegistry(); default IBaseResource loadResource(String theLocation, RequestDetails theRequestDetails) throws IOException { String json = stringFromResource(theLocation); - IBaseResource resource = getFhirContext().newJsonParser().parseResource(json); + IBaseResource resource = getTestFhirContext().newJsonParser().parseResource(json); IFhirResourceDao dao = getDaoRegistry().getResourceDao(resource.getIdElement().getResourceType()); if (dao == null) { return null; diff --git a/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/r4/CqlProviderR4Test.java b/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/r4/CqlProviderR4Test.java index 89e15e71605..c955ca6b823 100644 --- a/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/r4/CqlProviderR4Test.java +++ b/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/r4/CqlProviderR4Test.java @@ -22,7 +22,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class CqlProviderR4Test extends BaseCqlR4Test implements CqlProviderTestBase { private static final Logger ourLog = LoggerFactory.getLogger(CqlProviderR4Test.class); - private static final IdType libraryId = new IdType("Library", "library-mrp-logic"); private static final IdType measureId = new IdType("Measure", "measure-asf"); private static final String measure = "Measure/measure-asf"; private static final String patient = "Patient/Patient-6529"; diff --git a/hapi-fhir-jpaserver-mdm/pom.xml b/hapi-fhir-jpaserver-mdm/pom.xml index 07b2f843538..ffb8f0d40d1 100644 --- a/hapi-fhir-jpaserver-mdm/pom.xml +++ b/hapi-fhir-jpaserver-mdm/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml @@ -32,6 +32,14 @@ ${project.version} + + ca.uhn.hapi.fhir + hapi-fhir-jpaserver-base + ${project.version} + tests + test-jar + test + org.awaitility awaitility diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/BaseMdmR4Test.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/BaseMdmR4Test.java index 6e552d13ee9..f545231c81a 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/BaseMdmR4Test.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/BaseMdmR4Test.java @@ -1,12 +1,12 @@ package ca.uhn.fhir.jpa.mdm; -import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome; import ca.uhn.fhir.jpa.dao.data.IMdmLinkDao; import ca.uhn.fhir.jpa.dao.index.IdHelperService; +import ca.uhn.fhir.jpa.dao.r4.BaseJpaR4Test; import ca.uhn.fhir.jpa.entity.MdmLink; import ca.uhn.fhir.jpa.mdm.config.MdmConsumerConfig; import ca.uhn.fhir.jpa.mdm.config.MdmSubmitterConfig; @@ -22,7 +22,6 @@ import ca.uhn.fhir.jpa.mdm.svc.MdmMatchLinkSvc; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.searchparam.registry.SearchParamRegistryImpl; import ca.uhn.fhir.jpa.subscription.match.config.SubscriptionProcessorConfig; -import ca.uhn.fhir.jpa.test.BaseJpaR4Test; import ca.uhn.fhir.mdm.api.IMdmSettings; import ca.uhn.fhir.mdm.api.MdmConstants; import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum; @@ -88,8 +87,6 @@ abstract public class BaseMdmR4Test extends BaseJpaR4Test { .setValue("555-555-5555"); private static final String NAME_GIVEN_FRANK = "Frank"; @Autowired - protected FhirContext myFhirContext; - @Autowired protected IFhirResourceDao myPatientDao; @Autowired protected IFhirResourceDao myOrganizationDao; @@ -126,12 +123,10 @@ abstract public class BaseMdmR4Test extends BaseJpaR4Test { myRequestDetails = new ServletRequestDetails(myInterceptorBroadcaster); } - @Override @AfterEach public void after() throws IOException { myMdmLinkDao.deleteAll(); assertEquals(0, myMdmLinkDao.count()); - super.after(); } protected void saveLink(MdmLink theMdmLink) { diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkSvcTest.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkSvcTest.java index 88ab341020f..629ae40b2f1 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkSvcTest.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkSvcTest.java @@ -1,6 +1,7 @@ package ca.uhn.fhir.jpa.mdm.svc; import ca.uhn.fhir.i18n.Msg; +import ca.uhn.fhir.jpa.dao.expunge.ExpungeEverythingService; import ca.uhn.fhir.jpa.entity.MdmLink; import ca.uhn.fhir.jpa.mdm.BaseMdmR4Test; import ca.uhn.fhir.mdm.api.IMdmLinkSvc; @@ -31,6 +32,8 @@ public class MdmLinkSvcTest extends BaseMdmR4Test { private static final MdmMatchOutcome POSSIBLE_MATCH = new MdmMatchOutcome(null, null).setMatchResultEnum(MdmMatchResultEnum.POSSIBLE_MATCH); @Autowired IMdmLinkSvc myMdmLinkSvc; + @Autowired + ExpungeEverythingService myExpungeEverythingService; @Override @AfterEach diff --git a/hapi-fhir-jpaserver-model/pom.xml b/hapi-fhir-jpaserver-model/pom.xml index 2678b113eab..5105bfcfb69 100644 --- a/hapi-fhir-jpaserver-model/pom.xml +++ b/hapi-fhir-jpaserver-model/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-searchparam/pom.xml b/hapi-fhir-jpaserver-searchparam/pom.xml index 8b42efd6b8a..46f71d77776 100755 --- a/hapi-fhir-jpaserver-searchparam/pom.xml +++ b/hapi-fhir-jpaserver-searchparam/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/cache/ResourceChangeListenerCacheFactory.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/cache/ResourceChangeListenerCacheFactory.java index a127ba82a31..5aded0f3b1a 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/cache/ResourceChangeListenerCacheFactory.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/cache/ResourceChangeListenerCacheFactory.java @@ -30,7 +30,7 @@ public class ResourceChangeListenerCacheFactory { @Autowired ApplicationContext myApplicationContext; - public ResourceChangeListenerCache create(String theResourceName, SearchParameterMap theMap, IResourceChangeListener theResourceChangeListener, long theRemoteRefreshIntervalMs) { + public ResourceChangeListenerCache newResourceChangeListenerCache(String theResourceName, SearchParameterMap theMap, IResourceChangeListener theResourceChangeListener, long theRemoteRefreshIntervalMs) { return myApplicationContext.getBean(ResourceChangeListenerCache.class, theResourceName, theResourceChangeListener, theMap, theRemoteRefreshIntervalMs); } } diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/cache/ResourceChangeListenerRegistryImpl.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/cache/ResourceChangeListenerRegistryImpl.java index 39642f03f2d..f618c033639 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/cache/ResourceChangeListenerRegistryImpl.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/cache/ResourceChangeListenerRegistryImpl.java @@ -20,9 +20,9 @@ package ca.uhn.fhir.jpa.cache; * #L% */ -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.RuntimeResourceDefinition; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.searchparam.matcher.InMemoryMatchResult; import ca.uhn.fhir.jpa.searchparam.matcher.InMemoryResourceMatcher; @@ -30,7 +30,6 @@ import com.google.common.annotations.VisibleForTesting; import org.hl7.fhir.instance.model.api.IBaseResource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.annotation.Nonnull; @@ -49,25 +48,13 @@ import java.util.concurrent.ConcurrentLinkedQueue; public class ResourceChangeListenerRegistryImpl implements IResourceChangeListenerRegistry { private static final Logger ourLog = LoggerFactory.getLogger(ResourceChangeListenerRegistryImpl.class); private final Queue myListenerEntries = new ConcurrentLinkedQueue<>(); - @Autowired - ResourceChangeListenerCacheFactory myResourceChangeListenerCacheFactory; - @Autowired - private FhirContext myFhirContext; - @Autowired + private final FhirContext myFhirContext; + private final ResourceChangeListenerCacheFactory myResourceChangeListenerCacheFactory; private InMemoryResourceMatcher myInMemoryResourceMatcher; - @VisibleForTesting - public void setResourceChangeListenerCacheFactory(ResourceChangeListenerCacheFactory theResourceChangeListenerCacheFactory) { - myResourceChangeListenerCacheFactory = theResourceChangeListenerCacheFactory; - } - - @VisibleForTesting - public void setFhirContext(FhirContext theFhirContext) { + public ResourceChangeListenerRegistryImpl(FhirContext theFhirContext, ResourceChangeListenerCacheFactory theResourceChangeListenerCacheFactory, InMemoryResourceMatcher theInMemoryResourceMatcher) { myFhirContext = theFhirContext; - } - - @VisibleForTesting - public void setInMemoryResourceMatcher(InMemoryResourceMatcher theInMemoryResourceMatcher) { + myResourceChangeListenerCacheFactory = theResourceChangeListenerCacheFactory; myInMemoryResourceMatcher = theInMemoryResourceMatcher; } @@ -112,7 +99,7 @@ public class ResourceChangeListenerRegistryImpl implements IResourceChangeListen } private IResourceChangeListenerCache add(String theResourceName, IResourceChangeListener theResourceChangeListener, SearchParameterMap theMap, long theRemoteRefreshIntervalMs) { - ResourceChangeListenerCache retval = myResourceChangeListenerCacheFactory.create(theResourceName, theMap, theResourceChangeListener, theRemoteRefreshIntervalMs); + ResourceChangeListenerCache retval = myResourceChangeListenerCacheFactory.newResourceChangeListenerCache(theResourceName, theMap, theResourceChangeListener, theRemoteRefreshIntervalMs); myListenerEntries.add(retval); return retval; } diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/config/SearchParamConfig.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/config/SearchParamConfig.java index a1e1b8fe514..92cf0349eca 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/config/SearchParamConfig.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/config/SearchParamConfig.java @@ -20,8 +20,8 @@ package ca.uhn.fhir.jpa.searchparam.config; * #L% */ -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.cache.IResourceChangeListener; import ca.uhn.fhir.jpa.cache.IResourceChangeListenerCacheRefresher; import ca.uhn.fhir.jpa.cache.IResourceChangeListenerRegistry; @@ -40,9 +40,9 @@ import ca.uhn.fhir.jpa.searchparam.extractor.SearchParamExtractorService; import ca.uhn.fhir.jpa.searchparam.matcher.InMemoryResourceMatcher; import ca.uhn.fhir.jpa.searchparam.matcher.IndexedSearchParamExtractor; import ca.uhn.fhir.jpa.searchparam.matcher.SearchParamMatcher; -import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import ca.uhn.fhir.jpa.searchparam.registry.SearchParamRegistryImpl; import ca.uhn.fhir.jpa.searchparam.registry.SearchParameterCanonicalizer; +import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -86,7 +86,7 @@ public class SearchParamConfig { @Bean @Lazy - public SearchParamExtractorService searchParamExtractorService(){ + public SearchParamExtractorService searchParamExtractorService() { return new SearchParamExtractorService(); } @@ -112,8 +112,8 @@ public class SearchParamConfig { } @Bean - IResourceChangeListenerRegistry resourceChangeListenerRegistry() { - return new ResourceChangeListenerRegistryImpl(); + IResourceChangeListenerRegistry resourceChangeListenerRegistry(FhirContext theFhirContext, ResourceChangeListenerCacheFactory theResourceChangeListenerCacheFactory, InMemoryResourceMatcher theInMemoryResourceMatcher) { + return new ResourceChangeListenerRegistryImpl(theFhirContext, theResourceChangeListenerCacheFactory, theInMemoryResourceMatcher); } @Bean @@ -122,9 +122,10 @@ public class SearchParamConfig { } @Bean - ResourceChangeListenerCacheFactory registeredResourceListenerFactory() { + ResourceChangeListenerCacheFactory registeredResourceListenerFactory() { return new ResourceChangeListenerCacheFactory(); } + @Bean @Scope("prototype") ResourceChangeListenerCache registeredResourceChangeListener(String theResourceName, IResourceChangeListener theResourceChangeListener, SearchParameterMap theSearchParameterMap, long theRemoteRefreshIntervalMs) { diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/matcher/InMemoryResourceMatcher.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/matcher/InMemoryResourceMatcher.java index 8e80d941511..6d57fb31b33 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/matcher/InMemoryResourceMatcher.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/matcher/InMemoryResourceMatcher.java @@ -20,15 +20,14 @@ package ca.uhn.fhir.jpa.searchparam.matcher; * #L% */ -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.context.RuntimeSearchParam; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.jpa.searchparam.MatchUrlService; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.searchparam.extractor.ResourceIndexedSearchParams; -import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import ca.uhn.fhir.jpa.searchparam.util.SourceParam; import ca.uhn.fhir.model.api.IQueryParameterType; import ca.uhn.fhir.rest.api.Constants; @@ -38,6 +37,7 @@ import ca.uhn.fhir.rest.param.ParamPrefixEnum; import ca.uhn.fhir.rest.param.ReferenceParam; import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; +import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import ca.uhn.fhir.util.MetaUtil; import ca.uhn.fhir.util.UrlUtil; import org.apache.commons.lang3.Validate; @@ -63,6 +63,8 @@ public class InMemoryResourceMatcher { @Autowired FhirContext myFhirContext; + public InMemoryResourceMatcher() {} + /** * This method is called in two different scenarios. With a null theResource, it determines whether database matching might be required. * Otherwise, it tries to perform the match in-memory, returning UNSUPPORTED if it's not possible. diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/registry/SearchParamRegistryImpl.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/registry/SearchParamRegistryImpl.java index cb43a41a948..9d319ccc912 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/registry/SearchParamRegistryImpl.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/registry/SearchParamRegistryImpl.java @@ -20,10 +20,10 @@ package ca.uhn.fhir.jpa.searchparam.registry; * #L% */ -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.RuntimeSearchParam; import ca.uhn.fhir.context.phonetic.IPhoneticEncoder; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.interceptor.api.IInterceptorService; import ca.uhn.fhir.jpa.cache.IResourceChangeEvent; import ca.uhn.fhir.jpa.cache.IResourceChangeListener; @@ -71,6 +71,7 @@ public class SearchParamRegistryImpl implements ISearchParamRegistry, IResourceC private static final Logger ourLog = LoggerFactory.getLogger(SearchParamRegistryImpl.class); private static final int MAX_MANAGED_PARAM_COUNT = 10000; private static final long REFRESH_INTERVAL = DateUtils.MILLIS_PER_HOUR; + private final JpaSearchParamCache myJpaSearchParamCache = new JpaSearchParamCache(); @Autowired private ModelConfig myModelConfig; @@ -81,13 +82,14 @@ public class SearchParamRegistryImpl implements ISearchParamRegistry, IResourceC @Autowired private SearchParameterCanonicalizer mySearchParameterCanonicalizer; @Autowired + private IInterceptorService myInterceptorBroadcaster; + @Autowired private IResourceChangeListenerRegistry myResourceChangeListenerRegistry; + + private IResourceChangeListenerCache myResourceChangeListenerCache; private volatile ReadOnlySearchParamCache myBuiltInSearchParams; private volatile IPhoneticEncoder myPhoneticEncoder; private volatile RuntimeSearchParamCache myActiveSearchParams; - @Autowired - private IInterceptorService myInterceptorBroadcaster; - private IResourceChangeListenerCache myResourceChangeListenerCache; /** * Constructor diff --git a/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/cache/ResourceChangeListenerCacheTest.java b/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/cache/ResourceChangeListenerCacheTest.java index eaebdcf038b..b8ead1fa54a 100644 --- a/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/cache/ResourceChangeListenerCacheTest.java +++ b/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/cache/ResourceChangeListenerCacheTest.java @@ -44,7 +44,7 @@ class ResourceChangeListenerCacheTest { @Test public void doNotRefreshIfNotMatches() { - ResourceChangeListenerCache cache = myResourceChangeListenerCacheFactory.create(TEST_RESOURCE_NAME, ourMap, mock(IResourceChangeListener.class), TEST_REFRESH_INTERVAL); + ResourceChangeListenerCache cache = myResourceChangeListenerCacheFactory.newResourceChangeListenerCache(TEST_RESOURCE_NAME, ourMap, mock(IResourceChangeListener.class), TEST_REFRESH_INTERVAL); cache.forceRefresh(); assertNotEquals(Instant.MIN, cache.getNextRefreshTimeForUnitTest()); @@ -65,7 +65,7 @@ class ResourceChangeListenerCacheTest { @Test public void testSchedule() { - ResourceChangeListenerCache cache = myResourceChangeListenerCacheFactory.create(TEST_RESOURCE_NAME, ourMap, ourListener, TEST_REFRESH_INTERVAL); + ResourceChangeListenerCache cache = myResourceChangeListenerCacheFactory.newResourceChangeListenerCache(TEST_RESOURCE_NAME, ourMap, ourListener, TEST_REFRESH_INTERVAL); ResourceChangeListenerCache.setNowForUnitTests("08:00:00"); cache.refreshCacheIfNecessary(); verify(myResourceChangeListenerCacheRefresher, times(1)).refreshCacheAndNotifyListener(any()); diff --git a/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/cache/ResourceChangeListenerRegistryImplTest.java b/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/cache/ResourceChangeListenerRegistryImplTest.java index 8f7a1035231..1817dda2699 100644 --- a/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/cache/ResourceChangeListenerRegistryImplTest.java +++ b/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/cache/ResourceChangeListenerRegistryImplTest.java @@ -65,9 +65,12 @@ class ResourceChangeListenerRegistryImplTest { @Configuration @Import(RegisteredResourceListenerFactoryConfig.class) static class SpringContext { + @Autowired + ResourceChangeListenerCacheFactory myResourceChangeListenerCacheFactory; + @Bean - public IResourceChangeListenerRegistry resourceChangeListenerRegistry() { - return new ResourceChangeListenerRegistryImpl(); + public IResourceChangeListenerRegistry resourceChangeListenerRegistry(InMemoryResourceMatcher theInMemoryResourceMatcher) { + return new ResourceChangeListenerRegistryImpl(ourFhirContext, myResourceChangeListenerCacheFactory, theInMemoryResourceMatcher); } @Bean @@ -79,7 +82,7 @@ class ResourceChangeListenerRegistryImplTest { @BeforeEach public void before() { Set entries = new HashSet<>(); - IResourceChangeListenerCache cache = myResourceChangeListenerCacheFactory.create(PATIENT_RESOURCE_NAME, ourMap, myTestListener, TEST_REFRESH_INTERVAL_MS); + IResourceChangeListenerCache cache = myResourceChangeListenerCacheFactory.newResourceChangeListenerCache(PATIENT_RESOURCE_NAME, ourMap, myTestListener, TEST_REFRESH_INTERVAL_MS); entries.add(cache); when(myInMemoryResourceMatcher.canBeEvaluatedInMemory(any(), any())).thenReturn(InMemoryMatchResult.successfulMatch()); } 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 a8e46ee64a2..b7cb1a94619 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 @@ -5,6 +5,7 @@ import ca.uhn.fhir.context.RuntimeSearchParam; import ca.uhn.fhir.interceptor.api.IInterceptorService; import ca.uhn.fhir.jpa.cache.IResourceChangeListenerRegistry; import ca.uhn.fhir.jpa.cache.IResourceVersionSvc; +import ca.uhn.fhir.jpa.cache.ResourceChangeListenerCacheFactory; import ca.uhn.fhir.jpa.cache.ResourceChangeListenerCacheRefresherImpl; import ca.uhn.fhir.jpa.cache.ResourceChangeListenerRegistryImpl; import ca.uhn.fhir.jpa.cache.ResourceChangeResult; @@ -126,8 +127,8 @@ public class SearchParamRegistryImplTest { } @Bean - IResourceChangeListenerRegistry resourceChangeListenerRegistry() { - return new ResourceChangeListenerRegistryImpl(); + IResourceChangeListenerRegistry resourceChangeListenerRegistry(FhirContext theFhirContext, ResourceChangeListenerCacheFactory theResourceChangeListenerCacheFactory, InMemoryResourceMatcher theInMemoryResourceMatcher) { + return new ResourceChangeListenerRegistryImpl(theFhirContext, theResourceChangeListenerCacheFactory, theInMemoryResourceMatcher); } @Bean diff --git a/hapi-fhir-jpaserver-subscription/pom.xml b/hapi-fhir-jpaserver-subscription/pom.xml index 91c879b2cc0..51218edb5aa 100644 --- a/hapi-fhir-jpaserver-subscription/pom.xml +++ b/hapi-fhir-jpaserver-subscription/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/config/WebsocketDispatcherConfig.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/config/WebsocketDispatcherConfig.java index f73db1dadb8..e08f6dfe59b 100644 --- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/config/WebsocketDispatcherConfig.java +++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/config/WebsocketDispatcherConfig.java @@ -23,7 +23,6 @@ package ca.uhn.fhir.jpa.subscription.match.config; import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.jpa.subscription.match.deliver.websocket.SubscriptionWebsocketHandler; import ca.uhn.fhir.jpa.subscription.match.deliver.websocket.WebsocketConnectionValidator; -import org.springframework.beans.factory.annotation.Autowire; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -52,7 +51,7 @@ public class WebsocketDispatcherConfig implements WebSocketConfigurer { theRegistry.addHandler(subscriptionWebSocketHandler(), myModelConfig.getWebsocketContextPath()).setAllowedOrigins("*"); } - @Bean(autowire = Autowire.BY_TYPE) + @Bean public WebSocketHandler subscriptionWebSocketHandler() { PerConnectionWebSocketHandler retVal = new PerConnectionWebSocketHandler(SubscriptionWebsocketHandler.class); return retVal; diff --git a/hapi-fhir-jpaserver-test-utilities/pom.xml b/hapi-fhir-jpaserver-test-utilities/pom.xml index 73ce2dbaa01..0aa73761014 100644 --- a/hapi-fhir-jpaserver-test-utilities/pom.xml +++ b/hapi-fhir-jpaserver-test-utilities/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/config/TestJpaConfig.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/config/TestJpaConfig.java deleted file mode 100644 index 37f0b15ced2..00000000000 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/config/TestJpaConfig.java +++ /dev/null @@ -1,67 +0,0 @@ -package ca.uhn.fhir.jpa.config; - -/*- - * #%L - * HAPI FHIR JPA Server Test Utilities - * %% - * Copyright (C) 2014 - 2022 Smile CDR, Inc. - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - -import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.jpa.binstore.IBinaryStorageSvc; -import ca.uhn.fhir.jpa.binstore.MemoryBinaryStorageSvcImpl; -import ca.uhn.fhir.jpa.model.config.PartitionSettings; -import ca.uhn.fhir.jpa.model.entity.ModelConfig; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Lazy; -import org.springframework.context.annotation.Primary; -import org.springframework.orm.jpa.JpaTransactionManager; - -import javax.persistence.EntityManagerFactory; -// TODO RC1 can use in jpa tests? -@Configuration -public class TestJpaConfig { - @Bean - public DaoConfig daoConfig() { - DaoConfig daoConfig = new DaoConfig(); - return daoConfig; - } - - @Bean - public ModelConfig modelConfig() { - return daoConfig().getModelConfig(); - } - - @Bean - @Lazy - public IBinaryStorageSvc binaryStorage() { - return new MemoryBinaryStorageSvcImpl(); - } - - @Bean - @Primary - public JpaTransactionManager hapiTransactionManager(EntityManagerFactory entityManagerFactory) { - JpaTransactionManager retVal = new JpaTransactionManager(); - retVal.setEntityManagerFactory(entityManagerFactory); - return retVal; - } - - @Bean - public PartitionSettings partitionSettings() { - return new PartitionSettings(); - } -} diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/config/TestJpaDstu3Config.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/config/TestJpaDstu3Config.java deleted file mode 100644 index 8647ae26036..00000000000 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/config/TestJpaDstu3Config.java +++ /dev/null @@ -1,141 +0,0 @@ -package ca.uhn.fhir.jpa.config; - -/*- - * #%L - * HAPI FHIR JPA Server Test Utilities - * %% - * Copyright (C) 2014 - 2022 Smile CDR, Inc. - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - -import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.support.DefaultProfileValidationSupport; -import ca.uhn.fhir.jpa.search.HapiLuceneAnalysisConfigurer; -import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener; -import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; -import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; -import ca.uhn.fhir.validation.ResultSeverityEnum; -import net.ttddyy.dsproxy.listener.SingleQueryCountHolder; -import net.ttddyy.dsproxy.listener.logging.SLF4JLogLevel; -import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder; -import org.apache.commons.dbcp2.BasicDataSource; -import ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect; -import org.hibernate.search.backend.lucene.cfg.LuceneBackendSettings; -import org.hibernate.search.backend.lucene.cfg.LuceneIndexSettings; -import org.hibernate.search.engine.cfg.BackendSettings; -import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Import; -import org.springframework.context.annotation.Lazy; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; - -import javax.sql.DataSource; -import java.util.Properties; -import java.util.concurrent.TimeUnit; - -// TODO KBD Can we remove this Class entirely and just use a Generic one (same for TestJpaR4Config)? -@Import(TestJpaConfig.class) -public class TestJpaDstu3Config extends BaseJavaConfigDstu3 { - private static final Logger ourLog = LoggerFactory.getLogger(TestJpaDstu3Config.class); - @Autowired - FhirContext myFhirContext; - - @Bean - public CircularQueueCaptureQueriesListener captureQueriesListener() { - return new CircularQueueCaptureQueriesListener(); - } - - @Bean - public DataSource dataSource() { - BasicDataSource retVal = new BasicDataSource(); - - retVal.setDriver(new org.h2.Driver()); - retVal.setUrl("jdbc:h2:mem:testdb_dstu3"); - retVal.setMaxWaitMillis(10000); - retVal.setUsername(""); - retVal.setPassword(""); - - SLF4JLogLevel level = SLF4JLogLevel.INFO; - DataSource dataSource = ProxyDataSourceBuilder - .create(retVal) -// .logQueryBySlf4j(level, "SQL") - .logSlowQueryBySlf4j(10, TimeUnit.SECONDS) -// .countQuery(new ThreadQueryCountHolder()) -// .beforeQuery(new BlockLargeNumbersOfParamsListener()) - .afterQuery(captureQueriesListener()) - .afterQuery(new CurrentThreadCaptureQueriesListener()) - .countQuery(singleQueryCountHolder()) - .build(); - - return dataSource; - } - - @Bean - public SingleQueryCountHolder singleQueryCountHolder() { - return new SingleQueryCountHolder(); - } - - @Override - @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory) { - LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory(theConfigurableListableBeanFactory); - retVal.setPersistenceUnitName("PU_HapiFhirJpaDstu3"); - retVal.setDataSource(dataSource()); - retVal.setJpaProperties(jpaProperties()); - return retVal; - } - - @Bean - public Properties jpaProperties() { - Properties extraProperties = new Properties(); - extraProperties.put("hibernate.format_sql", "false"); - extraProperties.put("hibernate.show_sql", "false"); - extraProperties.put("hibernate.hbm2ddl.auto", "update"); - extraProperties.put("hibernate.dialect", HapiFhirH2Dialect.class.getName()); - - extraProperties.put(BackendSettings.backendKey(BackendSettings.TYPE), "lucene"); - extraProperties.put(BackendSettings.backendKey(LuceneBackendSettings.ANALYSIS_CONFIGURER), HapiLuceneAnalysisConfigurer.class.getName()); - extraProperties.put(BackendSettings.backendKey(LuceneIndexSettings.DIRECTORY_TYPE), "local-heap"); - extraProperties.put(BackendSettings.backendKey(LuceneBackendSettings.LUCENE_VERSION), "LUCENE_CURRENT"); - extraProperties.put(HibernateOrmMapperSettings.ENABLED, "true"); - - return extraProperties; - } - - /** - * Bean which validates incoming requests - */ - @Bean - @Lazy - public RequestValidatingInterceptor requestValidatingInterceptor() { - RequestValidatingInterceptor requestValidator = new RequestValidatingInterceptor(); - requestValidator.setFailOnSeverity(ResultSeverityEnum.ERROR); - requestValidator.setAddResponseHeaderOnSeverity(null); - requestValidator.setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum.INFORMATION); - requestValidator.addValidatorModule(instanceValidator()); - - return requestValidator; - } - - - @Bean - public DefaultProfileValidationSupport validationSupportChainDstu3() { - return new DefaultProfileValidationSupport(myFhirContext); - } -} diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/config/TestJpaR4Config.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/config/TestJpaR4Config.java deleted file mode 100644 index 157e9e25326..00000000000 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/config/TestJpaR4Config.java +++ /dev/null @@ -1,147 +0,0 @@ -package ca.uhn.fhir.jpa.config; - -/*- - * #%L - * HAPI FHIR JPA Server Test Utilities - * %% - * Copyright (C) 2014 - 2022 Smile CDR, Inc. - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - -import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.support.DefaultProfileValidationSupport; -import ca.uhn.fhir.jpa.binstore.IBinaryStorageSvc; -import ca.uhn.fhir.jpa.binstore.MemoryBinaryStorageSvcImpl; -import ca.uhn.fhir.jpa.search.HapiLuceneAnalysisConfigurer; -import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener; -import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; -import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; -import ca.uhn.fhir.validation.ResultSeverityEnum; -import net.ttddyy.dsproxy.listener.SingleQueryCountHolder; -import net.ttddyy.dsproxy.listener.logging.SLF4JLogLevel; -import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder; -import org.apache.commons.dbcp2.BasicDataSource; -import ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect; -import org.hibernate.search.backend.lucene.cfg.LuceneBackendSettings; -import org.hibernate.search.backend.lucene.cfg.LuceneIndexSettings; -import org.hibernate.search.engine.cfg.BackendSettings; -import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Import; -import org.springframework.context.annotation.Lazy; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; - -import javax.sql.DataSource; -import java.util.Properties; -import java.util.concurrent.TimeUnit; - -// TODO KBD Can we remove this Class entirely and just use a Generic one (same for TestJpaDstu3Config)? -@Import(TestJpaConfig.class) -public class TestJpaR4Config extends BaseJavaConfigR4 { - private static final Logger ourLog = LoggerFactory.getLogger(TestJpaR4Config.class); - @Autowired - FhirContext myFhirContext; - - @Bean - public CircularQueueCaptureQueriesListener captureQueriesListener() { - return new CircularQueueCaptureQueriesListener(); - } - - @Bean - public DataSource dataSource() { - BasicDataSource retVal = new BasicDataSource(); - - retVal.setDriver(new org.h2.Driver()); - retVal.setUrl("jdbc:h2:mem:testdb_r4"); - retVal.setMaxWaitMillis(10000); - retVal.setUsername(""); - retVal.setPassword(""); - - SLF4JLogLevel level = SLF4JLogLevel.INFO; - DataSource dataSource = ProxyDataSourceBuilder - .create(retVal) -// .logQueryBySlf4j(level, "SQL") - .logSlowQueryBySlf4j(10, TimeUnit.SECONDS) -// .countQuery(new ThreadQueryCountHolder()) -// .beforeQuery(new BlockLargeNumbersOfParamsListener()) - .afterQuery(captureQueriesListener()) - .afterQuery(new CurrentThreadCaptureQueriesListener()) - .countQuery(singleQueryCountHolder()) - .build(); - - return dataSource; - } - - @Bean - public SingleQueryCountHolder singleQueryCountHolder() { - return new SingleQueryCountHolder(); - } - - @Override - @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory) { - LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory(theConfigurableListableBeanFactory); - retVal.setPersistenceUnitName("PU_HapiFhirJpaR4"); - retVal.setDataSource(dataSource()); - retVal.setJpaProperties(jpaProperties()); - return retVal; - } - - @Bean - public Properties jpaProperties() { - Properties extraProperties = new Properties(); - extraProperties.put("hibernate.format_sql", "false"); - extraProperties.put("hibernate.show_sql", "false"); - extraProperties.put("hibernate.hbm2ddl.auto", "update"); - extraProperties.put("hibernate.dialect", HapiFhirH2Dialect.class.getName()); - - extraProperties.put(BackendSettings.backendKey(BackendSettings.TYPE), "lucene"); - extraProperties.put(BackendSettings.backendKey(LuceneBackendSettings.ANALYSIS_CONFIGURER), HapiLuceneAnalysisConfigurer.class.getName()); - extraProperties.put(BackendSettings.backendKey(LuceneIndexSettings.DIRECTORY_TYPE), "local-heap"); - extraProperties.put(BackendSettings.backendKey(LuceneBackendSettings.LUCENE_VERSION), "LUCENE_CURRENT"); - extraProperties.put(HibernateOrmMapperSettings.ENABLED, "true"); - - return extraProperties; - } - - /** - * Bean which validates incoming requests - */ - @Bean - @Lazy - public RequestValidatingInterceptor requestValidatingInterceptor() { - RequestValidatingInterceptor requestValidator = new RequestValidatingInterceptor(); - requestValidator.setFailOnSeverity(ResultSeverityEnum.ERROR); - requestValidator.setAddResponseHeaderOnSeverity(null); - requestValidator.setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum.INFORMATION); - requestValidator.addValidatorModule(instanceValidator()); - - return requestValidator; - } - - @Bean - public IBinaryStorageSvc binaryStorage() { - return new MemoryBinaryStorageSvcImpl(); - } - - @Bean - public DefaultProfileValidationSupport validationSupportChainR4() { - return new DefaultProfileValidationSupport(myFhirContext); - } -} diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaDstu3Test.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaDstu3Test.java deleted file mode 100644 index 8b7258b3293..00000000000 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaDstu3Test.java +++ /dev/null @@ -1,28 +0,0 @@ -package ca.uhn.fhir.jpa.test; - -/*- - * #%L - * HAPI FHIR JPA Server Test Utilities - * %% - * Copyright (C) 2014 - 2022 Smile CDR, Inc. - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - -import ca.uhn.fhir.jpa.config.TestJpaDstu3Config; -import org.springframework.test.context.ContextConfiguration; - -@ContextConfiguration(classes = {TestJpaDstu3Config.class}) -public abstract class BaseJpaDstu3Test extends BaseJpaTest { -} diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaR4Test.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaR4Test.java deleted file mode 100644 index 4e85fbb9d78..00000000000 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaR4Test.java +++ /dev/null @@ -1,28 +0,0 @@ -package ca.uhn.fhir.jpa.test; - -/*- - * #%L - * HAPI FHIR JPA Server Test Utilities - * %% - * Copyright (C) 2014 - 2022 Smile CDR, Inc. - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - -import ca.uhn.fhir.jpa.config.TestJpaR4Config; -import org.springframework.test.context.ContextConfiguration; - -@ContextConfiguration(classes = {TestJpaR4Config.class}) -public abstract class BaseJpaR4Test extends BaseJpaTest { -} diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaTest.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaTest.java deleted file mode 100644 index 5edb82755f4..00000000000 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaTest.java +++ /dev/null @@ -1,107 +0,0 @@ -package ca.uhn.fhir.jpa.test; - -/*- - * #%L - * HAPI FHIR JPA Server Test Utilities - * %% - * Copyright (C) 2014 - 2022 Smile CDR, Inc. - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - -import ca.uhn.fhir.i18n.Msg; -import ca.uhn.fhir.jpa.dao.expunge.ExpungeEverythingService; -import ca.uhn.fhir.jpa.util.MemoryCacheService; -import ca.uhn.fhir.rest.api.Constants; -import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; -import ca.uhn.fhir.test.utilities.UnregisterScheduledProcessor; -import ca.uhn.fhir.util.TestUtil; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.extension.ExtendWith; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.TransactionDefinition; -import org.springframework.transaction.TransactionStatus; -import org.springframework.transaction.support.TransactionCallbackWithoutResult; -import org.springframework.transaction.support.TransactionTemplate; - -import java.io.IOException; -import java.util.concurrent.Callable; - -@TestPropertySource(properties = { - // Since scheduled tasks can cause searches, which messes up the - // value returned by SearchBuilder.getLastHandlerMechanismForUnitTest() - UnregisterScheduledProcessor.SCHEDULING_DISABLED_EQUALS_TRUE -}) -@ExtendWith(SpringExtension.class) -public abstract class BaseJpaTest { - private static final Logger ourLog = LoggerFactory.getLogger(BaseJpaTest.class); - - static { - System.setProperty(Constants.TEST_SYSTEM_PROP_VALIDATION_RESOURCE_CACHES_MS, "1000"); - System.setProperty("test", "true"); - System.setProperty("unit_test_mode", "true"); - TestUtil.setShouldRandomizeTimezones(false); - } - - @Autowired - protected ExpungeEverythingService myExpungeEverythingService; - - @Autowired - PlatformTransactionManager myPlatformTransactionManager; - - @Autowired - ApplicationContext myApplicationContext; - - @Autowired - MemoryCacheService myMemoryCacheService; - - @AfterEach - public void after() throws IOException { - ourLog.info("\n --- @After ---"); - myExpungeEverythingService.expungeEverything(null); - myMemoryCacheService.invalidateAllCaches(); - } - - public TransactionTemplate newTxTemplate() { - TransactionTemplate retVal = new TransactionTemplate(myPlatformTransactionManager); - retVal.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); - retVal.afterPropertiesSet(); - return retVal; - } - - public void runInTransaction(Runnable theRunnable) { - newTxTemplate().execute(new TransactionCallbackWithoutResult() { - @Override - protected void doInTransactionWithoutResult(TransactionStatus theStatus) { - theRunnable.run(); - } - }); - } - - public T runInTransaction(Callable theRunnable) { - return newTxTemplate().execute(t -> { - try { - return theRunnable.call(); - } catch (Exception theE) { - throw new InternalErrorException(Msg.code(72) + theE); - } - }); - } -} diff --git a/hapi-fhir-jpaserver-uhnfhirtest/pom.xml b/hapi-fhir-jpaserver-uhnfhirtest/pom.xml index 06651ae1025..61611c4861e 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/pom.xml +++ b/hapi-fhir-jpaserver-uhnfhirtest/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu2Config.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu2Config.java index 6d64df75098..4f5d2c8a0ec 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu2Config.java +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu2Config.java @@ -1,8 +1,10 @@ package ca.uhn.fhirtest.config; +import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.jpa.api.model.HistoryCountModeEnum; -import ca.uhn.fhir.jpa.config.BaseJavaConfigDstu2; +import ca.uhn.fhir.jpa.config.HapiJpaConfig; +import ca.uhn.fhir.jpa.config.JpaDstu2Config; +import ca.uhn.fhir.jpa.config.util.HapiEntityManagerFactoryUtil; import ca.uhn.fhir.jpa.model.dialect.HapiFhirPostgres94Dialect; import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.jpa.search.HapiLuceneAnalysisConfigurer; @@ -15,12 +17,9 @@ import ca.uhn.fhir.validation.ResultSeverityEnum; import ca.uhn.fhirtest.interceptor.PublicSecurityInterceptor; import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder; import org.apache.commons.dbcp2.BasicDataSource; -import org.apache.commons.lang3.time.DateUtils; -import org.hibernate.dialect.PostgreSQL94Dialect; import org.hibernate.search.backend.lucene.cfg.LuceneBackendSettings; import org.hibernate.search.backend.lucene.cfg.LuceneIndexSettings; import org.hibernate.search.engine.cfg.BackendSettings; -import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings; import org.hl7.fhir.dstu2.model.Subscription; import org.hl7.fhir.r5.utils.validation.constants.ReferenceValidationPolicy; import org.springframework.beans.factory.annotation.Value; @@ -41,9 +40,9 @@ import java.util.Properties; import java.util.concurrent.TimeUnit; @Configuration -@Import(CommonConfig.class) +@Import({CommonConfig.class, JpaDstu2Config.class, HapiJpaConfig.class}) @EnableTransactionManagement() -public class TestDstu2Config extends BaseJavaConfigDstu2 { +public class TestDstu2Config { public static final String FHIR_LUCENE_LOCATION_DSTU2 = "${fhir.lucene.location.dstu2}"; @@ -92,16 +91,15 @@ public class TestDstu2Config extends BaseJavaConfigDstu2 { return daoConfig().getModelConfig(); } - @Override @Bean public ValidationSettings validationSettings() { - ValidationSettings retVal = super.validationSettings(); + ValidationSettings retVal = new ValidationSettings(); retVal.setLocalReferenceValidationDefaultPolicy(ReferenceValidationPolicy.CHECK_VALID); return retVal; } - @Bean(name = "myPersistenceDataSourceDstu1", destroyMethod = "close") + @Bean(name = "myPersistenceDataSourceDstu1") public DataSource dataSource() { BasicDataSource retVal = new BasicDataSource(); if (CommonConfig.isLocalTestMode()) { @@ -134,10 +132,9 @@ public class TestDstu2Config extends BaseJavaConfigDstu2 { return retVal; } - @Override @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory) { - LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory(theConfigurableListableBeanFactory); + public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory, FhirContext theFhirContext) { + LocalContainerEntityManagerFactoryBean retVal = HapiEntityManagerFactoryUtil.newEntityManagerFactory(theConfigurableListableBeanFactory, theFhirContext); retVal.setPersistenceUnitName("PU_HapiFhirJpaDstu2"); retVal.setDataSource(dataSource()); retVal.setJpaProperties(jpaProperties()); @@ -194,7 +191,7 @@ public class TestDstu2Config extends BaseJavaConfigDstu2 { return new PropertySourcesPlaceholderConfigurer(); } -// @Bean(autowire = Autowire.BY_TYPE) +// @Bean // public IServerInterceptor subscriptionSecurityInterceptor() { // return new SubscriptionsRequireManualActivationInterceptorDstu2(); // } diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu3Config.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu3Config.java index 47021e3ec8a..21e07571248 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu3Config.java +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu3Config.java @@ -1,7 +1,10 @@ package ca.uhn.fhirtest.config; +import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.jpa.config.BaseJavaConfigDstu3; +import ca.uhn.fhir.jpa.config.HapiJpaConfig; +import ca.uhn.fhir.jpa.config.dstu3.JpaDstu3Config; +import ca.uhn.fhir.jpa.config.util.HapiEntityManagerFactoryUtil; import ca.uhn.fhir.jpa.model.dialect.HapiFhirPostgres94Dialect; import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; @@ -10,19 +13,16 @@ import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect; import ca.uhn.fhir.jpa.validation.ValidationSettings; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; +import ca.uhn.fhir.validation.IInstanceValidatorModule; import ca.uhn.fhir.validation.ResultSeverityEnum; import ca.uhn.fhirtest.interceptor.PublicSecurityInterceptor; import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder; import org.apache.commons.dbcp2.BasicDataSource; -import org.apache.commons.lang3.time.DateUtils; -import org.hibernate.dialect.PostgreSQL94Dialect; import org.hibernate.search.backend.lucene.cfg.LuceneBackendSettings; import org.hibernate.search.backend.lucene.cfg.LuceneIndexSettings; import org.hibernate.search.engine.cfg.BackendSettings; -import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings; import org.hl7.fhir.dstu2.model.Subscription; import org.hl7.fhir.r5.utils.validation.constants.ReferenceValidationPolicy; -import org.springframework.beans.factory.annotation.Autowire; import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.annotation.Bean; @@ -41,9 +41,9 @@ import java.util.Properties; import java.util.concurrent.TimeUnit; @Configuration -@Import(CommonConfig.class) +@Import({CommonConfig.class, JpaDstu3Config.class, HapiJpaConfig.class}) @EnableTransactionManagement() -public class TestDstu3Config extends BaseJavaConfigDstu3 { +public class TestDstu3Config { public static final String FHIR_DB_USERNAME = "${fhir.db.username}"; public static final String FHIR_DB_PASSWORD = "${fhir.db.password}"; public static final String FHIR_LUCENE_LOCATION_DSTU3 = "${fhir.lucene.location.dstu3}"; @@ -89,21 +89,16 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 { } - @Override @Bean public ValidationSettings validationSettings() { - ValidationSettings retVal = super.validationSettings(); + ValidationSettings retVal = new ValidationSettings(); retVal.setLocalReferenceValidationDefaultPolicy(ReferenceValidationPolicy.CHECK_VALID); return retVal; } - - - - @Override - @Bean(autowire = Autowire.BY_TYPE) + @Bean public DatabaseBackedPagingProvider databaseBackedPagingProvider() { - DatabaseBackedPagingProvider retVal = super.databaseBackedPagingProvider(); + DatabaseBackedPagingProvider retVal = new DatabaseBackedPagingProvider(); retVal.setDefaultPageSize(20); retVal.setMaximumPageSize(500); return retVal; @@ -115,7 +110,7 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 { return new PublicSecurityInterceptor(); } - @Bean(name = "myPersistenceDataSourceDstu3", destroyMethod = "close") + @Bean(name = "myPersistenceDataSourceDstu3") public DataSource dataSource() { BasicDataSource retVal = new BasicDataSource(); if (CommonConfig.isLocalTestMode()) { @@ -140,10 +135,9 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 { return dataSource; } - @Override @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory) { - LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory(theConfigurableListableBeanFactory); + public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory, FhirContext theFhirContext) { + LocalContainerEntityManagerFactoryBean retVal = HapiEntityManagerFactoryUtil.newEntityManagerFactory(theConfigurableListableBeanFactory, theFhirContext); retVal.setPersistenceUnitName("PU_HapiFhirJpaDstu3"); retVal.setDataSource(dataSource()); retVal.setJpaProperties(jpaProperties()); @@ -177,21 +171,22 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 { /** * Bean which validates incoming requests + * @param theFhirInstanceValidator */ @Bean @Lazy - public RequestValidatingInterceptor requestValidatingInterceptor() { + public RequestValidatingInterceptor requestValidatingInterceptor(IInstanceValidatorModule theFhirInstanceValidator) { RequestValidatingInterceptor requestValidator = new RequestValidatingInterceptor(); requestValidator.setFailOnSeverity(null); requestValidator.setAddResponseHeaderOnSeverity(null); requestValidator.setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum.INFORMATION); - requestValidator.addValidatorModule(instanceValidator()); + requestValidator.addValidatorModule(theFhirInstanceValidator); requestValidator.setIgnoreValidatorExceptions(true); return requestValidator; } -// @Bean(autowire = Autowire.BY_TYPE) +// @Bean // public IServerInterceptor subscriptionSecurityInterceptor() { // return new SubscriptionsRequireManualActivationInterceptorDstu3(); // } diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestR4Config.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestR4Config.java index 15099ddb9be..8e30629dc29 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestR4Config.java +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestR4Config.java @@ -1,7 +1,10 @@ package ca.uhn.fhirtest.config; +import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.jpa.config.BaseJavaConfigR4; +import ca.uhn.fhir.jpa.config.HapiJpaConfig; +import ca.uhn.fhir.jpa.config.r4.JpaR4Config; +import ca.uhn.fhir.jpa.config.util.HapiEntityManagerFactoryUtil; import ca.uhn.fhir.jpa.model.dialect.HapiFhirPostgres94Dialect; import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; @@ -10,6 +13,7 @@ import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect; import ca.uhn.fhir.jpa.validation.ValidationSettings; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; +import ca.uhn.fhir.validation.IInstanceValidatorModule; import ca.uhn.fhir.validation.ResultSeverityEnum; import ca.uhn.fhirtest.interceptor.PublicSecurityInterceptor; import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder; @@ -19,7 +23,6 @@ import org.hibernate.search.backend.lucene.cfg.LuceneIndexSettings; import org.hibernate.search.engine.cfg.BackendSettings; import org.hl7.fhir.dstu2.model.Subscription; import org.hl7.fhir.r5.utils.validation.constants.ReferenceValidationPolicy; -import org.springframework.beans.factory.annotation.Autowire; import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.annotation.Bean; @@ -38,9 +41,9 @@ import java.util.Properties; import java.util.concurrent.TimeUnit; @Configuration -@Import(CommonConfig.class) +@Import({CommonConfig.class, JpaR4Config.class, HapiJpaConfig.class}) @EnableTransactionManagement() -public class TestR4Config extends BaseJavaConfigR4 { +public class TestR4Config { public static final String FHIR_DB_USERNAME = "${fhir.db.username}"; public static final String FHIR_DB_PASSWORD = "${fhir.db.password}"; public static final String FHIR_LUCENE_LOCATION_R4 = "${fhir.lucene.location.r4}"; @@ -86,16 +89,15 @@ public class TestR4Config extends BaseJavaConfigR4 { } - @Override @Bean public ValidationSettings validationSettings() { - ValidationSettings retVal = super.validationSettings(); + ValidationSettings retVal = new ValidationSettings(); retVal.setLocalReferenceValidationDefaultPolicy(ReferenceValidationPolicy.CHECK_VALID); return retVal; } - @Bean(name = "myPersistenceDataSourceR4", destroyMethod = "close") + @Bean(name = "myPersistenceDataSourceR4") public DataSource dataSource() { BasicDataSource retVal = new BasicDataSource(); if (CommonConfig.isLocalTestMode()) { @@ -120,19 +122,17 @@ public class TestR4Config extends BaseJavaConfigR4 { return dataSource; } - @Override - @Bean(autowire = Autowire.BY_TYPE) + @Bean public DatabaseBackedPagingProvider databaseBackedPagingProvider() { - DatabaseBackedPagingProvider retVal = super.databaseBackedPagingProvider(); + DatabaseBackedPagingProvider retVal = new DatabaseBackedPagingProvider(); retVal.setDefaultPageSize(20); retVal.setMaximumPageSize(500); return retVal; } - @Override @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory) { - LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory(theConfigurableListableBeanFactory); + public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory, FhirContext theFhirContext) { + LocalContainerEntityManagerFactoryBean retVal = HapiEntityManagerFactoryUtil.newEntityManagerFactory(theConfigurableListableBeanFactory, theFhirContext); retVal.setPersistenceUnitName("PU_HapiFhirJpaR4"); retVal.setDataSource(dataSource()); retVal.setJpaProperties(jpaProperties()); @@ -165,15 +165,16 @@ public class TestR4Config extends BaseJavaConfigR4 { /** * Bean which validates incoming requests + * @param theFhirInstanceValidator */ @Bean @Lazy - public RequestValidatingInterceptor requestValidatingInterceptor() { + public RequestValidatingInterceptor requestValidatingInterceptor(IInstanceValidatorModule theFhirInstanceValidator) { RequestValidatingInterceptor requestValidator = new RequestValidatingInterceptor(); requestValidator.setFailOnSeverity(null); requestValidator.setAddResponseHeaderOnSeverity(null); requestValidator.setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum.INFORMATION); - requestValidator.addValidatorModule(instanceValidator()); + requestValidator.addValidatorModule(theFhirInstanceValidator); requestValidator.setIgnoreValidatorExceptions(true); return requestValidator; diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestR5Config.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestR5Config.java index 108c7f9db2f..9b668d7d0a7 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestR5Config.java +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestR5Config.java @@ -1,7 +1,10 @@ package ca.uhn.fhirtest.config; +import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.jpa.config.BaseJavaConfigR5; +import ca.uhn.fhir.jpa.config.HapiJpaConfig; +import ca.uhn.fhir.jpa.config.r5.JpaR5Config; +import ca.uhn.fhir.jpa.config.util.HapiEntityManagerFactoryUtil; import ca.uhn.fhir.jpa.model.dialect.HapiFhirPostgres94Dialect; import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; @@ -10,19 +13,16 @@ import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect; import ca.uhn.fhir.jpa.validation.ValidationSettings; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; +import ca.uhn.fhir.validation.IInstanceValidatorModule; import ca.uhn.fhir.validation.ResultSeverityEnum; import ca.uhn.fhirtest.interceptor.PublicSecurityInterceptor; import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder; import org.apache.commons.dbcp2.BasicDataSource; -import org.apache.commons.lang3.time.DateUtils; -import org.hibernate.dialect.PostgreSQL94Dialect; import org.hibernate.search.backend.lucene.cfg.LuceneBackendSettings; import org.hibernate.search.backend.lucene.cfg.LuceneIndexSettings; import org.hibernate.search.engine.cfg.BackendSettings; -import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings; import org.hl7.fhir.dstu2.model.Subscription; import org.hl7.fhir.r5.utils.validation.constants.ReferenceValidationPolicy; -import org.springframework.beans.factory.annotation.Autowire; import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.annotation.Bean; @@ -41,9 +41,9 @@ import java.util.Properties; import java.util.concurrent.TimeUnit; @Configuration -@Import(CommonConfig.class) +@Import({CommonConfig.class, JpaR5Config.class, HapiJpaConfig.class}) @EnableTransactionManagement() -public class TestR5Config extends BaseJavaConfigR5 { +public class TestR5Config { public static final String FHIR_DB_USERNAME = "${fhir.db.username}"; public static final String FHIR_DB_PASSWORD = "${fhir.db.password}"; public static final String FHIR_LUCENE_LOCATION_R5 = "${fhir.lucene.location.r5}"; @@ -88,18 +88,14 @@ public class TestR5Config extends BaseJavaConfigR5 { return daoConfig().getModelConfig(); } - @Override @Bean public ValidationSettings validationSettings() { - ValidationSettings retVal = super.validationSettings(); + ValidationSettings retVal = new ValidationSettings(); retVal.setLocalReferenceValidationDefaultPolicy(ReferenceValidationPolicy.CHECK_VALID); return retVal; } - - - - @Bean(name = "myPersistenceDataSourceR5", destroyMethod = "close") + @Bean(name = "myPersistenceDataSourceR5") public DataSource dataSource() { BasicDataSource retVal = new BasicDataSource(); if (CommonConfig.isLocalTestMode()) { @@ -124,19 +120,18 @@ public class TestR5Config extends BaseJavaConfigR5 { return dataSource; } - @Override - @Bean(autowire = Autowire.BY_TYPE) + // TODO KHS there is code duplication between this and the other Test*Config classes in this directory + @Bean public DatabaseBackedPagingProvider databaseBackedPagingProvider() { - DatabaseBackedPagingProvider retVal = super.databaseBackedPagingProvider(); + DatabaseBackedPagingProvider retVal = new DatabaseBackedPagingProvider(); retVal.setDefaultPageSize(20); retVal.setMaximumPageSize(500); return retVal; } - @Override @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory) { - LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory(theConfigurableListableBeanFactory); + public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory, FhirContext theFhirContext) { + LocalContainerEntityManagerFactoryBean retVal = HapiEntityManagerFactoryUtil.newEntityManagerFactory(theConfigurableListableBeanFactory, theFhirContext); retVal.setPersistenceUnitName("PU_HapiFhirJpaR5"); retVal.setDataSource(dataSource()); retVal.setJpaProperties(jpaProperties()); @@ -170,15 +165,16 @@ public class TestR5Config extends BaseJavaConfigR5 { /** * Bean which validates incoming requests + * @param theFhirInstanceValidator */ @Bean @Lazy - public RequestValidatingInterceptor requestValidatingInterceptor() { + public RequestValidatingInterceptor requestValidatingInterceptor(IInstanceValidatorModule theFhirInstanceValidator) { RequestValidatingInterceptor requestValidator = new RequestValidatingInterceptor(); requestValidator.setFailOnSeverity(null); requestValidator.setAddResponseHeaderOnSeverity(null); requestValidator.setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum.INFORMATION); - requestValidator.addValidatorModule(instanceValidator()); + requestValidator.addValidatorModule(theFhirInstanceValidator); requestValidator.setIgnoreValidatorExceptions(true); return requestValidator; diff --git a/hapi-fhir-server-mdm/pom.xml b/hapi-fhir-server-mdm/pom.xml index 64de30d51fd..60e44245165 100644 --- a/hapi-fhir-server-mdm/pom.xml +++ b/hapi-fhir-server-mdm/pom.xml @@ -7,7 +7,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-server-openapi/pom.xml b/hapi-fhir-server-openapi/pom.xml index 06330c2e62f..6f0c78e37cd 100644 --- a/hapi-fhir-server-openapi/pom.xml +++ b/hapi-fhir-server-openapi/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-server/pom.xml b/hapi-fhir-server/pom.xml index 572bf89e269..fa95437810b 100644 --- a/hapi-fhir-server/pom.xml +++ b/hapi-fhir-server/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml index 50f10597922..e651598d19c 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/src/main/java/ca/uhn/fhir/spring/boot/autoconfigure/FhirAutoConfiguration.java b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/src/main/java/ca/uhn/fhir/spring/boot/autoconfigure/FhirAutoConfiguration.java index 00377061726..e6e57cfae8b 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/src/main/java/ca/uhn/fhir/spring/boot/autoconfigure/FhirAutoConfiguration.java +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/src/main/java/ca/uhn/fhir/spring/boot/autoconfigure/FhirAutoConfiguration.java @@ -24,9 +24,10 @@ package ca.uhn.fhir.spring.boot.autoconfigure; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jaxrs.server.AbstractJaxRsProvider; import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.jpa.config.BaseJavaConfigDstu2; -import ca.uhn.fhir.jpa.config.BaseJavaConfigDstu3; -import ca.uhn.fhir.jpa.config.BaseJavaConfigR4; +import ca.uhn.fhir.jpa.config.HapiJpaConfig; +import ca.uhn.fhir.jpa.config.JpaDstu2Config; +import ca.uhn.fhir.jpa.config.dstu3.JpaDstu3Config; +import ca.uhn.fhir.jpa.config.r4.JpaR4Config; import ca.uhn.fhir.jpa.model.config.PartitionSettings; import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.jpa.provider.BaseJpaProvider; @@ -234,21 +235,24 @@ public class FhirAutoConfiguration { } @Configuration - @ConditionalOnMissingBean(type = "ca.uhn.fhir.jpa.config.BaseConfig") + @Import({JpaDstu3Config.class, HapiJpaConfig.class}) + @ConditionalOnMissingBean(type = "ca.uhn.fhir.jpa.config.JpaConfig") @ConditionalOnProperty(name = "hapi.fhir.version", havingValue = "DSTU3") - static class Dstu3 extends BaseJavaConfigDstu3 { + static class Dstu3 { } @Configuration - @ConditionalOnMissingBean(type = "ca.uhn.fhir.jpa.config.BaseConfig") + @Import({JpaDstu2Config.class, HapiJpaConfig.class}) + @ConditionalOnMissingBean(type = "ca.uhn.fhir.jpa.config.JpaConfig") @ConditionalOnProperty(name = "hapi.fhir.version", havingValue = "DSTU2") - static class Dstu2 extends BaseJavaConfigDstu2 { + static class Dstu2 { } @Configuration - @ConditionalOnMissingBean(type = "ca.uhn.fhir.jpa.config.BaseConfig") + @Import({JpaR4Config.class, HapiJpaConfig.class}) + @ConditionalOnMissingBean(type = "ca.uhn.fhir.jpa.config.JpaConfig") @ConditionalOnProperty(name = "hapi.fhir.version", havingValue = "R4") - static class R4 extends BaseJavaConfigR4 { + static class R4 { } } diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml index 5f3cd6127bc..07b59506d5e 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot-samples - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT hapi-fhir-spring-boot-sample-client-apache diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml index 693997f1ffd..95a6d61f3ea 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot-samples - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT hapi-fhir-spring-boot-sample-client-okhttp diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml index 211aea0f8fd..e09180fabf5 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot-samples - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT hapi-fhir-spring-boot-sample-server-jersey diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml index 2e5872c9ef2..a914aa5d018 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT hapi-fhir-spring-boot-samples diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml index cdd2978703a..fad089f1a84 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-spring-boot/pom.xml b/hapi-fhir-spring-boot/pom.xml index 83bf2e8fab0..5f63c576501 100644 --- a/hapi-fhir-spring-boot/pom.xml +++ b/hapi-fhir-spring-boot/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-sql-migrate/pom.xml b/hapi-fhir-sql-migrate/pom.xml index e38d63cad64..a9bb5384537 100644 --- a/hapi-fhir-sql-migrate/pom.xml +++ b/hapi-fhir-sql-migrate/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage/pom.xml b/hapi-fhir-storage/pom.xml index 881d45e64ba..3ad0f1b848e 100644 --- a/hapi-fhir-storage/pom.xml +++ b/hapi-fhir-storage/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/provider/DaoRegistryResourceSupportedSvc.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/provider/DaoRegistryResourceSupportedSvc.java new file mode 100644 index 00000000000..8208e9d69bb --- /dev/null +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/provider/DaoRegistryResourceSupportedSvc.java @@ -0,0 +1,17 @@ +package ca.uhn.fhir.jpa.provider; + +import ca.uhn.fhir.jpa.api.IDaoRegistry; +import ca.uhn.fhir.rest.api.IResourceSupportedSvc; + +public class DaoRegistryResourceSupportedSvc implements IResourceSupportedSvc { + private final IDaoRegistry myDaoRegistry; + + public DaoRegistryResourceSupportedSvc(IDaoRegistry theDaoRegistry) { + myDaoRegistry = theDaoRegistry; + } + + @Override + public boolean isSupported(String theResourceName) { + return myDaoRegistry.isResourceTypeSupported(theResourceName); + } +} diff --git a/hapi-fhir-structures-dstu2.1/pom.xml b/hapi-fhir-structures-dstu2.1/pom.xml index dc168caf90e..490dfc111b0 100644 --- a/hapi-fhir-structures-dstu2.1/pom.xml +++ b/hapi-fhir-structures-dstu2.1/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-dstu2/pom.xml b/hapi-fhir-structures-dstu2/pom.xml index e71e4a560e5..0ab1a987666 100644 --- a/hapi-fhir-structures-dstu2/pom.xml +++ b/hapi-fhir-structures-dstu2/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-dstu3/pom.xml b/hapi-fhir-structures-dstu3/pom.xml index 9b40427a8c5..09371232551 100644 --- a/hapi-fhir-structures-dstu3/pom.xml +++ b/hapi-fhir-structures-dstu3/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-hl7org-dstu2/pom.xml b/hapi-fhir-structures-hl7org-dstu2/pom.xml index 8d0640f630b..ae1cde25b24 100644 --- a/hapi-fhir-structures-hl7org-dstu2/pom.xml +++ b/hapi-fhir-structures-hl7org-dstu2/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-r4/pom.xml b/hapi-fhir-structures-r4/pom.xml index 09dbde43929..f23e56a9a29 100644 --- a/hapi-fhir-structures-r4/pom.xml +++ b/hapi-fhir-structures-r4/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-r5/pom.xml b/hapi-fhir-structures-r5/pom.xml index d6ea85eec2d..e7cb026ad63 100644 --- a/hapi-fhir-structures-r5/pom.xml +++ b/hapi-fhir-structures-r5/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-test-utilities/pom.xml b/hapi-fhir-test-utilities/pom.xml index 4e1cafe5e45..046c2022f85 100644 --- a/hapi-fhir-test-utilities/pom.xml +++ b/hapi-fhir-test-utilities/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-testpage-overlay/pom.xml b/hapi-fhir-testpage-overlay/pom.xml index 703e7f5f7e4..a4a3e61b2e8 100644 --- a/hapi-fhir-testpage-overlay/pom.xml +++ b/hapi-fhir-testpage-overlay/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-validation-resources-dstu2.1/pom.xml b/hapi-fhir-validation-resources-dstu2.1/pom.xml index 9408b7603a8..64259f40eb8 100644 --- a/hapi-fhir-validation-resources-dstu2.1/pom.xml +++ b/hapi-fhir-validation-resources-dstu2.1/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-dstu2/pom.xml b/hapi-fhir-validation-resources-dstu2/pom.xml index 59d09106547..6dd93e36f45 100644 --- a/hapi-fhir-validation-resources-dstu2/pom.xml +++ b/hapi-fhir-validation-resources-dstu2/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-dstu3/pom.xml b/hapi-fhir-validation-resources-dstu3/pom.xml index ee9a1a63155..86a5818a52d 100644 --- a/hapi-fhir-validation-resources-dstu3/pom.xml +++ b/hapi-fhir-validation-resources-dstu3/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-r4/pom.xml b/hapi-fhir-validation-resources-r4/pom.xml index 261ef4de0e9..7fef8523c67 100644 --- a/hapi-fhir-validation-resources-r4/pom.xml +++ b/hapi-fhir-validation-resources-r4/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-r5/pom.xml b/hapi-fhir-validation-resources-r5/pom.xml index 084d2c8299d..656e66392f3 100644 --- a/hapi-fhir-validation-resources-r5/pom.xml +++ b/hapi-fhir-validation-resources-r5/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation/pom.xml b/hapi-fhir-validation/pom.xml index a0229aaa4f7..892ea91532a 100644 --- a/hapi-fhir-validation/pom.xml +++ b/hapi-fhir-validation/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-tinder-plugin/pom.xml b/hapi-tinder-plugin/pom.xml index 0e50f90e848..32b2df08885 100644 --- a/hapi-tinder-plugin/pom.xml +++ b/hapi-tinder-plugin/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../pom.xml @@ -58,37 +58,37 @@ ca.uhn.hapi.fhir hapi-fhir-structures-dstu3 - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ca.uhn.hapi.fhir hapi-fhir-structures-hl7org-dstu2 - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ca.uhn.hapi.fhir hapi-fhir-structures-r4 - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ca.uhn.hapi.fhir hapi-fhir-structures-r5 - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ca.uhn.hapi.fhir hapi-fhir-validation-resources-dstu2 - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ca.uhn.hapi.fhir hapi-fhir-validation-resources-dstu3 - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ca.uhn.hapi.fhir hapi-fhir-validation-resources-r4 - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT org.apache.velocity diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderJpaRestServerMojo.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderJpaRestServerMojo.java index bc02054077f..cd961853a69 100644 --- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderJpaRestServerMojo.java +++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderJpaRestServerMojo.java @@ -1,8 +1,8 @@ package ca.uhn.fhir.tinder; -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.tinder.parser.BaseStructureSpreadsheetParser; import ca.uhn.fhir.tinder.parser.ResourceGeneratorUsingModel; import ca.uhn.fhir.tinder.parser.ResourceGeneratorUsingSpreadsheet; @@ -201,7 +201,7 @@ public class TinderJpaRestServerMojo extends AbstractMojo { */ templateIs = ResourceGeneratorUsingSpreadsheet.class.getResourceAsStream("/vm/jpa_spring_beans_java.vm"); templateReader = new InputStreamReader(templateIs); - f = new File(configPackageDirectoryBase, "BaseJavaConfig" + capitalize + ".java"); + f = new File(configPackageDirectoryBase, "GeneratedDaoAndResourceProviderConfig" + capitalize + ".java"); w = new OutputStreamWriter(new FileOutputStream(f, false), "UTF-8"); v.evaluate(ctx, w, "", templateReader); w.close(); diff --git a/hapi-tinder-plugin/src/main/resources/vm/jpa_spring_beans_java.vm b/hapi-tinder-plugin/src/main/resources/vm/jpa_spring_beans_java.vm index 4a2b7483772..a38d63aa868 100644 --- a/hapi-tinder-plugin/src/main/resources/vm/jpa_spring_beans_java.vm +++ b/hapi-tinder-plugin/src/main/resources/vm/jpa_spring_beans_java.vm @@ -9,7 +9,7 @@ import javax.persistence.EntityManager; import org.springframework.transaction.PlatformTransactionManager; import ca.uhn.fhir.jpa.api.config.DaoConfig; -import org.springframework.beans.factory.annotation.Autowire; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Lazy; @@ -18,6 +18,7 @@ import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.SchedulingConfigurer; import org.springframework.scheduling.config.ScheduledTaskRegistrar; +import ca.uhn.fhir.rest.api.IResourceSupportedSvc; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.rest.server.IResourceProvider; @@ -26,23 +27,25 @@ import ca.uhn.fhir.jpa.dao.*; import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory; @Configuration -public abstract class BaseJavaConfig${versionCapitalized} extends ca.uhn.fhir.jpa.config${package_suffix}.Base${versionCapitalized}Config { +public class GeneratedDaoAndResourceProviderConfig${versionCapitalized} { +@Autowired +FhirContext myFhirContext; @Bean(name="myResourceProviders${versionCapitalized}") - public ResourceProviderFactory resourceProviders${versionCapitalized}() { + public ResourceProviderFactory resourceProviders${versionCapitalized}(IResourceSupportedSvc theResourceSupportedSvc) { ResourceProviderFactory retVal = new ResourceProviderFactory(); #foreach ( $res in $resources ) - retVal.addSupplier(() -> isSupported("${res.name}") ? rp${res.declaringClassNameComplete}${versionCapitalized}() : null); + retVal.addSupplier(() -> theResourceSupportedSvc.isSupported("${res.name}") ? rp${res.declaringClassNameComplete}${versionCapitalized}() : null); #end return retVal; } @Bean(name="myResourceDaos${versionCapitalized}") - public List> resourceDaos${versionCapitalized}() { + public List> resourceDaos${versionCapitalized}(IResourceSupportedSvc theResourceSupportedSvc) { List> retVal = new ArrayList>(); #foreach ( $res in $resources ) - if (isSupported("${res.name}")) { + if (theResourceSupportedSvc.isSupported("${res.name}")) { retVal.add(dao${res.declaringClassNameComplete}${versionCapitalized}()); } #end @@ -50,7 +53,7 @@ public abstract class BaseJavaConfig${versionCapitalized} extends ca.uhn.fhir.jp } #foreach ( $res in $resources ) - @Bean(name="my${res.name}Dao${versionCapitalized}", autowire=Autowire.BY_NAME) + @Bean(name="my${res.name}Dao${versionCapitalized}") public #if ( ${versionCapitalized} == 'Dstu2' && ${res.name} == 'ValueSet' ) IFhirResourceDaoValueSet @@ -92,7 +95,7 @@ public abstract class BaseJavaConfig${versionCapitalized} extends ca.uhn.fhir.jp retVal = new ca.uhn.fhir.jpa.dao.JpaResourceDao<${resourcePackage}.${res.declaringClassNameComplete}>(); #end retVal.setResourceType(${resourcePackage}.${res.declaringClassNameComplete}.class); - retVal.setContext(fhirContext${versionCapitalized}()); + retVal.setContext(myFhirContext); return retVal; } @@ -101,7 +104,7 @@ public abstract class BaseJavaConfig${versionCapitalized} extends ca.uhn.fhir.jp public ca.uhn.fhir.jpa.rp.${version}.${res.declaringClassNameComplete}ResourceProvider rp${res.declaringClassNameComplete}${versionCapitalized}() { ca.uhn.fhir.jpa.rp.${version}.${res.declaringClassNameComplete}ResourceProvider retVal; retVal = new ca.uhn.fhir.jpa.rp.${version}.${res.declaringClassNameComplete}ResourceProvider(); - retVal.setContext(fhirContext${versionCapitalized}()); + retVal.setContext(myFhirContext); retVal.setDao(dao${res.declaringClassNameComplete}${versionCapitalized}()); return retVal; } diff --git a/hapi-tinder-test/pom.xml b/hapi-tinder-test/pom.xml index 15c667c9414..bccfade0fff 100644 --- a/hapi-tinder-test/pom.xml +++ b/hapi-tinder-test/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../pom.xml diff --git a/pom.xml b/pom.xml index 2fe6df309b1..423bce1d3ac 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-fhir pom - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT HAPI-FHIR An open-source implementation of the FHIR specification in Java. https://hapifhir.io @@ -2010,7 +2010,7 @@ ca.uhn.hapi.fhir hapi-fhir-checkstyle - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT diff --git a/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml b/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml index 550d6f26cd3..15d7ee95908 100644 --- a/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml +++ b/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../../pom.xml diff --git a/tests/hapi-fhir-base-test-mindeps-client/pom.xml b/tests/hapi-fhir-base-test-mindeps-client/pom.xml index 85e369a4607..97717318de2 100644 --- a/tests/hapi-fhir-base-test-mindeps-client/pom.xml +++ b/tests/hapi-fhir-base-test-mindeps-client/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../../pom.xml diff --git a/tests/hapi-fhir-base-test-mindeps-server/pom.xml b/tests/hapi-fhir-base-test-mindeps-server/pom.xml index 6f7dd96ae9d..d5b0bd2668f 100644 --- a/tests/hapi-fhir-base-test-mindeps-server/pom.xml +++ b/tests/hapi-fhir-base-test-mindeps-server/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.0.0-PRE2-SNAPSHOT + 6.0.0-PRE3-SNAPSHOT ../../pom.xml