use of com.google.api.services.actions_fulfillment.v2.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method searchLocations_shouldNotAddRelatedResourcesForEmptyReverseInclude.
@Test
public void searchLocations_shouldNotAddRelatedResourcesForEmptyReverseInclude() {
HashSet<Include> revIncludeSet = new HashSet<>();
when(locationService.searchForLocations(isNull(), isNull(), 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, null, null, null, null, null, null, null, null, null, revIncludeSet, null);
List<Location> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
assertThat(resultList.size(), equalTo(1));
assertThat(resultList.get(0).getId(), equalTo(LOCATION_UUID));
}
use of com.google.api.services.actions_fulfillment.v2.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method findLocationsByName_shouldReturnMatchingBundleOfLocations.
@Test
public void findLocationsByName_shouldReturnMatchingBundleOfLocations() {
StringAndListParam nameParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(LOCATION_NAME)));
when(locationService.searchForLocations(argThat(Matchers.is(nameParam)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(location), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchLocations(nameParam, null, 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).getName(), equalTo(LOCATION_NAME));
}
use of com.google.api.services.actions_fulfillment.v2.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 com.google.api.services.actions_fulfillment.v2.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 com.google.api.services.actions_fulfillment.v2.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);
}
Aggregations