From 7d7865ab17725321a863d4b9d6d9f21d60939ba7 Mon Sep 17 00:00:00 2001 From: michaelabuckley Date: Wed, 10 Nov 2021 16:07:36 -0500 Subject: [PATCH] Mb share jpa date tests (#3154) * publish test-jar from hapi-fhir-storage * Extract BaseDateSearchDaoTests up to hapi-fhir-storage. Share a date search tests between JPA and Mongo. * Use ITestDataBuilder for setup * Move Mongo date cases into common set * cleanup * More cleanup * naming --- hapi-fhir-jpaserver-base/pom.xml | 8 + .../search/ExtendedLuceneIndexExtractor.java | 3 +- .../fhir/jpa/dao/BaseDAODateSearchTest.java | 106 -------------- ...rResourceDaoR4LegacySearchBuilderTest.java | 19 +-- ...rceDaoR4LuceneDisabledStandardQueries.java | 28 ++-- hapi-fhir-storage/pom.xml | 19 +++ .../fhir/jpa/dao/BaseDateSearchDaoTests.java | 137 ++++++++++++++++++ .../uhn/fhir/jpa/dao/DaoTestDataBuilder.java | 42 ++++++ .../jpa/conformance/DateSearchTestCase.java | 13 +- .../fhir/test/utilities/ITestDataBuilder.java | 7 + .../DateSearchTestCase-compact.csv | 3 + pom.xml | 2 +- 12 files changed, 242 insertions(+), 145 deletions(-) delete mode 100644 hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseDAODateSearchTest.java create mode 100644 hapi-fhir-storage/src/test/java/ca/uhn/fhir/jpa/dao/BaseDateSearchDaoTests.java create mode 100644 hapi-fhir-storage/src/test/java/ca/uhn/fhir/jpa/dao/DaoTestDataBuilder.java diff --git a/hapi-fhir-jpaserver-base/pom.xml b/hapi-fhir-jpaserver-base/pom.xml index 5c5fb880f5d..c965058c337 100644 --- a/hapi-fhir-jpaserver-base/pom.xml +++ b/hapi-fhir-jpaserver-base/pom.xml @@ -156,6 +156,14 @@ ${project.version} test + + ca.uhn.hapi.fhir + hapi-fhir-storage + ${project.version} + tests + test-jar + test + ch.qos.logback diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/search/ExtendedLuceneIndexExtractor.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/search/ExtendedLuceneIndexExtractor.java index 164d252e3a8..4872085ce72 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/search/ExtendedLuceneIndexExtractor.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/search/ExtendedLuceneIndexExtractor.java @@ -46,7 +46,6 @@ public class ExtendedLuceneIndexExtractor { @NotNull public ExtendedLuceneIndexData extract(ResourceIndexedSearchParams theNewParams) { - // wip mb this is testable now. ExtendedLuceneIndexData retVal = new ExtendedLuceneIndexData(myContext); theNewParams.myStringParams.forEach(nextParam -> @@ -59,7 +58,7 @@ public class ExtendedLuceneIndexExtractor { // awkwardly, links are shared between different search params if they use the same path, // so we re-build the linkage. - // WIP MB is this the right design? Or should we follow JPA and share these? + // WIPMB is this the right design? Or should we follow JPA and share these? Map> linkPathToParamName = new HashMap<>(); for (String nextParamName : theNewParams.getPopulatedResourceLinkParameters()) { RuntimeSearchParam sp = myParams.get(nextParamName); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseDAODateSearchTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseDAODateSearchTest.java deleted file mode 100644 index 74158a278ed..00000000000 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseDAODateSearchTest.java +++ /dev/null @@ -1,106 +0,0 @@ -package ca.uhn.fhir.jpa.dao; - -import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; -import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome; -import ca.uhn.fhir.jpa.conformance.DateSearchTestCase; -import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; -import ca.uhn.fhir.rest.api.server.IBundleProvider; -import ca.uhn.fhir.rest.param.DateParam; -import ca.uhn.fhir.util.FhirTerser; -import org.hl7.fhir.instance.model.api.IBaseResource; -import org.hl7.fhir.instance.model.api.IIdType; -import org.hl7.fhir.r4.model.Observation; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.transaction.support.TransactionCallback; - -import java.util.List; -import java.util.stream.Collectors; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Run the tests defined in {@link DateSearchTestCase} in a DAO test as a @Nested suite. - */ -public abstract class BaseDAODateSearchTest { - private static final Logger ourLog = LoggerFactory.getLogger(BaseDAODateSearchTest.class); - - /** Id of test Observation */ - IIdType myObservationId; - - /** - * Test for our date search operators. - *

- * Be careful - date searching is defined by set relations over intervals, not a simple number comparison. - * See http://hl7.org/fhir/search.html#prefix for details. - *

- * - * @param theResourceDate the date to use as Observation effective date - * @param theQuery the query parameter value including prefix (e.g. eq2020-01-01) - * @param theExpectedMatch true if tdheQuery should match theResourceDate. - */ - @ParameterizedTest - // use @CsvSource to debug individual cases. - //@CsvSource("2019-12-31T08:00:00,eq2020,false,inline,1") - @MethodSource("dateSearchCases") - public void testDateSearchMatching(String theResourceDate, String theQuery, Boolean theExpectedMatch, String theFileName, int theLineNumber) { - if (isShouldSkip(theResourceDate, theQuery)) { - return; - } - // setup - createObservationWithEffectiveDate(theResourceDate); - - // run the query - boolean matched = isSearchMatch(theQuery); - - String message = - "Expected " + theQuery + " to " + - (theExpectedMatch ? "" : "not ") + "match " + theResourceDate + - " (" + theFileName + ":" + theLineNumber + ")"; // wrap this in () so tools recognize the line reference. - assertEquals(theExpectedMatch, matched, message); - } - - protected boolean isShouldSkip(String theResourceDate, String theQuery) { - return false; - } - - // we need these from the test container - abstract protected FhirContext getMyFhirCtx(); - abstract protected T doInTransaction(TransactionCallback daoMethodOutcomeTransactionCallback); - abstract protected IFhirResourceDao getObservationDao(); - - protected void createObservationWithEffectiveDate(String theResourceDate) { - IBaseResource obs = getMyFhirCtx().getResourceDefinition("Observation").newInstance(); - FhirTerser fhirTerser = getMyFhirCtx().newTerser(); - fhirTerser.addElement(obs, "effectiveDateTime", theResourceDate); - ourLog.info("obs {}", getMyFhirCtx().newJsonParser().encodeResourceToString(obs)); - - DaoMethodOutcome createOutcome = doInTransaction(s -> getObservationDao().create(obs)); - myObservationId = createOutcome.getId(); - } - - /** - * Does the query string match the observation created during setup? - */ - protected boolean isSearchMatch(String theQuery) { - SearchParameterMap map = SearchParameterMap.newSynchronous(); - map.add(Observation.SP_DATE, new DateParam(theQuery)); - ourLog.info("Searching for observation {}", map); - - IBundleProvider results = getObservationDao().search(map); - - boolean matched = results.getAllResourceIds().contains(myObservationId.getIdPart()); - return matched; - } - - static List dateSearchCases() { - return DateSearchTestCase.ourCases.stream() - .map(DateSearchTestCase::toArguments) - .collect(Collectors.toList()); - } - -} diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4LegacySearchBuilderTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4LegacySearchBuilderTest.java index d8f42d12e88..6bd6dc63509 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4LegacySearchBuilderTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4LegacySearchBuilderTest.java @@ -1,13 +1,11 @@ package ca.uhn.fhir.jpa.dao.r4; -import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.interceptor.api.HookParams; import ca.uhn.fhir.interceptor.api.IAnonymousInterceptor; import ca.uhn.fhir.interceptor.api.Pointcut; import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; -import ca.uhn.fhir.jpa.dao.BaseDAODateSearchTest; +import ca.uhn.fhir.jpa.dao.BaseDateSearchDaoTests; import ca.uhn.fhir.jpa.entity.Search; import ca.uhn.fhir.jpa.model.config.PartitionSettings; import ca.uhn.fhir.jpa.model.entity.ModelConfig; @@ -5316,8 +5314,7 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { } @Nested - public class DateSearchTests extends BaseDAODateSearchTest { - + public class DateSearchTests extends BaseDateSearchDaoTests { /** * legacy builder didn't get the year/month date search fixes, so skip anything wider than a day. */ @@ -5328,16 +5325,8 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { } @Override - protected FhirContext getMyFhirCtx() { - return myFhirCtx; - } - @Override - protected T doInTransaction(TransactionCallback theCallback) { - return new TransactionTemplate(myTxManager).execute(theCallback); - } - @Override - protected IFhirResourceDao getObservationDao() { - return myObservationDao; + protected Fixture getFixture() { + return new TestDataBuilderFixture(FhirResourceDaoR4LegacySearchBuilderTest.this, myObservationDao); } } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4LuceneDisabledStandardQueries.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4LuceneDisabledStandardQueries.java index b754c635dca..71719b784a6 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4LuceneDisabledStandardQueries.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4LuceneDisabledStandardQueries.java @@ -1,10 +1,13 @@ package ca.uhn.fhir.jpa.dao.r4; import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; import ca.uhn.fhir.jpa.config.TestR4WithLuceneDisabledConfig; -import ca.uhn.fhir.jpa.dao.BaseDAODateSearchTest; +import ca.uhn.fhir.jpa.dao.BaseDateSearchDaoTests; import ca.uhn.fhir.jpa.dao.BaseJpaTest; +import ca.uhn.fhir.jpa.dao.DaoTestDataBuilder; +import ca.uhn.fhir.jpa.partition.SystemRequestDetails; import org.hl7.fhir.r4.model.Observation; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.extension.ExtendWith; @@ -16,8 +19,6 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.support.TransactionCallback; -import org.springframework.transaction.support.TransactionTemplate; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -33,6 +34,8 @@ public class FhirResourceDaoR4LuceneDisabledStandardQueries extends BaseJpaTest @Autowired @Qualifier("myObservationDaoR4") IFhirResourceDao myObservationDao; + @Autowired + protected DaoRegistry myDaoRegistry; @Override protected PlatformTransactionManager getTxManager() { @@ -45,22 +48,11 @@ public class FhirResourceDaoR4LuceneDisabledStandardQueries extends BaseJpaTest } @Nested - public class DateSearchTests extends BaseDAODateSearchTest { + public class DateSearchTests extends BaseDateSearchDaoTests { @Override - protected FhirContext getMyFhirCtx() { - return myFhirCtx; - } - - @Override - protected T doInTransaction(TransactionCallback theCallback) { - return new TransactionTemplate(myTxManager).execute( - theCallback - ); - } - - @Override - protected IFhirResourceDao getObservationDao() { - return myObservationDao; + protected Fixture getFixture() { + DaoTestDataBuilder testDataBuilder = new DaoTestDataBuilder(myFhirCtx, myDaoRegistry, new SystemRequestDetails()); + return new TestDataBuilderFixture<>(testDataBuilder, myObservationDao); } } diff --git a/hapi-fhir-storage/pom.xml b/hapi-fhir-storage/pom.xml index 4262e0cad03..ea2946fdc0a 100644 --- a/hapi-fhir-storage/pom.xml +++ b/hapi-fhir-storage/pom.xml @@ -75,6 +75,13 @@ hapi-fhir-jpaserver-searchparam ${project.version} + + ca.uhn.hapi.fhir + hapi-fhir-test-utilities + ${project.version} + test + + org.hibernate.search hibernate-search-mapper-orm @@ -151,6 +158,18 @@ + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + + test-jar + + + + org.jacoco jacoco-maven-plugin diff --git a/hapi-fhir-storage/src/test/java/ca/uhn/fhir/jpa/dao/BaseDateSearchDaoTests.java b/hapi-fhir-storage/src/test/java/ca/uhn/fhir/jpa/dao/BaseDateSearchDaoTests.java new file mode 100644 index 00000000000..6b36749cb7c --- /dev/null +++ b/hapi-fhir-storage/src/test/java/ca/uhn/fhir/jpa/dao/BaseDateSearchDaoTests.java @@ -0,0 +1,137 @@ +package ca.uhn.fhir.jpa.dao; + +import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; +import ca.uhn.fhir.jpa.conformance.DateSearchTestCase; +import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; +import ca.uhn.fhir.rest.api.server.IBundleProvider; +import ca.uhn.fhir.rest.param.DateParam; +import ca.uhn.fhir.test.utilities.ITestDataBuilder; +import org.hl7.fhir.instance.model.api.IBaseResource; +import org.hl7.fhir.instance.model.api.IIdType; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; +import java.util.stream.Collectors; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Run the tests defined in {@link DateSearchTestCase} in a DAO test as a @Nested suite. + */ +public abstract class BaseDateSearchDaoTests { + private static final Logger ourLog = LoggerFactory.getLogger(BaseDateSearchDaoTests.class); + + /** + * Id of test Observation + */ + IIdType myObservationId; + + + /** + * Test for our date search operators. + *

+ * Be careful - date searching is defined by set relations over intervals, not a simple number comparison. + * See http://hl7.org/fhir/search.html#prefix for details. + *

+ * To debug, uncomment the @CsvSource line and comment @MethodSource to run a single case + * + * + * @param theResourceDate the date to use as Observation effective date + * @param theQuery the query parameter value including prefix (e.g. eq2020-01-01) + * @param theExpectedMatch true if theQuery should match theResourceDate. + * @param theFileName source file for test case + * @param theLineNumber source file line number for test case (-1 for inline tests) + */ + @ParameterizedTest + // use @CsvSource to debug individual cases. + //@CsvSource("2019-12-31T08:00:00,eq2020,false,inline,1") + @MethodSource("dateSearchCases") + public void testDateSearchMatching(String theResourceDate, String theQuery, boolean theExpectedMatch, String theFileName, int theLineNumber) { + Fixture fixture = getFixture(); + if (isShouldSkip(theResourceDate, theQuery)) { + return; + } + + // setup + myObservationId = fixture.createObservationWithEffectiveDate(theResourceDate); + + // run the query + boolean matched = fixture.isObservationSearchMatch(theQuery, myObservationId); + + assertExpectedMatch(theResourceDate, theQuery, theExpectedMatch, matched, theFileName, theLineNumber); + } + + + protected boolean isShouldSkip(String theResourceDate, String theQuery) { + return false; + } + + protected static void assertExpectedMatch(String theResourceDate, String theQuery, boolean theExpectedMatch, boolean matched, String theFileName, int theLineNumber) { + String message = + "Expected " + theQuery + " to " + + (theExpectedMatch ? "" : "not ") + "match " + theResourceDate + + " (" + theFileName + ":" + theLineNumber + ")"; // wrap this in () so tools recognize the line reference. + assertEquals(theExpectedMatch, matched, message); + } + + + /** + * Turn the cases into expanded arguments for better reporting output and debugging + */ + public static List dateSearchCases() { + return DateSearchTestCase.ourCases.stream() + .map(DateSearchTestCase::toArguments) + .collect(Collectors.toList()); + } + + /** + * Helper to provide local setup and query services. + * + * Use an abstract method instead of a constructor because JUnit has a such a funky lifecycle. + */ + protected abstract Fixture getFixture(); + + public interface Fixture { + /** + * Create an observation and save it + */ + IIdType createObservationWithEffectiveDate(String theResourceDate); + + /** + * Does date=theQuery match theObservationId created + */ + boolean isObservationSearchMatch(String theQuery, IIdType theObservationId); + + } + + public static class TestDataBuilderFixture implements Fixture { + final ITestDataBuilder myTestDataBuilder; + final IFhirResourceDao myObservationDao; + + public TestDataBuilderFixture(ITestDataBuilder theTestDataBuilder, IFhirResourceDao theObservationDao) { + myTestDataBuilder = theTestDataBuilder; + myObservationDao = theObservationDao; + } + + @Override + public IIdType createObservationWithEffectiveDate(String theResourceDate) { + return myTestDataBuilder.createObservation(myTestDataBuilder.withEffectiveDate(theResourceDate)); + } + + @Override + public boolean isObservationSearchMatch(String theQuery, IIdType theObservationId) { + SearchParameterMap map = SearchParameterMap.newSynchronous(); + map.add("date", new DateParam(theQuery)); + ourLog.info("Searching for observation {}", map); + + IBundleProvider results = myObservationDao.search(map); + + boolean matched = results.getAllResourceIds().contains(theObservationId.getIdPart()); + return matched; + } + } +} diff --git a/hapi-fhir-storage/src/test/java/ca/uhn/fhir/jpa/dao/DaoTestDataBuilder.java b/hapi-fhir-storage/src/test/java/ca/uhn/fhir/jpa/dao/DaoTestDataBuilder.java new file mode 100644 index 00000000000..411a366ac7d --- /dev/null +++ b/hapi-fhir-storage/src/test/java/ca/uhn/fhir/jpa/dao/DaoTestDataBuilder.java @@ -0,0 +1,42 @@ +package ca.uhn.fhir.jpa.dao; + +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.jpa.api.dao.DaoRegistry; +import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; +import ca.uhn.fhir.jpa.partition.SystemRequestDetails; +import ca.uhn.fhir.test.utilities.ITestDataBuilder; +import org.hl7.fhir.instance.model.api.IBaseResource; +import org.hl7.fhir.instance.model.api.IIdType; + +public class DaoTestDataBuilder implements ITestDataBuilder { + final FhirContext myFhirCtx; + final DaoRegistry myDaoRegistry; + SystemRequestDetails mySrd; + + public DaoTestDataBuilder(FhirContext theFhirCtx, DaoRegistry theDaoRegistry, SystemRequestDetails theSrd) { + myFhirCtx = theFhirCtx; + myDaoRegistry = theDaoRegistry; + mySrd = theSrd; + } + + @Override + public IIdType doCreateResource(IBaseResource theResource) { + //noinspection rawtypes + IFhirResourceDao dao = myDaoRegistry.getResourceDao(theResource.getClass()); + //noinspection unchecked + return dao.create(theResource, mySrd).getId().toUnqualifiedVersionless(); + } + + @Override + public IIdType doUpdateResource(IBaseResource theResource) { + //noinspection rawtypes + IFhirResourceDao dao = myDaoRegistry.getResourceDao(theResource.getClass()); + //noinspection unchecked + return dao.update(theResource, mySrd).getId().toUnqualifiedVersionless(); + } + + @Override + public FhirContext getFhirContext() { + return myFhirCtx; + } +} diff --git a/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/jpa/conformance/DateSearchTestCase.java b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/jpa/conformance/DateSearchTestCase.java index ca611defee9..33b03d34d69 100644 --- a/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/jpa/conformance/DateSearchTestCase.java +++ b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/jpa/conformance/DateSearchTestCase.java @@ -30,6 +30,7 @@ import java.io.InputStreamReader; import java.io.LineNumberReader; import java.io.Reader; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Set; @@ -68,17 +69,23 @@ public class DateSearchTestCase { */ public final static List ourCases; static { + ourCases = new ArrayList<>(); + ourCases.addAll(expandedCases()); + ourCases.addAll(compactCases()); + } + + private static List expandedCases() { String csv = "DateSearchTestCase.csv"; InputStream resource = DateSearchTestCase.class.getResourceAsStream(csv); assert resource != null; InputStreamReader inputStreamReader = new InputStreamReader(resource, StandardCharsets.UTF_8); - ourCases = parseCsvCases(inputStreamReader, csv); + List cases = parseCsvCases(inputStreamReader, csv); try { resource.close(); } catch (IOException e) { e.printStackTrace(); } - ourCases.addAll(compactCases()); + return cases; } static List parseCsvCases(Reader theSource, String theFileName) { @@ -122,7 +129,7 @@ public class DateSearchTestCase { String resourceValue = fields[0].trim(); String truePrefixes = fields[1].trim(); String queryValue = fields[2].trim(); - Set expectedTruePrefixes = Arrays.stream(truePrefixes.split(" +")).map(String::trim).collect(Collectors.toSet()); + Set expectedTruePrefixes = Arrays.stream(truePrefixes.split("\\s+")).map(String::trim).collect(Collectors.toSet()); // expand to one test case per supportedPrefixes return supportedPrefixes.stream() diff --git a/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/ITestDataBuilder.java b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/ITestDataBuilder.java index 7338eb60364..54e79c27ca9 100644 --- a/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/ITestDataBuilder.java +++ b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/ITestDataBuilder.java @@ -86,6 +86,13 @@ public interface ITestDataBuilder { return t -> __setPrimitiveChild(getFhirContext(), t, "status", "code", theStatus); } + /** + * Set Observation.effectiveDate + */ + default Consumer withEffectiveDate(String theDate) { + return t -> __setPrimitiveChild(getFhirContext(), t, "effectiveDateTime", "dateTime", theDate); + } + /** * Set [Resource].identifier.system and [Resource].identifier.value */ diff --git a/hapi-fhir-test-utilities/src/main/resources/ca/uhn/fhir/jpa/conformance/DateSearchTestCase-compact.csv b/hapi-fhir-test-utilities/src/main/resources/ca/uhn/fhir/jpa/conformance/DateSearchTestCase-compact.csv index 49a169909a4..50ac7344212 100644 --- a/hapi-fhir-test-utilities/src/main/resources/ca/uhn/fhir/jpa/conformance/DateSearchTestCase-compact.csv +++ b/hapi-fhir-test-utilities/src/main/resources/ca/uhn/fhir/jpa/conformance/DateSearchTestCase-compact.csv @@ -3,3 +3,6 @@ 2021, gt ge ne,2020, 2020, lt le ne,2021, 2021-01-01, ne gt ge,2020 +1965-08-09, ne gt ge, 1918-11-11 +1965-08-09, eq le ge, 1965-08-09 +1965-08-09, ne lt le, 2020-12-08 diff --git a/pom.xml b/pom.xml index ee492b8de52..bf08df39611 100644 --- a/pom.xml +++ b/pom.xml @@ -2913,7 +2913,7 @@ FASTINSTALL - true + true