From eee7d7e455d02b0770edde4297438e408d611da6 Mon Sep 17 00:00:00 2001 From: Ken Stevens Date: Sun, 12 Sep 2021 23:09:18 -0400 Subject: [PATCH] code cleanup (#2986) * failed attempt to get it to work * Use simplified FhirContext.forCached methods * Update hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java Co-authored-by: James Agnew Co-authored-by: James Agnew --- .../java/ca/uhn/fhir/context/FhirContext.java | 8 ++++ .../jpa/batch/job/model/PartitionedUrl.java | 4 ++ .../jpa/bulk/BulkDataExportProviderTest.java | 14 +++---- .../jpa/dao/TolerantJsonParserR4Test.java | 5 +-- .../jpa/dao/TransactionProcessorTest.java | 3 +- .../FhirResourceDaoSearchParameterR4Test.java | 3 +- ...bservationIndexedSearchParamLastNR4IT.java | 29 ++++++++++---- .../dao/r4/SearchParamExtractorR4Test.java | 5 +-- .../jpa/dao/r4/SearchParameterMapTest.java | 3 +- .../ca/uhn/fhir/jpa/packages/NpmR4Test.java | 2 +- .../packages/PackageInstallerSvcImplTest.java | 3 +- .../PartitionManagementProviderTest.java | 3 +- .../fhir/jpa/patch/FhirPatchApplyR4Test.java | 3 +- .../uhn/fhir/jpa/patch/FhirPatchCoreTest.java | 5 +-- .../fhir/jpa/patch/FhirPatchDiffR4Test.java | 3 +- .../provider/JpaGraphQLR4ProviderTest.java | 7 +--- .../jpa/provider/SearchParameterMapTest.java | 27 ++++++++----- .../jpa/provider/SystemProviderDstu2Test.java | 36 ++++++++++------- ...temProviderTransactionSearchDstu2Test.java | 3 +- .../TerminologyUploaderProviderTest.java | 9 ++--- .../ResourceProviderDstu3CodeSystemTest.java | 14 +++++-- ...temProviderTransactionSearchDstu3Test.java | 6 +-- .../jpa/provider/r4/EmptyIndexesR4Test.java | 6 +-- .../jpa/provider/r4/SystemProviderR4Test.java | 3 +- ...SystemProviderTransactionSearchR4Test.java | 14 +++---- .../search/SearchCoordinatorSvcImplTest.java | 13 +++--- .../builder/sql/SearchQueryBuilderTest.java | 3 +- ...lasticsearchSvcMultipleObservationsIT.java | 3 +- ...tNElasticsearchSvcSingleObservationIT.java | 9 +---- .../ResourceReindexingSvcImplTest.java | 3 +- .../jpa/searchparam/MatchUrlServiceTest.java | 5 +-- .../stresstest/GiantTransactionPerfTest.java | 3 +- .../jpa/stresstest/StressTestParserTest.java | 4 +- .../subscription/BaseSubscriptionsR5Test.java | 3 +- .../jpa/subscription/FhirServiceUtil.java | 8 ++-- ...SubscriptionValidatingInterceptorTest.java | 3 +- ...tivatesPreExistingSubscriptionsR4Test.java | 3 +- .../resthook/RestHookTestDstu2Test.java | 21 ++++++---- .../resthook/RestHookTestDstu3Test.java | 40 ++++++++++++++----- ...rceptorRegisteredToDaoConfigDstu2Test.java | 7 ++-- ...rceptorRegisteredToDaoConfigDstu3Test.java | 7 ++-- ...nterceptorRegisteredToDaoConfigR4Test.java | 25 +++++++----- .../RestHookWithInterceptorR4Test.java | 5 +-- .../SubscriptionTriggeringDstu3Test.java | 15 ++++--- .../term/TerminologyLoaderSvcLoincTest.java | 7 ++-- .../util/jsonpatch/JsonPatchUtilsTest.java | 6 +-- .../fhir/validator/AttachmentUtilTest.java | 7 ++-- .../ValidatorAcrossVersionsTest.java | 17 ++++---- .../SearchParamExtractorDstu3Test.java | 3 +- .../rest/openapi/OpenApiInterceptorTest.java | 3 +- ...eptorWithAuthorizationInterceptorTest.java | 40 +------------------ ...mThymeleafNarrativeGeneratorDstu2Test.java | 3 +- ...tThymeleafNarrativeGeneratorDstu2Test.java | 3 +- ...tThymeleafNarrativeGeneratorDstu3Test.java | 17 ++++++-- ...stomThymeleafNarrativeGeneratorR4Test.java | 5 +-- ...aultThymeleafNarrativeGeneratorR4Test.java | 19 +++++++-- .../CapabilityStatementCacheR4Test.java | 3 +- ...apabilityStatementCustomizationR4Test.java | 3 +- .../ca/uhn/fhir/rest/server/ReadR4Test.java | 3 +- .../SearchPreferHandlingInterceptorTest.java | 3 +- .../ca/uhn/fhir/rest/server/SearchR4Test.java | 8 +--- .../server/ServerInvalidDefinitionR4Test.java | 15 +------ .../ca/uhn/fhir/util/FhirTerserR4Test.java | 3 +- ...rverCapabilityStatementProviderR5Test.java | 33 ++++++++++++--- ...oryTerminologyServerValidationSupport.java | 6 +-- ...rverCapabilityStatementProviderR4Test.java | 3 +- ...ologyDisplayPopulationInterceptorTest.java | 3 +- ...mmonCodeSystemsTerminologyServiceTest.java | 7 ++-- 68 files changed, 305 insertions(+), 313 deletions(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java index 168a6995b65..73970ce82fe 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java @@ -225,6 +225,14 @@ public class FhirContext { } + + /** + * @since 5.6.0 + */ + public static FhirContext forDstu2Cached() { + return forCached(FhirVersionEnum.DSTU2); + } + /** * @since 5.5.0 */ diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch/job/model/PartitionedUrl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch/job/model/PartitionedUrl.java index ebc69de9d18..cb3240a203e 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch/job/model/PartitionedUrl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch/job/model/PartitionedUrl.java @@ -54,4 +54,8 @@ public class PartitionedUrl implements IModelJson { public void setRequestPartitionId(RequestPartitionId theRequestPartitionId) { myRequestPartitionId = theRequestPartitionId; } + + public boolean isPartitioned() { + return myRequestPartitionId != null && !myRequestPartitionId.isDefaultPartition(); + } } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportProviderTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportProviderTest.java index e2ca669a6dd..0783f3cb387 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportProviderTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportProviderTest.java @@ -1,16 +1,15 @@ package ca.uhn.fhir.jpa.bulk; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster; -import ca.uhn.fhir.rest.api.server.bulk.BulkDataExportOptions; import ca.uhn.fhir.jpa.bulk.export.api.IBulkDataExportSvc; -import ca.uhn.fhir.jpa.bulk.export.model.BulkExportResponseJson; import ca.uhn.fhir.jpa.bulk.export.model.BulkExportJobStatusEnum; +import ca.uhn.fhir.jpa.bulk.export.model.BulkExportResponseJson; import ca.uhn.fhir.jpa.bulk.export.provider.BulkDataExportProvider; import ca.uhn.fhir.jpa.model.util.JpaConstants; import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.server.RequestDetails; +import ca.uhn.fhir.rest.api.server.bulk.BulkDataExportOptions; import ca.uhn.fhir.rest.client.apache.ResourceEntity; import ca.uhn.fhir.rest.server.RestfulServer; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; @@ -55,11 +54,8 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.times; @@ -74,7 +70,7 @@ public class BulkDataExportProviderTest { private static final String GROUP_ID = "Group/G2401"; private static final String G_JOB_ID = "0000000-GGGGGG"; private Server myServer; - private final FhirContext myCtx = FhirContext.forCached(FhirVersionEnum.R4); + private final FhirContext myCtx = FhirContext.forR4Cached(); private int myPort; @Mock private IBulkDataExportSvc myBulkDataExportSvc; @@ -478,9 +474,9 @@ public class BulkDataExportProviderTest { when(myBulkDataExportSvc.submitJob(any(), any(), nullable(RequestDetails.class))).thenReturn(jobInfo); String url = "http://localhost:" + myPort + "/" + "Group/123/" +JpaConstants.OPERATION_EXPORT - + "?" + JpaConstants.PARAM_EXPORT_OUTPUT_FORMAT + "=" + UrlUtil.escapeUrlParam(Constants.CT_FHIR_NDJSON);; + + "?" + JpaConstants.PARAM_EXPORT_OUTPUT_FORMAT + "=" + UrlUtil.escapeUrlParam(Constants.CT_FHIR_NDJSON); - HttpGet get = new HttpGet(url); + HttpGet get = new HttpGet(url); get.addHeader(Constants.HEADER_PREFER, Constants.HEADER_PREFER_RESPOND_ASYNC); CloseableHttpResponse execute = myClient.execute(get); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/TolerantJsonParserR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/TolerantJsonParserR4Test.java index 7222ce7f83a..e4079c42903 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/TolerantJsonParserR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/TolerantJsonParserR4Test.java @@ -1,19 +1,18 @@ package ca.uhn.fhir.jpa.dao; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.parser.DataFormatException; import ca.uhn.fhir.parser.LenientErrorHandler; import org.hl7.fhir.r4.model.Observation; import org.junit.jupiter.api.Test; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.hamcrest.MatcherAssert.assertThat; public class TolerantJsonParserR4Test { - private FhirContext myFhirContext = FhirContext.forCached(FhirVersionEnum.R4); + private final FhirContext myFhirContext = FhirContext.forR4Cached(); @Test public void testParseInvalidNumeric_LeadingDecimal() { diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/TransactionProcessorTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/TransactionProcessorTest.java index cff84d93d99..f48b4ede91f 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/TransactionProcessorTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/TransactionProcessorTest.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.dao; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.interceptor.executor.InterceptorService; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; @@ -123,7 +122,7 @@ public class TransactionProcessorTest { @Bean public FhirContext fhirContext() { - return FhirContext.forCached(FhirVersionEnum.R4); + return FhirContext.forR4Cached(); } @Bean diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoSearchParameterR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoSearchParameterR4Test.java index 78eb2ec76e4..b9ab285fa69 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoSearchParameterR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoSearchParameterR4Test.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.dao.r4; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.context.RuntimeSearchParam; import ca.uhn.fhir.jpa.api.config.DaoConfig; @@ -32,7 +31,7 @@ public class FhirResourceDaoSearchParameterR4Test { @BeforeEach public void before() { - myCtx = FhirContext.forCached(FhirVersionEnum.R4); + myCtx = FhirContext.forR4Cached(); myDao = new FhirResourceDaoSearchParameterR4(); myDao.setContext(myCtx); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/PersistObservationIndexedSearchParamLastNR4IT.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/PersistObservationIndexedSearchParamLastNR4IT.java index bd686231e0c..cbd54dca482 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/PersistObservationIndexedSearchParamLastNR4IT.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/PersistObservationIndexedSearchParamLastNR4IT.java @@ -1,24 +1,33 @@ 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.api.dao.IFhirSystemDao; import ca.uhn.fhir.jpa.config.TestR4ConfigWithElasticsearchClient; import ca.uhn.fhir.jpa.dao.ObservationLastNIndexPersistSvc; import ca.uhn.fhir.jpa.model.entity.ResourceTable; -import ca.uhn.fhir.jpa.model.util.CodeSystemHash; import ca.uhn.fhir.jpa.search.lastn.ElasticsearchSvcImpl; import ca.uhn.fhir.jpa.search.lastn.json.CodeJson; import ca.uhn.fhir.jpa.search.lastn.json.ObservationJson; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.parser.IParser; -import ca.uhn.fhir.rest.param.*; +import ca.uhn.fhir.rest.param.ReferenceAndListParam; +import ca.uhn.fhir.rest.param.ReferenceOrListParam; +import ca.uhn.fhir.rest.param.ReferenceParam; +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.test.utilities.docker.RequiresDocker; import com.google.common.base.Charsets; import org.apache.commons.io.IOUtils; -import org.aspectj.lang.annotation.Before; -import org.hl7.fhir.r4.model.*; +import org.hl7.fhir.r4.model.Bundle; +import org.hl7.fhir.r4.model.CodeableConcept; +import org.hl7.fhir.r4.model.Coding; +import org.hl7.fhir.r4.model.DateTimeType; +import org.hl7.fhir.r4.model.IdType; +import org.hl7.fhir.r4.model.Meta; +import org.hl7.fhir.r4.model.Observation; +import org.hl7.fhir.r4.model.Reference; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.MethodOrderer; @@ -31,14 +40,18 @@ import org.springframework.core.io.Resource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.PersistenceContextType; import java.io.IOException; import java.io.InputStream; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -411,7 +424,7 @@ public class PersistObservationIndexedSearchParamLastNR4IT { @Order(1) @Test public void testSampleBundleInTransaction() throws IOException { - FhirContext myFhirCtx = FhirContext.forCached(FhirVersionEnum.R4); + FhirContext myFhirCtx = FhirContext.forR4Cached(); PathMatchingResourcePatternResolver provider = new PathMatchingResourcePatternResolver(); final Resource[] bundleResources; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/SearchParamExtractorR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/SearchParamExtractorR4Test.java index 8dfe6e4a1c7..0481f0b3de3 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/SearchParamExtractorR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/SearchParamExtractorR4Test.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.dao.r4; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.context.RuntimeSearchParam; import ca.uhn.fhir.context.phonetic.IPhoneticEncoder; @@ -61,7 +60,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; public class SearchParamExtractorR4Test { private static final Logger ourLog = LoggerFactory.getLogger(SearchParamExtractorR4Test.class); - private static FhirContext ourCtx = FhirContext.forCached(FhirVersionEnum.R4); + private static final FhirContext ourCtx = FhirContext.forR4Cached(); private MySearchParamRegistry mySearchParamRegistry; private PartitionSettings myPartitionSettings; @@ -398,7 +397,7 @@ public class SearchParamExtractorR4Test { private static class MySearchParamRegistry implements ISearchParamRegistry, ISearchParamRegistryController { - private List myExtraSearchParams = new ArrayList<>(); + private final List myExtraSearchParams = new ArrayList<>(); @Override public void forceRefresh() { diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/SearchParameterMapTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/SearchParameterMapTest.java index fcb37e54fe9..090e693af20 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/SearchParameterMapTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/SearchParameterMapTest.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.dao.r4; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.rest.param.HasParam; import ca.uhn.fhir.test.BaseTest; @@ -11,7 +10,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class SearchParameterMapTest extends BaseTest { - private FhirContext myContext = FhirContext.forCached(FhirVersionEnum.R4); + private final FhirContext myContext = FhirContext.forR4Cached(); @Test public void toNormalizedQueryStringTest() { 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 13cfb4cd620..ed387fed101 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 @@ -185,7 +185,7 @@ public class NpmR4Test extends BaseJpaR4Test { assertEquals("Nictiz NL package of FHIR STU3 conformance resources for MedMij information standard Questionnaires. Includes dependency on Zib2017 and SDC.\\n\\nHCIMs: https://zibs.nl/wiki/HCIM_Release_2017(EN)", pkg.description()); // Fetch resource by URL - FhirContext fhirContext = FhirContext.forCached(FhirVersionEnum.DSTU3); + FhirContext fhirContext = FhirContext.forDstu3Cached(); runInTransaction(() -> { IBaseResource asset = myPackageCacheManager.loadPackageAssetByUrl(FhirVersionEnum.DSTU3, "http://nictiz.nl/fhir/StructureDefinition/vl-QuestionnaireResponse"); assertThat(fhirContext.newJsonParser().encodeResourceToString(asset), containsString("\"url\":\"http://nictiz.nl/fhir/StructureDefinition/vl-QuestionnaireResponse\",\"version\":\"1.0.1\"")); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/packages/PackageInstallerSvcImplTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/packages/PackageInstallerSvcImplTest.java index 2ac98743ab0..93e4e690b5d 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/packages/PackageInstallerSvcImplTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/packages/PackageInstallerSvcImplTest.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.packages; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import org.hl7.fhir.r4.model.Enumerations; import org.hl7.fhir.r4.model.SearchParameter; import org.junit.jupiter.api.BeforeEach; @@ -11,7 +10,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; class PackageInstallerSvcImplTest { - private final FhirContext myCtx = FhirContext.forCached(FhirVersionEnum.R4); + private final FhirContext myCtx = FhirContext.forR4Cached(); private PackageInstallerSvcImpl mySvc; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/partition/PartitionManagementProviderTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/partition/PartitionManagementProviderTest.java index ad02f5fc22a..3d3f0b2fc37 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/partition/PartitionManagementProviderTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/partition/PartitionManagementProviderTest.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.partition; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.jpa.entity.PartitionEntity; import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; @@ -43,7 +42,7 @@ import static org.mockito.Mockito.when; public class PartitionManagementProviderTest { private static final Logger ourLog = LoggerFactory.getLogger(PartitionManagementProviderTest.class); - private static FhirContext ourCtx = FhirContext.forCached(FhirVersionEnum.R4); + private static final FhirContext ourCtx = FhirContext.forR4Cached(); @RegisterExtension public static RestfulServerExtension ourServerRule = new RestfulServerExtension(ourCtx); @MockBean diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/patch/FhirPatchApplyR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/patch/FhirPatchApplyR4Test.java index 0a9252e986a..51f664bac56 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/patch/FhirPatchApplyR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/patch/FhirPatchApplyR4Test.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.patch; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.IBaseResource; @@ -24,7 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class FhirPatchApplyR4Test { - private static final FhirContext ourCtx = FhirContext.forCached(FhirVersionEnum.R4); + private static final FhirContext ourCtx = FhirContext.forR4Cached(); private static final Logger ourLog = LoggerFactory.getLogger(FhirPatchApplyR4Test.class); @Test diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/patch/FhirPatchCoreTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/patch/FhirPatchCoreTest.java index b044d489485..1da0afb4e49 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/patch/FhirPatchCoreTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/patch/FhirPatchCoreTest.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.patch; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.test.BaseTest; import ca.uhn.fhir.util.ClasspathUtil; import ca.uhn.fhir.util.XmlUtil; @@ -51,10 +50,10 @@ public class FhirPatchCoreTest extends BaseTest { public static List parameters() throws TransformerException, SAXException, IOException { String testSpecR4 = "/org/hl7/fhir/testcases/r4/patch/fhir-path-tests.xml"; - Collection retValR4 = loadTestSpec(FhirContext.forCached(FhirVersionEnum.R4), testSpecR4); + Collection retValR4 = loadTestSpec(FhirContext.forR4Cached(), testSpecR4); String testSpecR5 = "/org/hl7/fhir/testcases/r5/patch/fhir-path-tests.xml"; - Collection retValR5 = loadTestSpec(FhirContext.forCached(FhirVersionEnum.R5), testSpecR5); + Collection retValR5 = loadTestSpec(FhirContext.forR5Cached(), testSpecR5); ArrayList retVal = new ArrayList<>(); retVal.addAll(retValR4); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/patch/FhirPatchDiffR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/patch/FhirPatchDiffR4Test.java index 11e15dec383..94447ad11ed 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/patch/FhirPatchDiffR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/patch/FhirPatchDiffR4Test.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.patch; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.r4.model.BooleanType; import org.hl7.fhir.r4.model.DateTimeType; @@ -22,7 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class FhirPatchDiffR4Test { private static final Logger ourLog = LoggerFactory.getLogger(FhirPatchDiffR4Test.class); - private static final FhirContext ourCtx = FhirContext.forCached(FhirVersionEnum.R4); + private static final FhirContext ourCtx = FhirContext.forR4Cached(); @Test public void testReplaceIdentifier() { diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/JpaGraphQLR4ProviderTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/JpaGraphQLR4ProviderTest.java index 9c078cb6ae5..eab62c85934 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/JpaGraphQLR4ProviderTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/JpaGraphQLR4ProviderTest.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.provider; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.rest.annotation.OptionalParam; import ca.uhn.fhir.rest.annotation.Search; import ca.uhn.fhir.rest.api.Constants; @@ -31,7 +30,6 @@ import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Resource; import org.hl7.fhir.utilities.graphql.Argument; import org.hl7.fhir.utilities.graphql.IGraphQLStorageServices; -import org.hl7.fhir.utilities.graphql.Value; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -40,7 +38,6 @@ import org.junit.jupiter.api.Test; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; -import java.util.LinkedList; import java.util.List; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -55,7 +52,7 @@ public class JpaGraphQLR4ProviderTest { public static final String DATA_PREFIX = "{\"data\": "; public static final String DATA_SUFFIX = "}"; private static CloseableHttpClient ourClient; - private static FhirContext ourCtx = FhirContext.forCached(FhirVersionEnum.R4); + private static final FhirContext ourCtx = FhirContext.forR4Cached(); private static int ourPort; private static Server ourServer; @@ -252,7 +249,7 @@ public class JpaGraphQLR4ProviderTest { Patient patient = new Patient(); patient.addName(new HumanName().setFamily("FAMILY")); patient.getIdElement().setValue("Patient/" + i); - retVal.add((Patient) patient); + retVal.add(patient); } return retVal; } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SearchParameterMapTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SearchParameterMapTest.java index 39f995742a4..b9442e0813d 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SearchParameterMapTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SearchParameterMapTest.java @@ -1,25 +1,30 @@ package ca.uhn.fhir.jpa.provider; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; - -import ca.uhn.fhir.context.FhirVersionEnum; -import ca.uhn.fhir.rest.api.SearchContainedModeEnum; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Test; - import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap.EverythingModeEnum; import ca.uhn.fhir.model.api.Include; +import ca.uhn.fhir.rest.api.SearchContainedModeEnum; import ca.uhn.fhir.rest.api.SortOrderEnum; import ca.uhn.fhir.rest.api.SortSpec; -import ca.uhn.fhir.rest.param.*; -import ca.uhn.fhir.util.TestUtil; +import ca.uhn.fhir.rest.param.DateAndListParam; +import ca.uhn.fhir.rest.param.DateOrListParam; +import ca.uhn.fhir.rest.param.DateParam; +import ca.uhn.fhir.rest.param.ParamPrefixEnum; +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.util.UrlUtil; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; public class SearchParameterMapTest { - private static FhirContext ourCtx = FhirContext.forCached(FhirVersionEnum.DSTU3); + private static final FhirContext ourCtx = FhirContext.forDstu3Cached(); @Test 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 bcaba0b3547..98c604f3903 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 @@ -1,15 +1,22 @@ package ca.uhn.fhir.jpa.provider; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.jpa.dao.dstu2.BaseJpaDstu2Test; -import ca.uhn.fhir.jpa.rp.dstu2.*; -import ca.uhn.fhir.model.dstu2.resource.*; +import ca.uhn.fhir.jpa.rp.dstu2.BinaryResourceProvider; +import ca.uhn.fhir.jpa.rp.dstu2.DiagnosticOrderResourceProvider; +import ca.uhn.fhir.jpa.rp.dstu2.DiagnosticReportResourceProvider; +import ca.uhn.fhir.jpa.rp.dstu2.LocationResourceProvider; +import ca.uhn.fhir.jpa.rp.dstu2.ObservationResourceProvider; +import ca.uhn.fhir.jpa.rp.dstu2.OrganizationResourceProvider; +import ca.uhn.fhir.jpa.rp.dstu2.PatientResourceProvider; +import ca.uhn.fhir.jpa.rp.dstu2.PractitionerResourceProvider; +import ca.uhn.fhir.model.dstu2.resource.Bundle; +import ca.uhn.fhir.model.dstu2.resource.OperationDefinition; +import ca.uhn.fhir.model.dstu2.resource.OperationOutcome; +import ca.uhn.fhir.model.dstu2.resource.Patient; import ca.uhn.fhir.model.dstu2.valueset.BundleTypeEnum; import ca.uhn.fhir.model.dstu2.valueset.HTTPVerbEnum; -import ca.uhn.fhir.model.primitive.DecimalDt; import ca.uhn.fhir.model.primitive.IdDt; -import ca.uhn.fhir.model.primitive.StringDt; import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.server.FifoMemoryPagingProvider; @@ -17,8 +24,8 @@ import ca.uhn.fhir.rest.server.RestfulServer; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException; import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor; +import ca.uhn.fhir.test.utilities.JettyUtil; import ca.uhn.fhir.util.BundleUtil; -import ca.uhn.fhir.util.TestUtil; import com.google.common.base.Charsets; import org.apache.commons.io.IOUtils; import org.apache.http.client.methods.CloseableHttpResponse; @@ -30,14 +37,11 @@ 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.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.model.IdType; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; import java.io.IOException; import java.io.InputStream; @@ -45,10 +49,13 @@ import java.nio.charset.StandardCharsets; import java.util.concurrent.TimeUnit; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; -import static org.junit.jupiter.api.Assertions.*; - -import ca.uhn.fhir.test.utilities.JettyUtil; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.startsWith; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; public class SystemProviderDstu2Test extends BaseJpaDstu2Test { @@ -104,7 +111,7 @@ public class SystemProviderDstu2Test extends BaseJpaDstu2Test { servletHolder.setServlet(restServer); proxyHandler.addServlet(servletHolder, "/fhir/context/*"); - ourCtx = FhirContext.forCached(FhirVersionEnum.DSTU2); + ourCtx = FhirContext.forDstu2Cached(); restServer.setFhirContext(ourCtx); ourServer.setHandler(proxyHandler); @@ -396,7 +403,6 @@ public class SystemProviderDstu2Test extends BaseJpaDstu2Test { assertEquals(200, http.getStatusLine().getStatusCode()); } finally { IOUtils.closeQuietly(http); - ; } } 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 4291cc754c8..cc5b8b1f60c 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 @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.provider; 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.dao.dstu2.BaseJpaDstu2Test; import ca.uhn.fhir.jpa.rp.dstu2.ObservationResourceProvider; @@ -82,7 +81,7 @@ public class SystemProviderTransactionSearchDstu2Test extends BaseJpaDstu2Test { servletHolder.setServlet(restServer); proxyHandler.addServlet(servletHolder, "/fhir/context/*"); - ourCtx = FhirContext.forCached(FhirVersionEnum.DSTU2); + ourCtx = FhirContext.forDstu2Cached(); restServer.setFhirContext(ourCtx); ourServer.setHandler(proxyHandler); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/TerminologyUploaderProviderTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/TerminologyUploaderProviderTest.java index e40c255f6c3..ac8066b3f31 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/TerminologyUploaderProviderTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/TerminologyUploaderProviderTest.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.provider; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.test.BaseTest; import org.hl7.fhir.r4.model.CodeSystem; @@ -13,7 +12,7 @@ public class TerminologyUploaderProviderTest extends BaseTest { @Test public void testCanonicalizeR3() { TerminologyUploaderProvider provider = new TerminologyUploaderProvider(); - provider.setContext(FhirContext.forCached(FhirVersionEnum.DSTU3)); + provider.setContext(FhirContext.forDstu3Cached()); org.hl7.fhir.dstu3.model.CodeSystem input = new org.hl7.fhir.dstu3.model.CodeSystem(); input.addConcept().setCode("FOO").setDisplay("Foo"); @@ -26,7 +25,7 @@ public class TerminologyUploaderProviderTest extends BaseTest { @Test public void testCanonicalizeR4() { TerminologyUploaderProvider provider = new TerminologyUploaderProvider(); - provider.setContext(FhirContext.forCached(FhirVersionEnum.R4)); + provider.setContext(FhirContext.forR4Cached()); org.hl7.fhir.r4.model.CodeSystem input = new org.hl7.fhir.r4.model.CodeSystem(); input.addConcept().setCode("FOO").setDisplay("Foo"); @@ -39,7 +38,7 @@ public class TerminologyUploaderProviderTest extends BaseTest { @Test public void testCanonicalizeR5() { TerminologyUploaderProvider provider = new TerminologyUploaderProvider(); - provider.setContext(FhirContext.forCached(FhirVersionEnum.R5)); + provider.setContext(FhirContext.forR5Cached()); org.hl7.fhir.r5.model.CodeSystem input = new org.hl7.fhir.r5.model.CodeSystem(); input.addConcept().setCode("FOO").setDisplay("Foo"); @@ -52,7 +51,7 @@ public class TerminologyUploaderProviderTest extends BaseTest { @Test public void testCanonicalizeR5_WrongType() { TerminologyUploaderProvider provider = new TerminologyUploaderProvider(); - provider.setContext(FhirContext.forCached(FhirVersionEnum.R5)); + provider.setContext(FhirContext.forR5Cached()); org.hl7.fhir.r5.model.Patient input = new org.hl7.fhir.r5.model.Patient(); 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 7f8aa7a0fb5..75977b406b4 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 @@ -1,12 +1,20 @@ package ca.uhn.fhir.jpa.provider.dstu3; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.jpa.dao.dstu3.FhirResourceDaoDstu3TerminologyTest; import ca.uhn.fhir.jpa.term.TermReindexingSvcImpl; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; -import org.hl7.fhir.dstu3.model.*; +import org.hl7.fhir.dstu3.model.BooleanType; +import org.hl7.fhir.dstu3.model.CodeSystem; +import org.hl7.fhir.dstu3.model.CodeType; +import org.hl7.fhir.dstu3.model.Coding; +import org.hl7.fhir.dstu3.model.Parameters; +import org.hl7.fhir.dstu3.model.Questionnaire; +import org.hl7.fhir.dstu3.model.QuestionnaireResponse; +import org.hl7.fhir.dstu3.model.StringType; +import org.hl7.fhir.dstu3.model.UriType; +import org.hl7.fhir.dstu3.model.ValueSet; import org.hl7.fhir.instance.model.api.IBaseOperationOutcome; import org.hl7.fhir.instance.model.api.IBaseResource; import org.junit.jupiter.api.BeforeEach; @@ -22,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.fail; public class ResourceProviderDstu3CodeSystemTest extends BaseResourceProviderDstu3Test { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderDstu3CodeSystemTest.class); - public static FhirContext ourCtx = FhirContext.forCached(FhirVersionEnum.DSTU3); + public static FhirContext ourCtx = FhirContext.forDstu3Cached(); @BeforeEach @Transactional 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 902e792d724..9e1020e7957 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 @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.provider.dstu3; 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.dao.dstu3.BaseJpaDstu3Test; import ca.uhn.fhir.jpa.rp.dstu3.ObservationResourceProvider; @@ -13,7 +12,6 @@ import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.client.interceptor.SimpleRequestHeaderInterceptor; import ca.uhn.fhir.rest.server.RestfulServer; import ca.uhn.fhir.test.utilities.JettyUtil; -import ca.uhn.fhir.util.TestUtil; import com.google.common.base.Charsets; import org.apache.commons.io.IOUtils; import org.apache.http.client.methods.CloseableHttpResponse; @@ -34,10 +32,10 @@ import org.hl7.fhir.dstu3.model.Bundle.HTTPVerb; import org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender; import org.hl7.fhir.dstu3.model.Patient; import org.hl7.fhir.instance.model.api.IIdType; -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.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -102,7 +100,7 @@ public class SystemProviderTransactionSearchDstu3Test extends BaseJpaDstu3Test { servletHolder.setServlet(restServer); proxyHandler.addServlet(servletHolder, "/fhir/context/*"); - ourCtx = FhirContext.forCached(FhirVersionEnum.DSTU3); + ourCtx = FhirContext.forDstu3Cached(); restServer.setFhirContext(ourCtx); ourServer.setHandler(proxyHandler); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/EmptyIndexesR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/EmptyIndexesR4Test.java index 6b14da66fb2..ef88b957313 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/EmptyIndexesR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/EmptyIndexesR4Test.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.provider.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.dao.r4.BaseJpaR4Test; import ca.uhn.fhir.jpa.rp.r4.ObservationResourceProvider; @@ -12,7 +11,6 @@ import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.client.interceptor.SimpleRequestHeaderInterceptor; 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; @@ -20,10 +18,10 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.hl7.fhir.r4.model.Observation; -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.util.concurrent.TimeUnit; @@ -76,7 +74,7 @@ public class EmptyIndexesR4Test extends BaseJpaR4Test { servletHolder.setServlet(restServer); proxyHandler.addServlet(servletHolder, "/fhir/context/*"); - ourCtx = FhirContext.forCached(FhirVersionEnum.R4); + ourCtx = FhirContext.forR4Cached(); restServer.setFhirContext(ourCtx); ourServer.setHandler(proxyHandler); 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 7b8a3bf32b8..750953a8818 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 @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.provider.r4; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.interceptor.api.Hook; import ca.uhn.fhir.interceptor.api.Pointcut; import ca.uhn.fhir.jpa.api.config.DaoConfig; @@ -161,7 +160,7 @@ public class SystemProviderR4Test extends BaseJpaR4Test { servletHolder.setServlet(restServer); proxyHandler.addServlet(servletHolder, "/fhir/context/*"); - ourCtx = FhirContext.forCached(FhirVersionEnum.R4); + ourCtx = FhirContext.forR4Cached(); restServer.setFhirContext(ourCtx); ourServer.setHandler(proxyHandler); 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 df65b4de7d0..249c93b2166 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 @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.provider.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.dao.r4.BaseJpaR4Test; import ca.uhn.fhir.jpa.rp.r4.MedicationRequestResourceProvider; @@ -17,7 +16,6 @@ import ca.uhn.fhir.rest.param.ReferenceParam; import ca.uhn.fhir.rest.param.TokenOrListParam; 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; @@ -34,8 +32,8 @@ import org.hl7.fhir.r4.model.Medication; import org.hl7.fhir.r4.model.MedicationRequest; 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.AfterAll; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -44,10 +42,10 @@ import java.util.List; import java.util.concurrent.TimeUnit; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; -import static org.junit.jupiter.api.Assertions.*; - -import ca.uhn.fhir.test.utilities.JettyUtil; +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.nullValue; +import static org.junit.jupiter.api.Assertions.assertEquals; public class SystemProviderTransactionSearchR4Test extends BaseJpaR4Test { @@ -103,7 +101,7 @@ public class SystemProviderTransactionSearchR4Test extends BaseJpaR4Test { servletHolder.setServlet(restServer); proxyHandler.addServlet(servletHolder, "/fhir/context/*"); - ourCtx = FhirContext.forCached(FhirVersionEnum.R4); + ourCtx = FhirContext.forR4Cached(); restServer.setFhirContext(ourCtx); ourServer.setHandler(proxyHandler); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImplTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImplTest.java index 347f7a94c86..830f77ba0f5 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImplTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImplTest.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.search; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster; import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.api.config.DaoConfig; @@ -87,7 +86,7 @@ import static org.mockito.Mockito.when; public class SearchCoordinatorSvcImplTest { private static final Logger ourLog = LoggerFactory.getLogger(SearchCoordinatorSvcImplTest.class); - private static FhirContext ourCtx = FhirContext.forCached(FhirVersionEnum.DSTU3); + private static final FhirContext ourCtx = FhirContext.forDstu3Cached(); @Mock private IFhirResourceDao myCallingDao; @Mock @@ -667,7 +666,7 @@ public class SearchCoordinatorSvcImplTest { public static class FailAfterNIterator extends BaseIterator implements IResultIterator { private int myCount; - private IResultIterator myWrap; + private final IResultIterator myWrap; FailAfterNIterator(IResultIterator theWrap, int theCount) { myWrap = theWrap; @@ -768,10 +767,10 @@ public class SearchCoordinatorSvcImplTest { private static final Logger ourLog = LoggerFactory.getLogger(SlowIterator.class); private final IResultIterator myResultIteratorWrap; - private int myDelay; - private Iterator myWrap; - private List myReturnedValues = new ArrayList<>(); - private AtomicInteger myCountReturned = new AtomicInteger(0); + private final int myDelay; + private final Iterator myWrap; + private final List myReturnedValues = new ArrayList<>(); + private final AtomicInteger myCountReturned = new AtomicInteger(0); SlowIterator(Iterator theWrap, int theDelay) { myWrap = theWrap; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/builder/sql/SearchQueryBuilderTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/builder/sql/SearchQueryBuilderTest.java index 7e535aa8c6a..99f799469ac 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/builder/sql/SearchQueryBuilderTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/builder/sql/SearchQueryBuilderTest.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.search.builder.sql; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.config.HibernatePropertiesProvider; import ca.uhn.fhir.jpa.model.config.PartitionSettings; @@ -43,7 +42,7 @@ public class SearchQueryBuilderTest { @BeforeEach public void before() { - myFhirContext = FhirContext.forCached(FhirVersionEnum.R4); + myFhirContext = FhirContext.forR4Cached(); myModelConfig = new ModelConfig(); myPartitionSettings = new PartitionSettings(); myRequestPartitionId = RequestPartitionId.allPartitions(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchSvcMultipleObservationsIT.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchSvcMultipleObservationsIT.java index 653c4de56f5..5c35f8a65e1 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchSvcMultipleObservationsIT.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchSvcMultipleObservationsIT.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.search.lastn; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.jpa.model.config.PartitionSettings; import ca.uhn.fhir.jpa.search.lastn.config.TestElasticsearchContainerHelper; import ca.uhn.fhir.jpa.search.lastn.json.CodeJson; @@ -61,7 +60,7 @@ public class LastNElasticsearchSvcMultipleObservationsIT { private static ObjectMapper ourMapperNonPrettyPrint; private static boolean indexLoaded = false; private final Map>> createdPatientObservationMap = new HashMap<>(); - private final FhirContext myFhirContext = FhirContext.forCached(FhirVersionEnum.R4); + private final FhirContext myFhirContext = FhirContext.forR4Cached(); private ElasticsearchSvcImpl elasticsearchSvc; @BeforeEach diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchSvcSingleObservationIT.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchSvcSingleObservationIT.java index 55a5056f8d8..dbda8eb5e48 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchSvcSingleObservationIT.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchSvcSingleObservationIT.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.search.lastn; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.jpa.model.config.PartitionSettings; import ca.uhn.fhir.jpa.model.util.CodeSystemHash; import ca.uhn.fhir.jpa.search.lastn.config.TestElasticsearchContainerHelper; @@ -27,23 +26,17 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.testcontainers.elasticsearch.ElasticsearchContainer; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import java.io.IOException; -import java.time.Duration; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.UUID; -import static java.time.temporal.ChronoUnit.SECONDS; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -85,7 +78,7 @@ public class LastNElasticsearchSvcSingleObservationIT { final String CODEFIRSTCODINGSYSTEM = "http://mycodes.org/fhir/observation-code"; final String CODEFIRSTCODINGCODE = "test-code"; final String CODEFIRSTCODINGDISPLAY = "test-code display"; - final FhirContext myFhirContext = FhirContext.forCached(FhirVersionEnum.R4); + final FhirContext myFhirContext = FhirContext.forR4Cached(); ElasticsearchSvcImpl elasticsearchSvc; 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 c1277dd9378..a8aec02d895 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 @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.search.reindex; 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.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; @@ -56,7 +55,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) public class ResourceReindexingSvcImplTest extends BaseJpaTest { - private static final FhirContext ourCtx = FhirContext.forCached(FhirVersionEnum.R4); + private static final FhirContext ourCtx = FhirContext.forR4Cached(); @Mock private PlatformTransactionManager myTxManager; 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 5b47c24a5be..ccf59fce433 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 @@ -1,14 +1,13 @@ package ca.uhn.fhir.jpa.searchparam; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.jpa.config.TestDstu3Config; import ca.uhn.fhir.jpa.dao.BaseJpaTest; -import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import ca.uhn.fhir.jpa.searchparam.util.Dstu3DistanceHelper; import ca.uhn.fhir.rest.param.QuantityParam; import ca.uhn.fhir.rest.param.ReferenceParam; +import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import org.hl7.fhir.dstu3.model.Condition; import org.hl7.fhir.dstu3.model.Location; import org.junit.jupiter.api.Test; @@ -30,7 +29,7 @@ import static org.mockito.Mockito.when; @ContextConfiguration(classes = {TestDstu3Config.class}) public class MatchUrlServiceTest extends BaseJpaTest { - private static FhirContext ourCtx = FhirContext.forCached(FhirVersionEnum.DSTU3); + private static final FhirContext ourCtx = FhirContext.forDstu3Cached(); @Autowired MatchUrlService myMatchUrlService; 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 fb0bb5230dd..f6d155b268f 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 @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.stresstest; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster; import ca.uhn.fhir.interceptor.executor.InterceptorService; import ca.uhn.fhir.interceptor.model.ReadPartitionIdRequestDetails; @@ -110,7 +109,7 @@ import static org.mockito.Mockito.when; public class GiantTransactionPerfTest { private static final Logger ourLog = LoggerFactory.getLogger(GiantTransactionPerfTest.class); - private final FhirContext myCtx = FhirContext.forCached(FhirVersionEnum.R4); + private final FhirContext myCtx = FhirContext.forR4Cached(); private FhirSystemDaoR4 mySystemDao; private IInterceptorBroadcaster myInterceptorSvc; private TransactionProcessor myTransactionProcessor; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/stresstest/StressTestParserTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/stresstest/StressTestParserTest.java index e0a8c46726c..f0f5d41113c 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/stresstest/StressTestParserTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/stresstest/StressTestParserTest.java @@ -1,10 +1,8 @@ package ca.uhn.fhir.jpa.stresstest; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.test.BaseTest; import ca.uhn.fhir.util.StopWatch; -import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r4.model.Bundle; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -24,7 +22,7 @@ public class StressTestParserTest extends BaseTest { @Test @Disabled public void test() throws IOException { - FhirContext ctx = FhirContext.forCached(FhirVersionEnum.R4); + FhirContext ctx = FhirContext.forR4Cached(); String input = loadResource("/org/hl7/fhir/r4/model/valueset/valuesets.xml"); Bundle parsed = ctx.newXmlParser().parseResource(Bundle.class, input); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/BaseSubscriptionsR5Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/BaseSubscriptionsR5Test.java index c99d943d134..d6eaae2a64d 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/BaseSubscriptionsR5Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/BaseSubscriptionsR5Test.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.subscription; 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.r5.BaseResourceProviderR5Test; import ca.uhn.fhir.jpa.subscription.channel.impl.LinkedBlockingChannel; @@ -225,7 +224,7 @@ public abstract class BaseSubscriptionsR5Test extends BaseResourceProviderR5Test @BeforeAll public static void startListenerServer() throws Exception { - RestfulServer ourListenerRestServer = new RestfulServer(FhirContext.forCached(FhirVersionEnum.R5)); + RestfulServer ourListenerRestServer = new RestfulServer(FhirContext.forR5Cached()); ObservationListener obsListener = new ObservationListener(); ourListenerRestServer.setResourceProviders(obsListener); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/FhirServiceUtil.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/FhirServiceUtil.java index c3928d03cca..168209f9830 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/FhirServiceUtil.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/FhirServiceUtil.java @@ -1,11 +1,9 @@ package ca.uhn.fhir.jpa.subscription; -import ca.uhn.fhir.context.FhirVersionEnum; -import org.hl7.fhir.instance.model.api.IBaseResource; - import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.client.api.IGenericClient; +import org.hl7.fhir.instance.model.api.IBaseResource; public class FhirServiceUtil { @@ -16,12 +14,12 @@ public class FhirServiceUtil { public static final String REST_HOOK_ENDPOINT = "http://localhost:10080/rest-hook"; public static IGenericClient getFhirDstu3Client() { - FhirContext ctx = FhirContext.forCached(FhirVersionEnum.DSTU3); + FhirContext ctx = FhirContext.forDstu3Cached(); return ctx.newRestfulGenericClient(FHIR_DSTU3_URL); } public static IGenericClient getFhirDstu2Client() { - FhirContext ctx = FhirContext.forCached(FhirVersionEnum.DSTU2); + FhirContext ctx = FhirContext.forDstu2Cached(); return ctx.newRestfulGenericClient(FHIR_DSTU2_URL); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/SubscriptionValidatingInterceptorTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/SubscriptionValidatingInterceptorTest.java index 543546ec9ab..8e829406d72 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/SubscriptionValidatingInterceptorTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/SubscriptionValidatingInterceptorTest.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.subscription; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.subscription.match.matcher.matching.SubscriptionStrategyEvaluator; import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionCanonicalizer; @@ -26,7 +25,7 @@ public class SubscriptionValidatingInterceptorTest { @Mock public DaoRegistry myDaoRegistry; private SubscriptionValidatingInterceptor mySvc; - private FhirContext myCtx = FhirContext.forCached(FhirVersionEnum.R4); + private final FhirContext myCtx = FhirContext.forR4Cached(); @Mock private SubscriptionStrategyEvaluator mySubscriptionStrategyEvaluator; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookActivatesPreExistingSubscriptionsR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookActivatesPreExistingSubscriptionsR4Test.java index c8383e05398..4c6d4fcf2ee 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookActivatesPreExistingSubscriptionsR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookActivatesPreExistingSubscriptionsR4Test.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.subscription.resthook; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.jpa.provider.r4.BaseResourceProviderR4Test; import ca.uhn.fhir.jpa.subscription.SubscriptionTestUtil; import ca.uhn.fhir.jpa.subscription.submit.interceptor.SubscriptionMatcherInterceptor; @@ -164,7 +163,7 @@ public class RestHookActivatesPreExistingSubscriptionsR4Test extends BaseResourc @BeforeAll public static void startListenerServer() throws Exception { - ourListenerRestServer = new RestfulServer(FhirContext.forCached(FhirVersionEnum.R4)); + ourListenerRestServer = new RestfulServer(FhirContext.forR4Cached()); ObservationListener obsListener = new ObservationListener(); ourListenerRestServer.setResourceProviders(obsListener); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestDstu2Test.java index fa642b17864..cde305c056b 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestDstu2Test.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.subscription.resthook; 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.BaseResourceProviderDstu2Test; import ca.uhn.fhir.jpa.subscription.SubscriptionTestUtil; @@ -28,7 +27,11 @@ import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; -import org.junit.jupiter.api.*; import static org.hamcrest.MatcherAssert.assertThat; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import javax.validation.constraints.NotNull; @@ -38,7 +41,11 @@ import java.util.stream.Collectors; import static ca.uhn.fhir.jpa.subscription.resthook.RestHookTestDstu3Test.logAllInterceptors; import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.jupiter.api.Assertions.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; /** * Test the rest-hook subscriptions @@ -46,13 +53,13 @@ import static org.junit.jupiter.api.Assertions.*; public class RestHookTestDstu2Test extends BaseResourceProviderDstu2Test { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(RestHookTestDstu2Test.class); - private static List ourCreatedObservations = Lists.newArrayList(); + private static final List ourCreatedObservations = Lists.newArrayList(); private static int ourListenerPort; private static RestfulServer ourListenerRestServer; private static Server ourListenerServer; private static String ourListenerServerBase; - private static List ourUpdatedObservations = Lists.newArrayList(); - private List mySubscriptionIds = new ArrayList(); + private static final List ourUpdatedObservations = Lists.newArrayList(); + private final List mySubscriptionIds = new ArrayList(); @Autowired private SubscriptionTestUtil mySubscriptionTestUtil; @@ -325,7 +332,7 @@ public class RestHookTestDstu2Test extends BaseResourceProviderDstu2Test { @BeforeAll public static void startListenerServer() throws Exception { - ourListenerRestServer = new RestfulServer(FhirContext.forCached(FhirVersionEnum.DSTU2)); + ourListenerRestServer = new RestfulServer(FhirContext.forDstu2Cached()); ObservationListener obsListener = new ObservationListener(); ourListenerRestServer.setResourceProviders(obsListener); 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 310bbd35715..b5715d7291d 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 @@ -1,14 +1,13 @@ package ca.uhn.fhir.jpa.subscription.resthook; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.interceptor.api.IInterceptorService; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.provider.dstu3.BaseResourceProviderDstu3Test; import ca.uhn.fhir.jpa.subscription.NotificationServlet; import ca.uhn.fhir.jpa.subscription.SubscriptionTestUtil; -import ca.uhn.fhir.jpa.subscription.util.SubscriptionDebugLogInterceptor; import ca.uhn.fhir.jpa.subscription.match.matcher.matching.SubscriptionMatchingStrategy; +import ca.uhn.fhir.jpa.subscription.util.SubscriptionDebugLogInterceptor; import ca.uhn.fhir.rest.annotation.Create; import ca.uhn.fhir.rest.annotation.ResourceParam; import ca.uhn.fhir.rest.annotation.Update; @@ -24,10 +23,22 @@ import com.google.common.collect.Lists; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; -import org.hl7.fhir.dstu3.model.*; +import org.hl7.fhir.dstu3.model.CodeableConcept; +import org.hl7.fhir.dstu3.model.Coding; +import org.hl7.fhir.dstu3.model.CommunicationRequest; +import org.hl7.fhir.dstu3.model.DateTimeType; +import org.hl7.fhir.dstu3.model.IdType; +import org.hl7.fhir.dstu3.model.Observation; +import org.hl7.fhir.dstu3.model.Organization; +import org.hl7.fhir.dstu3.model.StringType; +import org.hl7.fhir.dstu3.model.Subscription; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; -import org.junit.jupiter.api.*; import static org.hamcrest.MatcherAssert.assertThat; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import javax.servlet.http.HttpServletRequest; @@ -40,8 +51,15 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import static org.awaitility.Awaitility.await; +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.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.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Test the rest-hook subscriptions @@ -49,18 +67,18 @@ import static org.junit.jupiter.api.Assertions.*; public class RestHookTestDstu3Test extends BaseResourceProviderDstu3Test { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(RestHookTestDstu3Test.class); - private static List ourCreatedObservations = Collections.synchronizedList(Lists.newArrayList()); + private static final List ourCreatedObservations = Collections.synchronizedList(Lists.newArrayList()); private static int ourListenerPort; private static RestfulServer ourListenerRestServer; private static Server ourListenerServer; private static String ourListenerServerBase; - private static List ourUpdatedObservations = Collections.synchronizedList(Lists.newArrayList()); - private static List ourContentTypes = Collections.synchronizedList(new ArrayList<>()); + private static final List ourUpdatedObservations = Collections.synchronizedList(Lists.newArrayList()); + private static final List ourContentTypes = Collections.synchronizedList(new ArrayList<>()); private static NotificationServlet ourNotificationServlet; private static String ourNotificationListenerServer; private static CountDownLatch communicationRequestListenerLatch; - private static SubscriptionDebugLogInterceptor ourSubscriptionDebugLogInterceptor = new SubscriptionDebugLogInterceptor(); - private List mySubscriptionIds = Collections.synchronizedList(new ArrayList<>()); + private static final SubscriptionDebugLogInterceptor ourSubscriptionDebugLogInterceptor = new SubscriptionDebugLogInterceptor(); + private final List mySubscriptionIds = Collections.synchronizedList(new ArrayList<>()); @Autowired private SubscriptionTestUtil mySubscriptionTestUtil; @@ -638,7 +656,7 @@ public class RestHookTestDstu3Test extends BaseResourceProviderDstu3Test { @BeforeAll public static void startListenerServer() throws Exception { - ourListenerRestServer = new RestfulServer(FhirContext.forCached(FhirVersionEnum.DSTU3)); + ourListenerRestServer = new RestfulServer(FhirContext.forDstu3Cached()); ObservationListener obsListener = new ObservationListener(); CommunicationRequestListener crListener = new CommunicationRequestListener(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test.java index 904b0b1653f..7e24d49a2a2 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.subscription.resthook; 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.BaseResourceProviderDstu2Test; import ca.uhn.fhir.jpa.subscription.SubscriptionTestUtil; @@ -47,12 +46,12 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test extends BaseResourceProviderDstu2Test { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test.class); - private static List ourCreatedObservations = Collections.synchronizedList(Lists.newArrayList()); + private static final List ourCreatedObservations = Collections.synchronizedList(Lists.newArrayList()); private static int ourListenerPort; private static RestfulServer ourListenerRestServer; private static Server ourListenerServer; private static String ourListenerServerBase; - private static List ourUpdatedObservations = Collections.synchronizedList(Lists.newArrayList()); + private static final List ourUpdatedObservations = Collections.synchronizedList(Lists.newArrayList()); @Autowired protected SubscriptionRegistry mySubscriptionRegistry; @Autowired @@ -309,7 +308,7 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu2Test extends B @BeforeAll public static void startListenerServer() throws Exception { - ourListenerRestServer = new RestfulServer(FhirContext.forCached(FhirVersionEnum.DSTU2)); + ourListenerRestServer = new RestfulServer(FhirContext.forDstu2Cached()); ObservationListener obsListener = new ObservationListener(); ourListenerRestServer.setResourceProviders(obsListener); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestWithInterceptorRegisteredToDaoConfigDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestWithInterceptorRegisteredToDaoConfigDstu3Test.java index c9bc7b33b41..81ffcab1315 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestWithInterceptorRegisteredToDaoConfigDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestWithInterceptorRegisteredToDaoConfigDstu3Test.java @@ -2,7 +2,6 @@ package ca.uhn.fhir.jpa.subscription.resthook; 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.dstu3.BaseResourceProviderDstu3Test; import ca.uhn.fhir.jpa.subscription.SubscriptionTestUtil; @@ -42,13 +41,13 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; */ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu3Test extends BaseResourceProviderDstu3Test { - private static List ourCreatedObservations = Collections.synchronizedList(Lists.newArrayList()); + private static final List ourCreatedObservations = Collections.synchronizedList(Lists.newArrayList()); private static int ourListenerPort; private static RestfulServer ourListenerRestServer; private static Server ourListenerServer; private static String ourListenerServerBase; private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(RestHookTestWithInterceptorRegisteredToDaoConfigDstu3Test.class); - private static List ourUpdatedObservations = Collections.synchronizedList(Lists.newArrayList()); + private static final List ourUpdatedObservations = Collections.synchronizedList(Lists.newArrayList()); @Autowired private SubscriptionTestUtil mySubscriptionTestUtil; @@ -266,7 +265,7 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigDstu3Test extends B @BeforeAll public static void startListenerServer() throws Exception { - ourListenerRestServer = new RestfulServer(FhirContext.forCached(FhirVersionEnum.DSTU3)); + ourListenerRestServer = new RestfulServer(FhirContext.forDstu3Cached()); ObservationListener obsListener = new ObservationListener(); ourListenerRestServer.setResourceProviders(obsListener); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestWithInterceptorRegisteredToDaoConfigR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestWithInterceptorRegisteredToDaoConfigR4Test.java index f1e3593c89c..35ecf3cda06 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestWithInterceptorRegisteredToDaoConfigR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookTestWithInterceptorRegisteredToDaoConfigR4Test.java @@ -2,7 +2,6 @@ package ca.uhn.fhir.jpa.subscription.resthook; 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.subscription.SubscriptionTestUtil; @@ -20,28 +19,36 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.hl7.fhir.instance.model.api.IBaseResource; -import org.hl7.fhir.r4.model.*; -import org.junit.jupiter.api.*; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; - +import org.hl7.fhir.r4.model.CodeableConcept; +import org.hl7.fhir.r4.model.Coding; +import org.hl7.fhir.r4.model.IdType; +import org.hl7.fhir.r4.model.Observation; +import org.hl7.fhir.r4.model.Subscription; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import java.util.Collections; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; + /** * Test the rest-hook subscriptions */ public class RestHookTestWithInterceptorRegisteredToDaoConfigR4Test extends BaseResourceProviderR4Test { - private static List ourCreatedObservations = Collections.synchronizedList(Lists.newArrayList()); + private static final List ourCreatedObservations = Collections.synchronizedList(Lists.newArrayList()); private static int ourListenerPort; private static RestfulServer ourListenerRestServer; private static Server ourListenerServer; private static String ourListenerServerBase; private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(RestHookTestWithInterceptorRegisteredToDaoConfigR4Test.class); - private static List ourUpdatedObservations = Collections.synchronizedList(Lists.newArrayList()); + private static final List ourUpdatedObservations = Collections.synchronizedList(Lists.newArrayList()); @Autowired private SubscriptionTestUtil mySubscriptionTestUtil; @@ -270,7 +277,7 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigR4Test extends Base @BeforeAll public static void startListenerServer() throws Exception { - ourListenerRestServer = new RestfulServer(FhirContext.forCached(FhirVersionEnum.R4)); + ourListenerRestServer = new RestfulServer(FhirContext.forR4Cached()); ObservationListener obsListener = new ObservationListener(); ourListenerRestServer.setResourceProviders(obsListener); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookWithInterceptorR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookWithInterceptorR4Test.java index faa775e0771..4e2f76b3dd7 100755 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookWithInterceptorR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookWithInterceptorR4Test.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.subscription.resthook; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.interceptor.api.Hook; import ca.uhn.fhir.interceptor.api.IInterceptorService; import ca.uhn.fhir.interceptor.api.Interceptor; @@ -61,7 +60,7 @@ public class RestHookWithInterceptorR4Test extends BaseSubscriptionsR4Test { private static boolean ourNextAfterRestHookDeliveryReturn; private static boolean ourHitAfterRestHookDelivery; private static boolean ourNextAddHeader; - private static FhirContext ourCtx = FhirContext.forCached(FhirVersionEnum.R4); + private static final FhirContext ourCtx = FhirContext.forR4Cached(); @Autowired StoppableSubscriptionDeliveringRestHookSubscriber myStoppableSubscriptionDeliveringRestHookSubscriber; @@ -277,7 +276,7 @@ public class RestHookWithInterceptorR4Test extends BaseSubscriptionsR4Test { public static class AttributeCarryingInterceptor { private ResourceDeliveryMessage myLastDelivery; - private CountDownLatch myFinishedLatch = new CountDownLatch(1); + private final CountDownLatch myFinishedLatch = new CountDownLatch(1); public CountDownLatch getFinishedLatch() { return myFinishedLatch; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/SubscriptionTriggeringDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/SubscriptionTriggeringDstu3Test.java index ef2ff92b8f4..db91b394e8a 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/SubscriptionTriggeringDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/SubscriptionTriggeringDstu3Test.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.subscription.resthook; 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.model.sched.ISchedulerService; import ca.uhn.fhir.jpa.model.util.JpaConstants; @@ -64,12 +63,12 @@ public class SubscriptionTriggeringDstu3Test extends BaseResourceProviderDstu3Te private static RestfulServer ourListenerRestServer; private static Server ourListenerServer; private static String ourListenerServerBase; - private static List ourCreatedObservations = Collections.synchronizedList(Lists.newArrayList()); - private static List ourUpdatedObservations = Collections.synchronizedList(Lists.newArrayList()); - private static List ourCreatedPatients = Lists.newArrayList(); - private static List ourUpdatedPatients = Lists.newArrayList(); - private static List ourContentTypes = new ArrayList<>(); - private List mySubscriptionIds = new ArrayList<>(); + private static final List ourCreatedObservations = Collections.synchronizedList(Lists.newArrayList()); + private static final List ourUpdatedObservations = Collections.synchronizedList(Lists.newArrayList()); + private static final List ourCreatedPatients = Lists.newArrayList(); + private static final List ourUpdatedPatients = Lists.newArrayList(); + private static final List ourContentTypes = new ArrayList<>(); + private final List mySubscriptionIds = new ArrayList<>(); @Autowired private SubscriptionTestUtil mySubscriptionTestUtil; @@ -555,7 +554,7 @@ public class SubscriptionTriggeringDstu3Test extends BaseResourceProviderDstu3Te @BeforeAll public static void startListenerServer() throws Exception { - ourListenerRestServer = new RestfulServer(FhirContext.forCached(FhirVersionEnum.DSTU3)); + ourListenerRestServer = new RestfulServer(FhirContext.forDstu3Cached()); ObservationListener obsListener = new ObservationListener(); PatientListener ptListener = new PatientListener(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcLoincTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcLoincTest.java index 96c8f32762e..23feac7194b 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcLoincTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcLoincTest.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.term; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion; import ca.uhn.fhir.jpa.entity.TermConcept; import ca.uhn.fhir.jpa.entity.TermConceptDesignation; @@ -432,7 +431,7 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest { // IEEE Medical Device Codes conceptMap = conceptMaps.get(LoincIeeeMedicalDeviceCodeHandler.LOINC_IEEE_CM_ID); - ourLog.debug(FhirContext.forCached(FhirVersionEnum.R4).newXmlParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); + ourLog.debug(FhirContext.forR4Cached().newXmlParser().setPrettyPrint(true).encodeResourceToString(conceptMap)); assertEquals(LoincIeeeMedicalDeviceCodeHandler.LOINC_IEEE_CM_NAME, conceptMap.getName()); assertEquals(LoincIeeeMedicalDeviceCodeHandler.LOINC_IEEE_CM_URI, conceptMap.getUrl()); assertEquals("Beta.1", conceptMap.getVersion()); @@ -458,7 +457,7 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest { // Group - Parent vs = valueSets.get("LG100-4"); - ourLog.info(FhirContext.forCached(FhirVersionEnum.R4).newXmlParser().setPrettyPrint(true).encodeResourceToString(vs)); + ourLog.info(FhirContext.forR4Cached().newXmlParser().setPrettyPrint(true).encodeResourceToString(vs)); assertEquals("Chem_DrugTox_Chal_Sero_Allergy", vs.getName()); assertEquals("http://loinc.org/vs/LG100-4", vs.getUrl()); assertEquals(1, vs.getCompose().getInclude().size()); @@ -467,7 +466,7 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest { // Group - Child vs = valueSets.get("LG1695-8"); - ourLog.info(FhirContext.forCached(FhirVersionEnum.R4).newXmlParser().setPrettyPrint(true).encodeResourceToString(vs)); + ourLog.info(FhirContext.forR4Cached().newXmlParser().setPrettyPrint(true).encodeResourceToString(vs)); assertEquals("1,4-Dichlorobenzene|MCnc|Pt|ANYBldSerPl", vs.getName()); assertEquals("http://loinc.org/vs/LG1695-8", vs.getUrl()); assertEquals(1, vs.getCompose().getInclude().size()); 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 059adf0234c..cb7eb0246a8 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 @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.util.jsonpatch; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.jpa.dao.BaseJpaTest; import ca.uhn.fhir.jpa.patch.JsonPatchUtils; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; @@ -14,11 +13,12 @@ import org.springframework.transaction.PlatformTransactionManager; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.not; -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 JsonPatchUtilsTest extends BaseJpaTest { - private static final FhirContext ourCtx = FhirContext.forCached(FhirVersionEnum.R4); + private static final FhirContext ourCtx = FhirContext.forR4Cached(); private static final Logger ourLog = LoggerFactory.getLogger(JsonPatchUtilsTest.class); @SuppressWarnings("JsonStandardCompliance") diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/validator/AttachmentUtilTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/validator/AttachmentUtilTest.java index 69b2b89b1b8..072b1a5d6b2 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/validator/AttachmentUtilTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/validator/AttachmentUtilTest.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.validator; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.util.AttachmentUtil; import org.hl7.fhir.instance.model.api.ICompositeType; import org.junit.jupiter.api.Test; @@ -12,7 +11,7 @@ public class AttachmentUtilTest { @Test public void testCreateAttachmentDstu3() { - FhirContext ctx = FhirContext.forCached(FhirVersionEnum.DSTU3); + FhirContext ctx = FhirContext.forDstu3Cached(); ICompositeType attachment = AttachmentUtil.newInstance(ctx); AttachmentUtil.setData(ctx, attachment, new byte[]{0, 1, 2, 3}); AttachmentUtil.setUrl(ctx, attachment, "http://foo"); @@ -27,7 +26,7 @@ public class AttachmentUtilTest { @Test public void testCreateAttachmentR4() { - FhirContext ctx = FhirContext.forCached(FhirVersionEnum.R4); + FhirContext ctx = FhirContext.forR4Cached(); ICompositeType attachment = AttachmentUtil.newInstance(ctx); AttachmentUtil.setData(ctx, attachment, new byte[]{0, 1, 2, 3}); AttachmentUtil.setUrl(ctx, attachment, "http://foo"); @@ -42,7 +41,7 @@ public class AttachmentUtilTest { @Test public void testCreateAttachmentR5() { - FhirContext ctx = FhirContext.forCached(FhirVersionEnum.R5); + FhirContext ctx = FhirContext.forR5Cached(); ICompositeType attachment = AttachmentUtil.newInstance(ctx); AttachmentUtil.setData(ctx, attachment, new byte[]{0, 1, 2, 3}); AttachmentUtil.setUrl(ctx, attachment, "http://foo"); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/validator/ValidatorAcrossVersionsTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/validator/ValidatorAcrossVersionsTest.java index 0fbfcc025b7..ed9722353d5 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/validator/ValidatorAcrossVersionsTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/validator/ValidatorAcrossVersionsTest.java @@ -1,19 +1,16 @@ package ca.uhn.fhir.validator; -import static org.junit.jupiter.api.Assertions.*; - -import ca.uhn.fhir.context.FhirVersionEnum; -import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Test; - import ca.uhn.fhir.context.ConfigurationException; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.model.dstu2.resource.QuestionnaireResponse; import ca.uhn.fhir.model.primitive.DateTimeDt; -import ca.uhn.fhir.util.TestUtil; import ca.uhn.fhir.validation.FhirValidator; import ca.uhn.fhir.validation.ValidationResult; +import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * This test doesn't really belong to JPA, but it needs to be in a project with both DSTU2 and HL7ORG_DSTU2 present, so here will do. @@ -23,7 +20,7 @@ public class ValidatorAcrossVersionsTest { @Test public void testWrongContextVersion() { - FhirContext ctxDstu2 = FhirContext.forCached(FhirVersionEnum.DSTU2); + FhirContext ctxDstu2 = FhirContext.forDstu2Cached(); try { ctxDstu2.getResourceDefinition(org.hl7.fhir.dstu3.model.Patient.class); fail(); @@ -37,7 +34,7 @@ public class ValidatorAcrossVersionsTest { @Test public void testValidateProfileOnDstu2Resource() { - FhirContext ctxDstu2 = FhirContext.forCached(FhirVersionEnum.DSTU2); + FhirContext ctxDstu2 = FhirContext.forDstu2Cached(); FhirValidator val = ctxDstu2.newValidator(); val.setValidateAgainstStandardSchema(false); val.setValidateAgainstStandardSchematron(false); diff --git a/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3Test.java b/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3Test.java index d3c18e9414f..5e70f8f7fe2 100644 --- a/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3Test.java +++ b/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3Test.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.searchparam.extractor; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.context.RuntimeSearchParam; import ca.uhn.fhir.context.phonetic.IPhoneticEncoder; @@ -49,7 +48,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class SearchParamExtractorDstu3Test { - private static FhirContext ourCtx = FhirContext.forCached(FhirVersionEnum.DSTU3); + private static FhirContext ourCtx = FhirContext.forDstu3Cached(); @Test public void testParamWithOrInPath() { diff --git a/hapi-fhir-server-openapi/src/test/java/ca/uhn/fhir/rest/openapi/OpenApiInterceptorTest.java b/hapi-fhir-server-openapi/src/test/java/ca/uhn/fhir/rest/openapi/OpenApiInterceptorTest.java index d80c750f92b..c7afe2ad42a 100644 --- a/hapi-fhir-server-openapi/src/test/java/ca/uhn/fhir/rest/openapi/OpenApiInterceptorTest.java +++ b/hapi-fhir-server-openapi/src/test/java/ca/uhn/fhir/rest/openapi/OpenApiInterceptorTest.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.rest.openapi; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.interceptor.api.Hook; import ca.uhn.fhir.interceptor.api.Pointcut; import ca.uhn.fhir.model.api.annotation.Description; @@ -70,7 +69,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; public class OpenApiInterceptorTest { private static final Logger ourLog = LoggerFactory.getLogger(OpenApiInterceptorTest.class); - private FhirContext myFhirContext = FhirContext.forCached(FhirVersionEnum.R4); + private final FhirContext myFhirContext = FhirContext.forR4Cached(); @RegisterExtension @Order(0) protected RestfulServerExtension myServer = new RestfulServerExtension(myFhirContext) diff --git a/hapi-fhir-server-openapi/src/test/java/ca/uhn/fhir/rest/openapi/OpenApiInterceptorWithAuthorizationInterceptorTest.java b/hapi-fhir-server-openapi/src/test/java/ca/uhn/fhir/rest/openapi/OpenApiInterceptorWithAuthorizationInterceptorTest.java index 766e79e5d89..ff9f3e6b9fd 100644 --- a/hapi-fhir-server-openapi/src/test/java/ca/uhn/fhir/rest/openapi/OpenApiInterceptorWithAuthorizationInterceptorTest.java +++ b/hapi-fhir-server-openapi/src/test/java/ca/uhn/fhir/rest/openapi/OpenApiInterceptorWithAuthorizationInterceptorTest.java @@ -1,50 +1,20 @@ package ca.uhn.fhir.rest.openapi; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; -import ca.uhn.fhir.interceptor.api.Hook; -import ca.uhn.fhir.interceptor.api.Pointcut; -import ca.uhn.fhir.model.api.annotation.Description; -import ca.uhn.fhir.rest.annotation.ConditionalUrlParam; -import ca.uhn.fhir.rest.annotation.IdParam; -import ca.uhn.fhir.rest.annotation.Operation; -import ca.uhn.fhir.rest.annotation.OperationParam; -import ca.uhn.fhir.rest.annotation.Patch; -import ca.uhn.fhir.rest.annotation.ResourceParam; -import ca.uhn.fhir.rest.api.Constants; -import ca.uhn.fhir.rest.api.MethodOutcome; -import ca.uhn.fhir.rest.api.PatchTypeEnum; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor; import ca.uhn.fhir.rest.server.interceptor.auth.AuthorizationInterceptor; import ca.uhn.fhir.rest.server.interceptor.auth.IAuthRule; import ca.uhn.fhir.rest.server.interceptor.auth.RuleBuilder; import ca.uhn.fhir.rest.server.provider.HashMapResourceProvider; -import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; -import ca.uhn.fhir.test.utilities.HtmlUtil; import ca.uhn.fhir.test.utilities.server.RestfulServerExtension; -import ca.uhn.fhir.util.ExtensionConstants; -import com.gargoylesoftware.htmlunit.html.DomElement; -import com.gargoylesoftware.htmlunit.html.HtmlDivision; -import com.gargoylesoftware.htmlunit.html.HtmlPage; import io.swagger.v3.core.util.Yaml; import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.PathItem; import org.apache.commons.io.IOUtils; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; -import org.hamcrest.Matchers; -import org.hl7.fhir.instance.model.api.IBaseBundle; -import org.hl7.fhir.instance.model.api.IBaseCoding; -import org.hl7.fhir.instance.model.api.IBaseConformance; -import org.hl7.fhir.instance.model.api.IBaseParameters; -import org.hl7.fhir.instance.model.api.IBaseReference; -import org.hl7.fhir.instance.model.api.IIdType; -import org.hl7.fhir.instance.model.api.IPrimitiveType; -import org.hl7.fhir.r4.model.CapabilityStatement; -import org.hl7.fhir.r4.model.DecimalType; import org.hl7.fhir.r4.model.Observation; import org.hl7.fhir.r4.model.Patient; import org.junit.jupiter.api.AfterEach; @@ -55,25 +25,17 @@ import org.junit.jupiter.api.extension.RegisterExtension; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.servlet.http.HttpServletRequest; import java.io.IOException; -import java.net.URL; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; 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.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; public class OpenApiInterceptorWithAuthorizationInterceptorTest { private static final Logger ourLog = LoggerFactory.getLogger(OpenApiInterceptorWithAuthorizationInterceptorTest.class); - private FhirContext myFhirContext = FhirContext.forCached(FhirVersionEnum.R4); + private final FhirContext myFhirContext = FhirContext.forR4Cached(); @RegisterExtension @Order(0) protected RestfulServerExtension myServer = new RestfulServerExtension(myFhirContext) diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/CustomThymeleafNarrativeGeneratorDstu2Test.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/CustomThymeleafNarrativeGeneratorDstu2Test.java index a3742c8ea60..44c6aa8cd14 100644 --- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/CustomThymeleafNarrativeGeneratorDstu2Test.java +++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/CustomThymeleafNarrativeGeneratorDstu2Test.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.narrative; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.model.dstu2.resource.Practitioner; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; @@ -13,7 +12,7 @@ public class CustomThymeleafNarrativeGeneratorDstu2Test { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CustomThymeleafNarrativeGeneratorDstu2Test.class); - private FhirContext myCtx = FhirContext.forCached(FhirVersionEnum.DSTU2); + private final FhirContext myCtx = FhirContext.forDstu2Cached(); @AfterEach public void after() { diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorDstu2Test.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorDstu2Test.java index 58beb7f4a0b..f96f093cc9a 100644 --- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorDstu2Test.java +++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorDstu2Test.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.narrative; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.model.api.TemporalPrecisionEnum; import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt; import ca.uhn.fhir.model.dstu2.composite.QuantityDt; @@ -37,7 +36,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class DefaultThymeleafNarrativeGeneratorDstu2Test { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(DefaultThymeleafNarrativeGeneratorDstu2Test.class); - private final FhirContext myCtx = FhirContext.forCached(FhirVersionEnum.DSTU2); + private final FhirContext myCtx = FhirContext.forDstu2Cached(); private DefaultThymeleafNarrativeGenerator myGen; @BeforeEach diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorDstu3Test.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorDstu3Test.java index c5dceef79ac..c5827989db2 100644 --- a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorDstu3Test.java +++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorDstu3Test.java @@ -1,16 +1,27 @@ package ca.uhn.fhir.narrative; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.parser.DataFormatException; import ca.uhn.fhir.util.TestUtil; import org.apache.commons.collections.Transformer; import org.apache.commons.collections.map.LazyMap; import org.hamcrest.core.StringContains; -import org.hl7.fhir.dstu3.model.*; +import org.hl7.fhir.dstu3.model.CodeableConcept; +import org.hl7.fhir.dstu3.model.Coding; +import org.hl7.fhir.dstu3.model.DateTimeType; +import org.hl7.fhir.dstu3.model.DiagnosticReport; import org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus; +import org.hl7.fhir.dstu3.model.Medication; +import org.hl7.fhir.dstu3.model.MedicationRequest; import org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestStatus; +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.Patient; +import org.hl7.fhir.dstu3.model.Quantity; +import org.hl7.fhir.dstu3.model.Reference; +import org.hl7.fhir.dstu3.model.SimpleQuantity; +import org.hl7.fhir.dstu3.model.StringType; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -30,7 +41,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class DefaultThymeleafNarrativeGeneratorDstu3Test { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(DefaultThymeleafNarrativeGeneratorDstu3Test.class); - private final FhirContext myCtx = FhirContext.forCached(FhirVersionEnum.DSTU3); + private final FhirContext myCtx = FhirContext.forDstu3Cached(); private DefaultThymeleafNarrativeGenerator myGen; @BeforeEach diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/narrative/CustomThymeleafNarrativeGeneratorR4Test.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/narrative/CustomThymeleafNarrativeGeneratorR4Test.java index 957551d03c5..012552f7896 100644 --- a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/narrative/CustomThymeleafNarrativeGeneratorR4Test.java +++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/narrative/CustomThymeleafNarrativeGeneratorR4Test.java @@ -1,12 +1,9 @@ package ca.uhn.fhir.narrative; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; -import ca.uhn.fhir.util.TestUtil; import org.hl7.fhir.r4.model.Practitioner; import org.hl7.fhir.r4.model.Quantity; import org.hl7.fhir.r4.model.StringType; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; @@ -21,7 +18,7 @@ public class CustomThymeleafNarrativeGeneratorR4Test { /** * Don't use cached here since we modify the context */ - private final FhirContext myCtx = FhirContext.forCached(FhirVersionEnum.R4); + private final FhirContext myCtx = FhirContext.forR4Cached(); @AfterEach public void after() { diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorR4Test.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorR4Test.java index 4847d922123..b67f5e6ba3c 100644 --- a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorR4Test.java +++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorR4Test.java @@ -1,14 +1,25 @@ package ca.uhn.fhir.narrative; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.parser.DataFormatException; import ca.uhn.fhir.util.TestUtil; import org.hamcrest.core.StringContains; -import org.hl7.fhir.r4.model.*; +import org.hl7.fhir.r4.model.CodeableConcept; +import org.hl7.fhir.r4.model.Coding; +import org.hl7.fhir.r4.model.DateTimeType; +import org.hl7.fhir.r4.model.DiagnosticReport; import org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus; +import org.hl7.fhir.r4.model.Medication; +import org.hl7.fhir.r4.model.MedicationRequest; import org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus; +import org.hl7.fhir.r4.model.Observation; import org.hl7.fhir.r4.model.Observation.ObservationStatus; +import org.hl7.fhir.r4.model.OperationOutcome; +import org.hl7.fhir.r4.model.Patient; +import org.hl7.fhir.r4.model.Quantity; +import org.hl7.fhir.r4.model.Reference; +import org.hl7.fhir.r4.model.SimpleQuantity; +import org.hl7.fhir.r4.model.StringType; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -23,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class DefaultThymeleafNarrativeGeneratorR4Test { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(DefaultThymeleafNarrativeGeneratorR4Test.class); - private final FhirContext myCtx = FhirContext.forCached(FhirVersionEnum.R4); + private final FhirContext myCtx = FhirContext.forR4Cached(); private DefaultThymeleafNarrativeGenerator myGen; @BeforeEach @@ -115,7 +126,7 @@ public class DefaultThymeleafNarrativeGeneratorR4Test { Observation obs = new Observation(); obs.getCode().addCoding().setCode("1938HB").setDisplay("Hemoglobin"); obs.setValue(new Quantity(null, 2.223, null, null, "mg/L")); - obs.addReferenceRange().setLow((SimpleQuantity) new SimpleQuantity().setValue(2.20)).setHigh((SimpleQuantity) new SimpleQuantity().setValue(2.99)); + obs.addReferenceRange().setLow(new SimpleQuantity().setValue(2.20)).setHigh(new SimpleQuantity().setValue(2.99)); obs.setStatus(ObservationStatus.FINAL); obs.addNote().setText("This is a result comment"); diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/CapabilityStatementCacheR4Test.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/CapabilityStatementCacheR4Test.java index 426ecdb22d3..2df0330e34b 100644 --- a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/CapabilityStatementCacheR4Test.java +++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/CapabilityStatementCacheR4Test.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.rest.server; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.rest.annotation.Metadata; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.server.method.ConformanceMethodBinding; @@ -24,7 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class CapabilityStatementCacheR4Test { - private final FhirContext myFhirContext = FhirContext.forCached(FhirVersionEnum.R4); + private final FhirContext myFhirContext = FhirContext.forR4Cached(); @RegisterExtension protected final RestfulServerExtension myServerExtension = new RestfulServerExtension(myFhirContext) diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/CapabilityStatementCustomizationR4Test.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/CapabilityStatementCustomizationR4Test.java index 5be02c67f3d..a3aa25c673a 100644 --- a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/CapabilityStatementCustomizationR4Test.java +++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/CapabilityStatementCustomizationR4Test.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.rest.server; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.interceptor.api.Hook; import ca.uhn.fhir.interceptor.api.Interceptor; import ca.uhn.fhir.interceptor.api.Pointcut; @@ -20,7 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class CapabilityStatementCustomizationR4Test { - private final FhirContext myCtx = FhirContext.forCached(FhirVersionEnum.R4); + private final FhirContext myCtx = FhirContext.forR4Cached(); @Order(0) @RegisterExtension protected RestfulServerExtension myServerExtension = new RestfulServerExtension(myCtx); diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/ReadR4Test.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/ReadR4Test.java index dd76ccb61de..7bde8051f8b 100644 --- a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/ReadR4Test.java +++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/ReadR4Test.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.rest.server; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.model.primitive.InstantDt; import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.Read; @@ -38,7 +37,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class ReadR4Test { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ReadR4Test.class); private static CloseableHttpClient ourClient; - private final FhirContext myCtx = FhirContext.forCached(FhirVersionEnum.R4); + private final FhirContext myCtx = FhirContext.forR4Cached(); @RegisterExtension public RestfulServerExtension myRestfulServerExtension = new RestfulServerExtension(myCtx); private int myPort; diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/SearchPreferHandlingInterceptorTest.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/SearchPreferHandlingInterceptorTest.java index 53718bc6c2d..cae4b588b19 100644 --- a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/SearchPreferHandlingInterceptorTest.java +++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/SearchPreferHandlingInterceptorTest.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.rest.server; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum; import ca.uhn.fhir.model.valueset.BundleEntrySearchModeEnum; import ca.uhn.fhir.rest.annotation.OptionalParam; @@ -39,7 +38,7 @@ import static org.junit.jupiter.api.Assertions.fail; public class SearchPreferHandlingInterceptorTest { - private final FhirContext myCtx = FhirContext.forCached(FhirVersionEnum.R4); + private final FhirContext myCtx = FhirContext.forR4Cached(); @RegisterExtension public RestfulServerExtension myRestfulServerExtension = new RestfulServerExtension(myCtx) .registerProvider(new DummyPatientResourceProvider()) diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/SearchR4Test.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/SearchR4Test.java index 147f77a192a..ce6d5674cf9 100644 --- a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/SearchR4Test.java +++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/SearchR4Test.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.rest.server; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum; import ca.uhn.fhir.model.valueset.BundleEntrySearchModeEnum; @@ -17,9 +16,7 @@ import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; import ca.uhn.fhir.rest.gclient.StringClientParam; import ca.uhn.fhir.rest.param.TokenAndListParam; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; -import ca.uhn.fhir.test.utilities.JettyUtil; import ca.uhn.fhir.test.utilities.server.RestfulServerExtension; -import ca.uhn.fhir.util.TestUtil; import ca.uhn.fhir.util.UrlUtil; import ca.uhn.fhir.validation.FhirValidator; import ca.uhn.fhir.validation.ValidationResult; @@ -30,9 +27,6 @@ import org.apache.http.client.methods.HttpGet; 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.ServletHandler; -import org.eclipse.jetty.servlet.ServletHolder; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.HumanName; @@ -68,7 +62,7 @@ public class SearchR4Test { private static CloseableHttpClient ourClient; private static TokenAndListParam ourIdentifiers; private static String ourLastMethod; - private final FhirContext myCtx = FhirContext.forCached(FhirVersionEnum.R4); + private final FhirContext myCtx = FhirContext.forR4Cached(); @RegisterExtension public RestfulServerExtension myRestfulServerExtension = new RestfulServerExtension(myCtx) .registerProvider(new DummyPatientResourceProvider()) diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/ServerInvalidDefinitionR4Test.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/ServerInvalidDefinitionR4Test.java index eac229a77c8..3e108855982 100644 --- a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/ServerInvalidDefinitionR4Test.java +++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/server/ServerInvalidDefinitionR4Test.java @@ -1,8 +1,6 @@ package ca.uhn.fhir.rest.server; -import ca.uhn.fhir.context.ConfigurationException; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.rest.annotation.ConditionalUrlParam; import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.Operation; @@ -14,34 +12,23 @@ import ca.uhn.fhir.rest.annotation.Update; import ca.uhn.fhir.rest.annotation.Validate; import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.server.IBundleProvider; -import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.param.TokenParam; -import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; -import ca.uhn.fhir.rest.server.provider.ServerCapabilityStatementProvider; import ca.uhn.fhir.test.utilities.server.MockServletUtil; -import ca.uhn.fhir.util.TestUtil; import com.google.common.collect.Lists; import org.hamcrest.core.StringContains; import org.hl7.fhir.instance.model.api.IBaseResource; -import org.hl7.fhir.r4.model.CapabilityStatement; import org.hl7.fhir.r4.model.DateType; import org.hl7.fhir.r4.model.IdType; -import org.hl7.fhir.r4.model.OperationDefinition; import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.StringType; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Test; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; - import java.util.List; -import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; public class ServerInvalidDefinitionR4Test extends BaseR4ServerTest { @@ -208,7 +195,7 @@ public class ServerInvalidDefinitionR4Test extends BaseR4ServerTest { } - RestfulServer rs = new RestfulServer(FhirContext.forCached(FhirVersionEnum.R4)); + RestfulServer rs = new RestfulServer(FhirContext.forR4Cached()); rs.setProviders(new PlainProviderWithExtendedOperationOnNoType()); rs.setServerAddressStrategy(new HardcodedServerAddressStrategy("http://localhost/baseR4")); diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/util/FhirTerserR4Test.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/util/FhirTerserR4Test.java index d44b17812dc..c48d36cf793 100644 --- a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/util/FhirTerserR4Test.java +++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/util/FhirTerserR4Test.java @@ -3,7 +3,6 @@ package ca.uhn.fhir.util; import ca.uhn.fhir.context.BaseRuntimeChildDefinition; import ca.uhn.fhir.context.BaseRuntimeElementDefinition; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.model.api.annotation.Block; import ca.uhn.fhir.parser.DataFormatException; import com.google.common.collect.Lists; @@ -68,7 +67,7 @@ import static org.mockito.Mockito.when; public class FhirTerserR4Test { private static final Logger ourLog = LoggerFactory.getLogger(FhirTerserR4Test.class); - private final FhirContext myCtx = FhirContext.forCached(FhirVersionEnum.R4); + private final FhirContext myCtx = FhirContext.forR4Cached(); @Test public void testAddElement() { diff --git a/hapi-fhir-structures-r5/src/test/java/ca/uhn/fhir/rest/server/ServerCapabilityStatementProviderR5Test.java b/hapi-fhir-structures-r5/src/test/java/ca/uhn/fhir/rest/server/ServerCapabilityStatementProviderR5Test.java index baa2c7758fa..9bf0eda3f7a 100644 --- a/hapi-fhir-structures-r5/src/test/java/ca/uhn/fhir/rest/server/ServerCapabilityStatementProviderR5Test.java +++ b/hapi-fhir-structures-r5/src/test/java/ca/uhn/fhir/rest/server/ServerCapabilityStatementProviderR5Test.java @@ -1,12 +1,25 @@ package ca.uhn.fhir.rest.server; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.model.api.annotation.Description; import ca.uhn.fhir.model.api.annotation.ResourceDef; import ca.uhn.fhir.model.primitive.InstantDt; -import ca.uhn.fhir.rest.annotation.*; +import ca.uhn.fhir.rest.annotation.ConditionalUrlParam; +import ca.uhn.fhir.rest.annotation.Create; +import ca.uhn.fhir.rest.annotation.Delete; +import ca.uhn.fhir.rest.annotation.History; +import ca.uhn.fhir.rest.annotation.IdParam; +import ca.uhn.fhir.rest.annotation.IncludeParam; +import ca.uhn.fhir.rest.annotation.Operation; +import ca.uhn.fhir.rest.annotation.OperationParam; +import ca.uhn.fhir.rest.annotation.OptionalParam; +import ca.uhn.fhir.rest.annotation.Read; +import ca.uhn.fhir.rest.annotation.RequiredParam; +import ca.uhn.fhir.rest.annotation.ResourceParam; +import ca.uhn.fhir.rest.annotation.Search; +import ca.uhn.fhir.rest.annotation.Update; +import ca.uhn.fhir.rest.annotation.Validate; import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum; @@ -28,7 +41,8 @@ import ca.uhn.fhir.util.TestUtil; import ca.uhn.fhir.validation.ValidationResult; import com.google.common.collect.Lists; import org.hl7.fhir.instance.model.api.IBaseResource; -import org.hl7.fhir.r5.model.*; +import org.hl7.fhir.r5.model.Bundle; +import org.hl7.fhir.r5.model.CapabilityStatement; import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestComponent; import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceComponent; import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceOperationComponent; @@ -36,9 +50,18 @@ import org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResource import org.hl7.fhir.r5.model.CapabilityStatement.ConditionalDeleteStatus; import org.hl7.fhir.r5.model.CapabilityStatement.SystemRestfulInteraction; import org.hl7.fhir.r5.model.CapabilityStatement.TypeRestfulInteraction; +import org.hl7.fhir.r5.model.CodeType; +import org.hl7.fhir.r5.model.DateType; +import org.hl7.fhir.r5.model.DiagnosticReport; +import org.hl7.fhir.r5.model.Encounter; +import org.hl7.fhir.r5.model.Enumerations; import org.hl7.fhir.r5.model.Enumerations.PublicationStatus; +import org.hl7.fhir.r5.model.IdType; +import org.hl7.fhir.r5.model.OperationDefinition; import org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterComponent; import org.hl7.fhir.r5.model.OperationDefinition.OperationKind; +import org.hl7.fhir.r5.model.Patient; +import org.hl7.fhir.r5.model.StringType; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -70,7 +93,7 @@ import static org.mockito.Mockito.when; public class ServerCapabilityStatementProviderR5Test { - private final FhirContext myCtx = FhirContext.forCached(FhirVersionEnum.R5); + private final FhirContext myCtx = FhirContext.forR5Cached(); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ServerCapabilityStatementProviderR5Test.class); private HttpServletRequest createHttpServletRequest() { @@ -212,7 +235,7 @@ public class ServerCapabilityStatementProviderR5Test { rs.init(createServletConfig()); CapabilityStatement serverConformance = (CapabilityStatement) sc.getServerConformance(createHttpServletRequest(), createRequestDetails(rs)); - List formatCodes = serverConformance.getFormat().stream().map(c -> c.getCode()).collect(Collectors.toList());; + List formatCodes = serverConformance.getFormat().stream().map(c -> c.getCode()).collect(Collectors.toList()); assertThat(formatCodes, hasItem(Constants.FORMAT_XML)); assertThat(formatCodes, hasItem(Constants.FORMAT_JSON)); diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/InMemoryTerminologyServerValidationSupport.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/InMemoryTerminologyServerValidationSupport.java index 810414aaa2b..8ccc2bc9926 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/InMemoryTerminologyServerValidationSupport.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/InMemoryTerminologyServerValidationSupport.java @@ -370,7 +370,7 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu @Nullable private org.hl7.fhir.r5.model.ValueSet expandValueSetDstu2(ValidationSupportContext theValidationSupportContext, ca.uhn.fhir.model.dstu2.resource.ValueSet theInput, @Nullable String theWantSystemUrlAndVersion, @Nullable String theWantCode) { IParser parserRi = FhirContext.forCached(FhirVersionEnum.DSTU2_HL7ORG).newJsonParser(); - IParser parserHapi = FhirContext.forCached(FhirVersionEnum.DSTU2).newJsonParser(); + IParser parserHapi = FhirContext.forDstu2Cached().newJsonParser(); Function codeSystemLoader = t -> { ca.uhn.fhir.model.dstu2.resource.ValueSet codeSystem = theInput; @@ -408,9 +408,7 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu if (cs != null) { IPrimitiveType content = getFhirContext().newTerser().getSingleValueOrNull(cs, "content", IPrimitiveType.class); - if (!"not-present".equals(content.getValueAsString())) { - return true; - } + return !"not-present".equals(content.getValueAsString()); } return false; diff --git a/hapi-fhir-validation/src/test/java/ca/uhn/fhir/rest/server/ServerCapabilityStatementProviderR4Test.java b/hapi-fhir-validation/src/test/java/ca/uhn/fhir/rest/server/ServerCapabilityStatementProviderR4Test.java index ca366cab38a..daea5b0f1f7 100644 --- a/hapi-fhir-validation/src/test/java/ca/uhn/fhir/rest/server/ServerCapabilityStatementProviderR4Test.java +++ b/hapi-fhir-validation/src/test/java/ca/uhn/fhir/rest/server/ServerCapabilityStatementProviderR4Test.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.rest.server; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.jpa.model.util.JpaConstants; import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.model.api.annotation.Description; @@ -119,7 +118,7 @@ public class ServerCapabilityStatementProviderR4Test { public static final String PATIENT_SUB_SUB_2 = "PatientSubSub2"; public static final String PATIENT_TRIPLE_SUB = "PatientTripleSub"; private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ServerCapabilityStatementProviderR4Test.class); - private final FhirContext myCtx = FhirContext.forCached(FhirVersionEnum.R4); + private final FhirContext myCtx = FhirContext.forR4Cached(); private FhirValidator myValidator; private static Set toStrings(Collection theType) { diff --git a/hapi-fhir-validation/src/test/java/ca/uhn/fhir/rest/server/interceptor/ResponseTerminologyDisplayPopulationInterceptorTest.java b/hapi-fhir-validation/src/test/java/ca/uhn/fhir/rest/server/interceptor/ResponseTerminologyDisplayPopulationInterceptorTest.java index 65b5767d5cf..2b476d65a31 100644 --- a/hapi-fhir-validation/src/test/java/ca/uhn/fhir/rest/server/interceptor/ResponseTerminologyDisplayPopulationInterceptorTest.java +++ b/hapi-fhir-validation/src/test/java/ca/uhn/fhir/rest/server/interceptor/ResponseTerminologyDisplayPopulationInterceptorTest.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.rest.server.interceptor; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.ValidationSupportContext; import ca.uhn.fhir.rest.client.api.IGenericClient; @@ -21,7 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; public class ResponseTerminologyDisplayPopulationInterceptorTest { - private final FhirContext myCtx = FhirContext.forCached(FhirVersionEnum.R4); + private final FhirContext myCtx = FhirContext.forR4Cached(); @Order(0) @RegisterExtension protected RestfulServerExtension myServerExtension = new RestfulServerExtension(myCtx); diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyServiceTest.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyServiceTest.java index 863eac1fd4f..a099a68ac93 100644 --- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyServiceTest.java +++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyServiceTest.java @@ -1,7 +1,6 @@ package org.hl7.fhir.common.hapi.validation.support; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.context.support.ConceptValidationOptions; import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.ValidationSupportContext; @@ -168,7 +167,7 @@ public class CommonCodeSystemsTerminologyServiceTest { @Test public void testFetchCodeSystemBuiltIn_Iso3166_DSTU3() { - CommonCodeSystemsTerminologyService svc = new CommonCodeSystemsTerminologyService(FhirContext.forCached(FhirVersionEnum.DSTU3)); + CommonCodeSystemsTerminologyService svc = new CommonCodeSystemsTerminologyService(FhirContext.forDstu3Cached()); org.hl7.fhir.dstu3.model.CodeSystem cs = (org.hl7.fhir.dstu3.model.CodeSystem) svc.fetchCodeSystem(CommonCodeSystemsTerminologyService.COUNTRIES_CODESYSTEM_URL); assert cs != null; assertEquals(498, cs.getConcept().size()); @@ -176,7 +175,7 @@ public class CommonCodeSystemsTerminologyServiceTest { @Test public void testFetchCodeSystemBuiltIn_Iso3166_R5() { - CommonCodeSystemsTerminologyService svc = new CommonCodeSystemsTerminologyService(FhirContext.forCached(FhirVersionEnum.R5)); + CommonCodeSystemsTerminologyService svc = new CommonCodeSystemsTerminologyService(FhirContext.forR5Cached()); org.hl7.fhir.r5.model.CodeSystem cs = (org.hl7.fhir.r5.model.CodeSystem) svc.fetchCodeSystem(CommonCodeSystemsTerminologyService.COUNTRIES_CODESYSTEM_URL); assert cs != null; assertEquals(498, cs.getConcept().size()); @@ -184,7 +183,7 @@ public class CommonCodeSystemsTerminologyServiceTest { @Test public void testFetchCodeSystemBuiltIn_Iso3166_DSTU2() { - CommonCodeSystemsTerminologyService svc = new CommonCodeSystemsTerminologyService(FhirContext.forCached(FhirVersionEnum.DSTU2)); + CommonCodeSystemsTerminologyService svc = new CommonCodeSystemsTerminologyService(FhirContext.forDstu2Cached()); IBaseResource cs = svc.fetchCodeSystem(CommonCodeSystemsTerminologyService.COUNTRIES_CODESYSTEM_URL); assertEquals(null, cs); }