Search in sources :

Example 71 with Person

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()));
}
Also used : Person(org.hl7.fhir.dstu3.model.Person) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 72 with Person

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()));
}
Also used : OperationOutcome(org.hl7.fhir.dstu3.model.OperationOutcome) Person(org.hl7.fhir.dstu3.model.Person) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 73 with Person

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());
}
Also used : InputStream(java.io.InputStream) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Person(org.hl7.fhir.dstu3.model.Person) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 74 with Person

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());
}
Also used : InputStream(java.io.InputStream) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Person(org.hl7.fhir.r4.model.Person) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 75 with Person

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());
}
Also used : InputStream(java.io.InputStream) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Person(org.hl7.fhir.r4.model.Person) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)181 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)54 Date (java.util.Date)50 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)48 Person (org.hl7.fhir.r4.model.Person)47 Person (model.Person)44 Person (com.google.api.services.people.v1.model.Person)38 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)37 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)32 Reference (org.hl7.fhir.r4.model.Reference)31 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)30 StringParam (ca.uhn.fhir.rest.param.StringParam)30 VCard (ezvcard.VCard)30 Person (org.openmrs.Person)29 EmailAddress (com.google.api.services.people.v1.model.EmailAddress)23 List (java.util.List)22 Collectors (java.util.stream.Collectors)22 Person (org.hl7.fhir.dstu3.model.Person)22 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)22 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)21