From c974e9283b0c12bdbf0970e03002a3670b742411 Mon Sep 17 00:00:00 2001 From: Ken Stevens Date: Tue, 10 Sep 2019 10:11:09 -0400 Subject: [PATCH] added search % now test --- .../provider/r5/ResourceProviderR5Test.java | 18 ++++++++++++++++++ ...java => InMemoryResourceMatcherR5Test.java} | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) rename hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/matcher/{InMemoryResourceMatcherTest.java => InMemoryResourceMatcherR5Test.java} (99%) diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r5/ResourceProviderR5Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r5/ResourceProviderR5Test.java index 82640c0c1a6..c7f92a47f1d 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r5/ResourceProviderR5Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r5/ResourceProviderR5Test.java @@ -5,7 +5,11 @@ import ca.uhn.fhir.jpa.search.SearchCoordinatorSvcImpl; import ca.uhn.fhir.jpa.util.TestUtil; import ca.uhn.fhir.parser.StrictErrorHandler; import ca.uhn.fhir.rest.client.interceptor.CapturingInterceptor; +import ca.uhn.fhir.util.UrlUtil; +import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r5.model.Bundle; +import org.hl7.fhir.r5.model.DateTimeType; +import org.hl7.fhir.r5.model.Observation; import org.hl7.fhir.r5.model.Patient; import org.junit.After; import org.junit.AfterClass; @@ -84,6 +88,20 @@ public class ResourceProviderR5Test extends BaseResourceProviderR5Test { } + @Test + public void testDateNowSyntax() { + Observation observation = new Observation(); + observation.setEffective(new DateTimeType("1965-08-09")); + IIdType oid = myObservationDao.create(observation).getId().toUnqualified(); + String nowParam = UrlUtil.escapeUrlParam("%now"); + Bundle output = ourClient + .search() + .byUrl("Observation?date=lt" + nowParam) + .returnBundle(Bundle.class) + .execute(); + List ids = output.getEntry().stream().map(t -> t.getResource().getIdElement().toUnqualified()).collect(Collectors.toList()); + assertThat(ids, containsInAnyOrder(oid)); + } @AfterClass public static void afterClassClearContext() { diff --git a/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/matcher/InMemoryResourceMatcherTest.java b/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/matcher/InMemoryResourceMatcherR5Test.java similarity index 99% rename from hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/matcher/InMemoryResourceMatcherTest.java rename to hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/matcher/InMemoryResourceMatcherR5Test.java index 4dde484952c..e51b0c69a01 100644 --- a/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/matcher/InMemoryResourceMatcherTest.java +++ b/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/matcher/InMemoryResourceMatcherR5Test.java @@ -30,7 +30,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; @RunWith(SpringRunner.class) -public class InMemoryResourceMatcherTest { +public class InMemoryResourceMatcherR5Test { public static final String OBSERVATION_DATE = "1970-10-17"; private static final String EARLY_DATE = "1965-08-09"; private static final String LATE_DATE = "2000-06-29";