Search in sources :

Example 1 with LocationTranslator

use of org.openmrs.module.fhir2.api.translators.LocationTranslator in project openmrs-module-fhir2 by openmrs.

the class FhirLocationServiceImplTest method searchForLocations_shouldReturnLocationsByParameters.

@Test
public void searchForLocations_shouldReturnLocationsByParameters() {
    List<org.openmrs.Location> locations = new ArrayList<>();
    locations.add(location);
    SearchParameterMap theParams = new SearchParameterMap();
    when(locationDao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(LOCATION_UUID));
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, locationDao, locationTranslator, globalPropertyService, searchQueryInclude));
    when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
    when(locationTranslator.toFhirResource(location)).thenReturn(fhirLocation);
    when(locationDao.getSearchResults(any(), any())).thenReturn(locations);
    IBundleProvider results = fhirLocationService.searchForLocations(null, null, null, null, null, null, null, null, null, null, null, null);
    assertThat(results, notNullValue());
    List<Location> resultList = get(results);
    assertThat(resultList, not(empty()));
    assertThat(resultList, hasItem(hasProperty("id", equalTo(LOCATION_UUID))));
}
Also used : ArrayList(java.util.ArrayList) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) Location(org.hl7.fhir.r4.model.Location) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Aggregations

IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)1 ArrayList (java.util.ArrayList)1 Location (org.hl7.fhir.r4.model.Location)1 Test (org.junit.Test)1 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)1