use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method getLocationHistoryById_shouldReturnListOfResource.
@Test
public void getLocationHistoryById_shouldReturnListOfResource() {
IdType id = new IdType();
id.setValue(LOCATION_UUID);
when(locationService.get(LOCATION_UUID)).thenReturn(location);
List<Resource> resources = resourceProvider.getLocationHistoryById(id);
assertThat(resources, notNullValue());
assertThat(resources, not(empty()));
assertThat(resources.size(), equalTo(2));
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method searchLocations_shouldReturnMatchingBundleOfLocationsByUUID.
@Test
public void searchLocations_shouldReturnMatchingBundleOfLocationsByUUID() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(LOCATION_UUID));
when(locationService.searchForLocations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(uuid)), 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, uuid, 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).getId(), equalTo(LOCATION_UUID));
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method searchLocations_shouldAddRelatedResourcesWhenIncluded.
@Test
public void searchLocations_shouldAddRelatedResourcesWhenIncluded() {
HashSet<Include> includeSet = new HashSet<>();
includeSet.add(new Include("Location:partof"));
when(locationService.searchForLocations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(includeSet)), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Arrays.asList(location, new Location()), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchLocations(null, null, null, null, null, null, null, null, null, includeSet, null, null);
List<Location> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
assertThat(resultList.get(1).fhirType(), is(FhirConstants.LOCATION));
assertThat(resultList.size(), equalTo(2));
assertThat(resultList.get(0).getId(), equalTo(LOCATION_UUID));
}
use of org.hl7.fhir.r4.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 org.hl7.fhir.r4.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));
}
Aggregations