From 5da282355330e3838adc33b4a7eec3096974c1a8 Mon Sep 17 00:00:00 2001 From: Ken Stevens Date: Wed, 22 Jan 2020 09:25:43 -0500 Subject: [PATCH] add negative test --- .../FhirResourceDaoDstu3SearchNoFtTest.java | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java index 1556b47ae9c..a692154f99b 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java @@ -3520,15 +3520,29 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test { loc.setPosition(position); String locId = myLocationDao.create(loc).getId().toUnqualifiedVersionless().getValue(); - double offset = 50.0; - SearchParameterMap map = myMatchUrlService.translateMatchUrl( - "Location?" + - Location.SP_NEAR + "=" + (latitude + offset) + ":" + (longitude - offset) + - "&" + - Location.SP_NEAR_DISTANCE + "=" + (offset * 2) + "|http://unitsofmeasure.org|km", myFhirCtx.getResourceDefinition("Location")); + { // In the box + double offset = 50.0; + SearchParameterMap map = myMatchUrlService.translateMatchUrl( + "Location?" + + Location.SP_NEAR + "=" + (latitude + offset) + ":" + (longitude - offset) + + "&" + + Location.SP_NEAR_DISTANCE + "=" + (offset * 2) + "|http://unitsofmeasure.org|km", myFhirCtx.getResourceDefinition("Location")); + + List ids = toUnqualifiedVersionlessIdValues(myLocationDao.search(map)); + assertThat(ids, contains(locId)); + } + { // Outside the box + double offset = 50.0; + SearchParameterMap map = myMatchUrlService.translateMatchUrl( + "Location?" + + Location.SP_NEAR + "=" + (latitude + offset) + ":" + (longitude - offset) + + "&" + + Location.SP_NEAR_DISTANCE + "=" + (offset / 2) + "|http://unitsofmeasure.org|km", myFhirCtx.getResourceDefinition("Location")); + + List ids = toUnqualifiedVersionlessIdValues(myLocationDao.search(map)); + assertThat(ids.size(), is(0)); + } - List ids = toUnqualifiedVersionlessIdValues(myLocationDao.search(map)); - assertThat(ids, contains(locId)); } @Test