use of com.walmartlabs.concord.runtime.v2.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationSearchQueryTest method searchForLocations_shouldReturnCorrectLocationByParentCountry.
@Test
public void searchForLocations_shouldReturnCorrectLocationByParentCountry() {
ReferenceAndListParam parentLocation = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(LOCATION_PARENT_COUNTRY).setChain("address-country")));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.LOCATION_REFERENCE_SEARCH_HANDLER, parentLocation);
IBundleProvider locations = search(theParams);
List<Location> resultList = get(locations);
assertThat(locations, notNullValue());
assertThat(resultList, hasSize(equalTo(1)));
assertThat(resultList.get(0).getIdElement().getIdPart(), equalTo(LOCATION_UUID));
}
use of com.walmartlabs.concord.runtime.v2.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationSearchQueryTest method searchForLocations_shouldReturnCorrectLocationByCountry.
@Test
public void searchForLocations_shouldReturnCorrectLocationByCountry() {
StringAndListParam country = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(LOCATION_COUNTRY)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COUNTRY_SEARCH_HANDLER, country);
IBundleProvider locations = search(theParams);
assertThat(locations, notNullValue());
assertThat(locations.size(), equalTo(2));
List<Location> resultList = get(locations);
assertThat(resultList, hasSize(equalTo(2)));
assertThat(resultList.get(0).getAddress().getCountry(), equalTo(LOCATION_COUNTRY));
}
use of com.walmartlabs.concord.runtime.v2.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method searchLocations_shouldReturnMatchingBundleOfChainedLocationsByParentPostalCode.
@Test
public void searchLocations_shouldReturnMatchingBundleOfChainedLocationsByParentPostalCode() {
ReferenceAndListParam locationParentPostalCode = new ReferenceAndListParam();
locationParentPostalCode.addValue(new ReferenceOrListParam().add(new ReferenceParam().setValue("234-30100").setChain(Location.SP_ADDRESS_POSTALCODE)));
when(locationService.searchForLocations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(Matchers.is(locationParentPostalCode)), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(location), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchLocations(null, null, null, null, null, null, locationParentPostalCode, null, null, null, null, null);
assertThat(results, notNullValue());
List<Location> resultList = get(results);
assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
use of com.walmartlabs.concord.runtime.v2.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method updateLocation_shouldThrowInvalidRequestExceptionForMissingId.
@Test(expected = InvalidRequestException.class)
public void updateLocation_shouldThrowInvalidRequestExceptionForMissingId() {
Location noIdLocation = new Location();
when(locationService.update(LOCATION_UUID, noIdLocation)).thenThrow(InvalidRequestException.class);
resourceProvider.updateLocation(new IdType().setValue(LOCATION_UUID), noIdLocation);
}
use of com.walmartlabs.concord.runtime.v2.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method findLocationsByCountry_shouldReturnMatchingBundleOfLocations.
@Test
public void findLocationsByCountry_shouldReturnMatchingBundleOfLocations() {
StringAndListParam countryParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(COUNTRY)));
when(locationService.searchForLocations(isNull(), isNull(), argThat(Matchers.is(countryParam)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(location), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchLocations(null, null, countryParam, null, null, null, null, null, null, null, null, null);
assertThat(results, notNullValue());
List<Location> resultList = get(results);
assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(resultList.get(0).getAddress().getCountry(), equalTo(COUNTRY));
}
Aggregations