add negative test

This commit is contained in:
Ken Stevens 2020-01-22 09:25:43 -05:00
parent 02a95115a4
commit 5da2823553
1 changed files with 22 additions and 8 deletions

View File

@ -3520,15 +3520,29 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
loc.setPosition(position); loc.setPosition(position);
String locId = myLocationDao.create(loc).getId().toUnqualifiedVersionless().getValue(); String locId = myLocationDao.create(loc).getId().toUnqualifiedVersionless().getValue();
double offset = 50.0; { // In the box
SearchParameterMap map = myMatchUrlService.translateMatchUrl( double offset = 50.0;
"Location?" + SearchParameterMap map = myMatchUrlService.translateMatchUrl(
Location.SP_NEAR + "=" + (latitude + offset) + ":" + (longitude - offset) + "Location?" +
"&" + Location.SP_NEAR + "=" + (latitude + offset) + ":" + (longitude - offset) +
Location.SP_NEAR_DISTANCE + "=" + (offset * 2) + "|http://unitsofmeasure.org|km", myFhirCtx.getResourceDefinition("Location")); "&" +
Location.SP_NEAR_DISTANCE + "=" + (offset * 2) + "|http://unitsofmeasure.org|km", myFhirCtx.getResourceDefinition("Location"));
List<String> 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<String> ids = toUnqualifiedVersionlessIdValues(myLocationDao.search(map));
assertThat(ids.size(), is(0));
}
List<String> ids = toUnqualifiedVersionlessIdValues(myLocationDao.search(map));
assertThat(ids, contains(locId));
} }
@Test @Test