use of org.hl7.gravity.refimpl.sdohexchange.model.Server in project openmrs-module-fhir2 by openmrs.
the class PatientFhirResourceProviderIntegrationTest method shouldReturnNotFoundWhenUpdatingNonExistentPatientAsJson.
@Test
public void shouldReturnNotFoundWhenUpdatingNonExistentPatientAsJson() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/Patient/" + PATIENT_UUID).accept(FhirMediaTypes.JSON).go();
Patient patient = readResponse(response);
// update the existing record
patient.setId(WRONG_PATIENT_UUID);
// send the update to the server
response = put("/Patient/" + WRONG_PATIENT_UUID).jsonContent(toJson(patient)).accept(FhirMediaTypes.JSON).go();
assertThat(response, isNotFound());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
OperationOutcome operationOutcome = readOperationOutcome(response);
assertThat(operationOutcome, notNullValue());
assertThat(operationOutcome.hasIssue(), is(true));
}
use of org.hl7.gravity.refimpl.sdohexchange.model.Server in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderIntegrationTest method shouldReturnBadRequestWhenDocumentIdDoesNotMatchPersonIdAsJson.
@Test
public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchPersonIdAsJson() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/Person/" + PERSON_UUID).accept(FhirMediaTypes.JSON).go();
Person person = readResponse(response);
// update the existing record
person.setId(WRONG_PERSON_UUID);
// send the update to the server
response = put("/Person/" + PERSON_UUID).jsonContent(toJson(person)).accept(FhirMediaTypes.JSON).go();
assertThat(response, isBadRequest());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
OperationOutcome operationOutcome = readOperationOutcome(response);
assertThat(operationOutcome, notNullValue());
assertThat(operationOutcome.hasIssue(), is(true));
}
use of org.hl7.gravity.refimpl.sdohexchange.model.Server in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderIntegrationTest method shouldReturnNotFoundWhenUpdatingNonExistentPersonAsJson.
@Test
public void shouldReturnNotFoundWhenUpdatingNonExistentPersonAsJson() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/Person/" + PERSON_UUID).accept(FhirMediaTypes.JSON).go();
Person person = readResponse(response);
// update the existing record
person.setId(WRONG_PERSON_UUID);
// send the update to the server
response = put("/Person/" + WRONG_PERSON_UUID).jsonContent(toJson(person)).accept(FhirMediaTypes.JSON).go();
assertThat(response, isNotFound());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
OperationOutcome operationOutcome = readOperationOutcome(response);
assertThat(operationOutcome, notNullValue());
assertThat(operationOutcome.hasIssue(), is(true));
}
use of org.hl7.gravity.refimpl.sdohexchange.model.Server in project openmrs-module-fhir2 by openmrs.
the class PersonFhirResourceProviderIntegrationTest method shouldUpdateExistingPersonAsXML.
@Test
public void shouldUpdateExistingPersonAsXML() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/Person/" + PERSON_UUID).accept(FhirMediaTypes.XML).go();
Person person = readResponse(response);
// update the existing record
Date birthDate = DateUtils.truncate(new Date(), Calendar.DATE);
person.setBirthDate(birthDate);
// send the update to the server
response = put("/Person/" + PERSON_UUID).xmlContent(toXML(person)).accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
// read the updated record
Person updatedPerson = readResponse(response);
assertThat(updatedPerson, notNullValue());
assertThat(updatedPerson.getIdElement().getIdPart(), equalTo(PERSON_UUID));
assertThat(updatedPerson.getBirthDate(), equalTo(birthDate));
assertThat(person, validResource());
// double-check the record returned via get
response = get("/Person/" + PERSON_UUID).accept(FhirMediaTypes.XML).go();
Person reReadPerson = readResponse(response);
assertThat(reReadPerson.getBirthDate(), equalTo(birthDate));
}
use of org.hl7.gravity.refimpl.sdohexchange.model.Server in project openmrs-module-fhir2 by openmrs.
the class PractitionerFhirResourceProviderIntegrationTest method shouldReturnBadRequestWhenDocumentIdDoesNotMatchPractitionerIdAsXML.
@Test
public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchPractitionerIdAsXML() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/Practitioner/" + PRACTITIONER_UUID).accept(FhirMediaTypes.XML).go();
Practitioner practitioner = readResponse(response);
// update the existing record
practitioner.setId(WRONG_PRACTITIONER_UUID);
// send the update to the server
response = put("/Practitioner/" + PRACTITIONER_UUID).xmlContent(toXML(practitioner)).accept(FhirMediaTypes.XML).go();
assertThat(response, isBadRequest());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
OperationOutcome operationOutcome = readOperationOutcome(response);
assertThat(operationOutcome, notNullValue());
assertThat(operationOutcome.hasIssue(), is(true));
}
Aggregations