use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method searchLocations_shouldReturnMatchingBundleOfChainedLocationsByParentState.
@Test
public void searchLocations_shouldReturnMatchingBundleOfChainedLocationsByParentState() {
ReferenceAndListParam locationParentState = new ReferenceAndListParam();
locationParentState.addValue(new ReferenceOrListParam().add(new ReferenceParam().setValue("najjanankumbi").setChain(Location.SP_ADDRESS_STATE)));
when(locationService.searchForLocations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(Matchers.is(locationParentState)), 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, locationParentState, null, null, null, null, null);
List<Location> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method findLocationsByCity_shouldReturnMatchingBundleOfLocations.
@Test
public void findLocationsByCity_shouldReturnMatchingBundleOfLocations() {
StringAndListParam cityParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(CITY)));
when(locationService.searchForLocations(isNull(), argThat(Matchers.is(cityParam)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(location), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchLocations(null, cityParam, null, null, null, null, null, null, null, null, null, null);
assertThat(results, notNullValue());
List<Location> resultList = get(results);
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
assertThat(resultList.get(0).getAddress().getCity(), equalTo(CITY));
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method getLocationHistoryById_shouldReturnProvenanceResources.
@Test
public void getLocationHistoryById_shouldReturnProvenanceResources() {
IdType id = new IdType();
id.setValue(LOCATION_UUID);
when(locationService.get(LOCATION_UUID)).thenReturn(location);
List<Resource> resources = resourceProvider.getLocationHistoryById(id);
assertThat(resources, not(empty()));
assertThat(resources.stream().findAny().isPresent(), is(true));
assertThat(resources.stream().findAny().get().getResourceType().name(), equalTo(Provenance.class.getSimpleName()));
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method updateLocation_shouldThrowInvalidRequestForMissingId.
@Test(expected = InvalidRequestException.class)
public void updateLocation_shouldThrowInvalidRequestForMissingId() {
Location noIdLocation = new Location();
when(locationService.update(eq(LOCATION_UUID), any(org.hl7.fhir.r4.model.Location.class))).thenThrow(InvalidRequestException.class);
resourceProvider.updateLocation(new IdType().setValue(LOCATION_UUID), noIdLocation);
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method searchLocations_shouldReturnMatchingBundleOfChainedLocationsByParentCity.
@Test
public void searchLocations_shouldReturnMatchingBundleOfChainedLocationsByParentCity() {
ReferenceAndListParam locationParentCity = new ReferenceAndListParam();
locationParentCity.addValue(new ReferenceOrListParam().add(new ReferenceParam().setValue("kampala").setChain(Location.SP_ADDRESS_CITY)));
when(locationService.searchForLocations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(Matchers.is(locationParentCity)), 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, locationParentCity, null, null, null, null, null);
List<Location> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Aggregations