use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderTest method searchForPeople_shouldNotAddRelatedResourcesForEmptyInclude.
@Test
public void searchForPeople_shouldNotAddRelatedResourcesForEmptyInclude() {
HashSet<Include> includes = new HashSet<>();
when(fhirPersonService.searchForPeople(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(person), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchPeople(null, null, null, null, null, null, null, null, null, null, includes);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.get(0).fhirType(), is(FhirConstants.PERSON));
assertThat(resultList.size(), equalTo(1));
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderTest method searchForPeople_shouldReturnMatchingBundleOfPeopleByState.
@Test
public void searchForPeople_shouldReturnMatchingBundleOfPeopleByState() {
StringAndListParam stateParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(STATE)));
when(fhirPersonService.searchForPeople(isNull(), isNull(), isNull(), isNull(), argThat(is(stateParam)), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(person), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchPeople(null, null, null, null, stateParam, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.iterator().next().fhirType(), is(FhirConstants.PERSON));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderTest method deletePerson_shouldDeletePerson.
@Test
public void deletePerson_shouldDeletePerson() {
when(fhirPersonService.delete(PERSON_UUID)).thenReturn(person);
OperationOutcome result = resourceProvider.deletePerson(new IdType().setValue(PERSON_UUID));
assertThat(result, notNullValue());
assertThat(result.getIssueFirstRep().getSeverity(), equalTo(OperationOutcome.IssueSeverity.INFORMATION));
assertThat(result.getIssueFirstRep().getDetails().getCodingFirstRep().getCode(), equalTo("MSG_DELETED"));
assertThat(result.getIssueFirstRep().getDetails().getCodingFirstRep().getDisplay(), equalTo("This resource has been deleted"));
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderTest method searchForPeople_shouldReturnMatchingBundleOfPeopleByCountry.
@Test
public void searchForPeople_shouldReturnMatchingBundleOfPeopleByCountry() {
StringAndListParam countryParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(COUNTRY)));
when(fhirPersonService.searchForPeople(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(countryParam)), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(person), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchPeople(null, null, null, null, null, null, countryParam, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.iterator().next().fhirType(), is(FhirConstants.PERSON));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderTest method updatePerson_shouldUpdatePerson.
@Test
public void updatePerson_shouldUpdatePerson() {
when(fhirPersonService.update(PERSON_UUID, person)).thenReturn(person);
MethodOutcome result = resourceProvider.updatePerson(new IdType().setValue(PERSON_UUID), person);
assertThat(result, notNullValue());
assertThat(result.getResource(), equalTo(person));
}
Aggregations