use of ca.uhn.fhir.rest.param.StringOrListParam in project openmrs-module-fhir2 by openmrs.
the class SearchParameterMapTest method shouldAddStringOrListParamIntoAnExistingMapUsingTheSameKeyValue.
@Test
public void shouldAddStringOrListParamIntoAnExistingMapUsingTheSameKeyValue() {
StringOrListParam orListParam1 = new StringOrListParam();
orListParam1.addOr(new StringParam("Clement"));
StringOrListParam orListParam2 = new StringOrListParam();
orListParam2.addOr(new StringParam("Jane"));
searchParam.addParameter(NAME, orListParam1);
searchParam.addParameter(NAME, orListParam2);
assertThat(searchParam, notNullValue());
assertThat(searchParam.getParameters(NAME), not(empty()));
assertThat(searchParam.getParameters(NAME), hasSize(is(2)));
}
use of ca.uhn.fhir.rest.param.StringOrListParam in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonFhirResourceProviderTest method searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByPostalCode.
@Test
public void searchForRelatedPeople_shouldReturnMatchingBundleOfRelatedPeopleByPostalCode() {
StringAndListParam postalCodeParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(POSTAL_CODE)));
when(relatedPersonService.searchForRelatedPeople(isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(postalCodeParam)), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(relatedPerson), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchRelatedPerson(null, null, null, null, null, postalCodeParam, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, Matchers.notNullValue());
assertThat(resultList.iterator().next().fhirType(), equalTo(FhirConstants.RELATED_PERSON));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
use of ca.uhn.fhir.rest.param.StringOrListParam in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method findLocationsByPostalCode_shouldReturnMatchingBundleOfLocations.
@Test
public void findLocationsByPostalCode_shouldReturnMatchingBundleOfLocations() {
StringAndListParam postalCodeParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(POSTAL_CODE)));
when(locationService.searchForLocations(isNull(), isNull(), isNull(), argThat(Matchers.is(postalCodeParam)), 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, postalCodeParam, null, null, null, null, null, null, null, null);
assertThat(results, notNullValue());
List<Location> resultList = get(results);
assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
assertThat(resultList, hasSize(equalTo(1)));
assertThat(resultList.get(0).getAddress().getPostalCode(), equalTo(POSTAL_CODE));
}
use of ca.uhn.fhir.rest.param.StringOrListParam 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);
List<Location> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(resultList.get(0).getName(), equalTo(LOCATION_NAME));
}
use of ca.uhn.fhir.rest.param.StringOrListParam in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method searchLocations_shouldReturnMatchingBundleOfLocations.
@Test
public void searchLocations_shouldReturnMatchingBundleOfLocations() {
List<Location> locations = new ArrayList<>();
locations.add(location);
when(locationService.searchForLocations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(locations, PREFERRED_PAGE_SIZE, COUNT));
StringAndListParam location = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(LOCATION_NAME)));
IBundleProvider resultLocations = resourceProvider.searchLocations(location, null, null, null, null, null, null, null, null, null, null, null);
assertThat(resultLocations, notNullValue());
List<Location> resultList = get(resultLocations);
assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
assertThat(resultList, hasSize(equalTo(1)));
assertThat(resultList.get(0).getId(), equalTo(LOCATION_UUID));
}
Aggregations