use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderWebTest method shouldVerifyGetPersonHistoryByIdUri.
@Test
public void shouldVerifyGetPersonHistoryByIdUri() throws Exception {
org.hl7.fhir.r4.model.Person person = new org.hl7.fhir.r4.model.Person();
person.setId(PERSON_UUID);
when(personService.get(PERSON_UUID)).thenReturn(person);
MockHttpServletResponse response = getPersonHistoryByIdRequest();
assertThat(response, isOk());
assertThat(response.getContentType(), equalTo(FhirMediaTypes.JSON.toString()));
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderWebTest method deletePerson_shouldDeletePerson.
@Test
public void deletePerson_shouldDeletePerson() throws Exception {
OperationOutcome retVal = new OperationOutcome();
retVal.setId(PERSON_UUID);
retVal.getText().setDivAsString("Deleted successfully");
org.hl7.fhir.r4.model.Person person = new org.hl7.fhir.r4.model.Person();
person.setId(PERSON_UUID);
when(personService.delete(PERSON_UUID)).thenReturn(person);
MockHttpServletResponse response = delete("/Person/" + PERSON_UUID).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), equalTo(FhirMediaTypes.JSON.toString()));
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderWebTest method updatePerson_shouldUpdateExistingPerson.
@Test
public void updatePerson_shouldUpdateExistingPerson() throws Exception {
String jsonPerson;
try (InputStream is = this.getClass().getClassLoader().getResourceAsStream(JSON_UPDATE_PERSON_PATH)) {
Objects.requireNonNull(is);
jsonPerson = IOUtils.toString(is, StandardCharsets.UTF_8);
}
org.hl7.fhir.r4.model.Person person = new org.hl7.fhir.r4.model.Person();
person.setId(PERSON_UUID);
when(personService.update(anyString(), any(org.hl7.fhir.r4.model.Person.class))).thenReturn(person);
MockHttpServletResponse response = put("/Person/" + PERSON_UUID).jsonContent(jsonPerson).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderWebTest method updatePerson_shouldUpdateExistingPerson.
@Test
public void updatePerson_shouldUpdateExistingPerson() throws Exception {
String jsonPerson;
try (InputStream is = this.getClass().getClassLoader().getResourceAsStream(JSON_UPDATE_PERSON_PATH)) {
Objects.requireNonNull(is);
jsonPerson = IOUtils.toString(is, StandardCharsets.UTF_8);
}
Person person = new Person();
person.setId(PERSON_UUID);
when(personService.update(anyString(), any(Person.class))).thenReturn(person);
MockHttpServletResponse response = put("/Person/" + PERSON_UUID).jsonContent(jsonPerson).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderWebTest method createPerson_shouldCreatePerson.
@Test
public void createPerson_shouldCreatePerson() throws Exception {
String jsonPerson;
try (InputStream is = this.getClass().getClassLoader().getResourceAsStream(JSON_CREATE_PERSON_PATH)) {
Objects.requireNonNull(is);
jsonPerson = IOUtils.toString(is, StandardCharsets.UTF_8);
}
Person person = new org.hl7.fhir.r4.model.Person();
person.setId(PERSON_UUID);
when(personService.create(any(Person.class))).thenReturn(person);
MockHttpServletResponse response = post("/Person").jsonContent(jsonPerson).accept(FhirMediaTypes.JSON).go();
assertThat(response, isCreated());
}
Aggregations