use of org.openmrs.module.fhir2.api.translators.PersonTranslator in project openmrs-module-fhir2 by openmrs.
the class FhirPersonServiceImplTest method searchForPeople_shouldReturnCollectionOfPersonWhenPersonCityMatched.
@Test
public void searchForPeople_shouldReturnCollectionOfPersonWhenPersonCityMatched() {
StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(CITY)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.CITY_PROPERTY, stringAndListParam);
when(dao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(person));
when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(PERSON_UUID));
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, personTranslator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
when(personTranslator.toFhirResource(person)).thenReturn(fhirPerson);
IBundleProvider results = personService.searchForPeople(null, null, null, stringAndListParam, null, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Aggregations