use of ca.uhn.fhir.rest.param.TokenAndListParam in project openmrs-module-fhir2 by openmrs.
the class FhirPractitionerServiceImplTest method shouldSearchForPractitionersByIdentifier.
@Test
public void shouldSearchForPractitionersByIdentifier() {
TokenAndListParam identifier = new TokenAndListParam().addAnd(new TokenOrListParam().add(IDENTIFIER));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.IDENTIFIER_SEARCH_HANDLER, identifier);
when(practitionerDao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(UUID));
when(practitionerDao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(provider));
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, practitionerDao, practitionerTranslator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
when(practitionerTranslator.toFhirResource(provider)).thenReturn(practitioner);
when(userService.searchForUsers(any())).thenReturn(new SimpleBundleProvider());
IBundleProvider results = practitionerService.searchForPractitioners(identifier, null, null, null, null, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
use of ca.uhn.fhir.rest.param.TokenAndListParam in project openmrs-module-fhir2 by openmrs.
the class FhirRelatedPersonServiceImplTest method searchForRelatedPeople_shouldReturnEmptyCollectionWhenRelatedPersonGenderNotMatched.
@Test
public void searchForRelatedPeople_shouldReturnEmptyCollectionWhenRelatedPersonGenderNotMatched() {
TokenAndListParam tokenAndListParam = new TokenAndListParam().addAnd(new TokenOrListParam().add(WRONG_GENDER));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.GENDER_SEARCH_HANDLER, tokenAndListParam);
when(dao.getSearchResultUuids(any())).thenReturn(Collections.emptyList());
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, translator, globalPropertyService, searchQueryInclude));
IBundleProvider results = relatedPersonService.searchForRelatedPeople(null, tokenAndListParam, null, null, null, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, empty());
}
use of ca.uhn.fhir.rest.param.TokenAndListParam in project openmrs-module-fhir2 by openmrs.
the class FhirServiceRequestServiceImplTest method searchForServiceRequest_shouldReturnCollectionOfServiceRequestByUUID.
@Test
public void searchForServiceRequest_shouldReturnCollectionOfServiceRequestByUUID() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(SERVICE_REQUEST_UUID));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid);
when(dao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(order));
when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(SERVICE_REQUEST_UUID));
when(translator.toFhirResource(order)).thenReturn(fhirServiceRequest);
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, translator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
IBundleProvider results = serviceRequestService.searchForServiceRequests(null, null, null, null, null, uuid, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, Matchers.notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
use of ca.uhn.fhir.rest.param.TokenAndListParam in project openmrs-module-fhir2 by openmrs.
the class FhirServiceRequestServiceImplTest method searchForServiceRequest_shouldReturnCollectionOfServiceRequestByCode.
@Test
public void searchForServiceRequest_shouldReturnCollectionOfServiceRequestByCode() {
TokenAndListParam code = new TokenAndListParam().addAnd(new TokenParam(CODE));
SearchParameterMap theParams = new SearchParameterMap();
theParams.addParameter(CODED_SEARCH_HANDLER, code);
when(dao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(order));
when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(SERVICE_REQUEST_UUID));
when(translator.toFhirResource(order)).thenReturn(fhirServiceRequest);
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, translator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
IBundleProvider results = serviceRequestService.searchForServiceRequests(null, code, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(equalTo(1)));
}
use of ca.uhn.fhir.rest.param.TokenAndListParam in project openmrs-module-fhir2 by openmrs.
the class FhirUserServiceImplTest method shouldsearchForUsersByIdentifier.
@Test
public void shouldsearchForUsersByIdentifier() {
TokenAndListParam identifier = new TokenAndListParam().addAnd(new TokenOrListParam().add(USER_SYSTEM_ID));
SearchParameterMap theParams = new SearchParameterMap().addParameter(IDENTIFIER_SEARCH_HANDLER, identifier);
when(dao.getSearchResultUuids(any())).thenReturn(singletonList(USER_UUID));
when(dao.getSearchResults(any(), any())).thenReturn(singletonList(user));
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, translator, globalPropertyService, searchQueryInclude));
when(translator.toFhirResource(user)).thenReturn(practitioner);
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
IBundleProvider results = userService.searchForUsers(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Aggregations