Search in sources :

Example 16 with StringParam

use of ca.uhn.fhir.rest.param.StringParam in project openmrs-module-fhir2 by openmrs.

the class FhirUserServiceImplTest method shouldReturnEmptyCollectionByWrongAddressCountry.

@Test
public void shouldReturnEmptyCollectionByWrongAddressCountry() {
    StringAndListParam country = new StringAndListParam().addAnd(new StringParam(WRONG_COUNTRY));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.COUNTRY_PROPERTY, country);
    when(dao.getSearchResultUuids(any())).thenReturn(Collections.emptyList());
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, translator, globalPropertyService, searchQueryInclude));
    IBundleProvider results = userService.searchForUsers(theParams);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, empty());
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 17 with StringParam

use of ca.uhn.fhir.rest.param.StringParam in project openmrs-module-fhir2 by openmrs.

the class FhirUserServiceImplTest method shouldSearchForUsersByName.

@Test
public void shouldSearchForUsersByName() {
    StringAndListParam name = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(USER_NAME)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(NAME_SEARCH_HANDLER, NAME_PROPERTY, name);
    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)));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 18 with StringParam

use of ca.uhn.fhir.rest.param.StringParam in project openmrs-module-fhir2 by openmrs.

the class FhirUserServiceImplTest method shouldSearchForUsersByAddressCountry.

@Test
public void shouldSearchForUsersByAddressCountry() {
    StringAndListParam country = new StringAndListParam().addAnd(new StringParam(COUNTRY));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(ADDRESS_SEARCH_HANDLER, COUNTRY_PROPERTY, country);
    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)));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 19 with StringParam

use of ca.uhn.fhir.rest.param.StringParam in project openmrs-module-fhir2 by openmrs.

the class FhirUserServiceImplTest method shouldReturnEmptyCollectionByWrongAddressPostalCode.

@Test
public void shouldReturnEmptyCollectionByWrongAddressPostalCode() {
    StringAndListParam postalCode = new StringAndListParam().addAnd(new StringParam(WRONG_POSTAL_CODE));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.POSTAL_CODE_PROPERTY, postalCode);
    when(dao.getSearchResultUuids(any())).thenReturn(Collections.emptyList());
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, translator, globalPropertyService, searchQueryInclude));
    IBundleProvider results = userService.searchForUsers(theParams);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, empty());
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 20 with StringParam

use of ca.uhn.fhir.rest.param.StringParam in project openmrs-module-fhir2 by openmrs.

the class FhirUserServiceImplTest method shouldsearchForUsersByAddressCity.

@Test
public void shouldsearchForUsersByAddressCity() {
    StringAndListParam city = new StringAndListParam().addAnd(new StringParam(CITY));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(ADDRESS_SEARCH_HANDLER, CITY_PROPERTY, city);
    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)));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Aggregations

StringParam (ca.uhn.fhir.rest.param.StringParam)271 Test (org.junit.Test)251 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)248 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)243 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)173 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)154 StringOrListParam (ca.uhn.fhir.rest.param.StringOrListParam)116 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)101 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)37 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)30 Practitioner (org.hl7.fhir.r4.model.Practitioner)26 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)21 Patient (org.hl7.fhir.r4.model.Patient)21 TokenParam (ca.uhn.fhir.rest.param.TokenParam)20 SimpleBundleProvider (ca.uhn.fhir.rest.server.SimpleBundleProvider)18 NumberParam (ca.uhn.fhir.rest.param.NumberParam)16 Observation (org.hl7.fhir.r4.model.Observation)16 Location (org.hl7.fhir.r4.model.Location)14 Person (org.hl7.fhir.r4.model.Person)14 SortSpec (ca.uhn.fhir.rest.api.SortSpec)13