use of org.hl7.fhir.r4b.model.OperationOutcome in project openmrs-module-fhir2 by openmrs.
the class MedicationFhirResourceProviderIntegrationTest method shouldReturnBadRequestWhenDocumentIdDoesNotMatchMedicationIdAsJson.
@Test
public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchMedicationIdAsJson() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/Medication/" + MEDICATION_UUID).accept(FhirMediaTypes.JSON).go();
Medication medication = readResponse(response);
// update the existing record
medication.setId(WRONG_MEDICATION_UUID);
// send the update to the server
response = put("/Medication/" + MEDICATION_UUID).jsonContent(toJson(medication)).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.fhir.r4b.model.OperationOutcome in project openmrs-module-fhir2 by openmrs.
the class MedicationFhirResourceProviderIntegrationTest method shouldReturnNotFoundWhenDeletingNonExistentMedication.
@Test
public void shouldReturnNotFoundWhenDeletingNonExistentMedication() throws Exception {
MockHttpServletResponse response = delete("/Medication/" + WRONG_MEDICATION_UUID).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.fhir.r4b.model.OperationOutcome in project openmrs-module-fhir2 by openmrs.
the class TaskFhirResourceIntegrationTest method shouldReturnBadRequestWhenDocumentIdDoesNotMatchTaskIdAsJson.
@Test
public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchTaskIdAsJson() throws Exception {
MockHttpServletResponse response = get("/Task/" + TASK_UUID).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
Task task = readResponse(response);
task.setId(WRONG_TASK_UUID);
response = put("/Task/" + TASK_UUID).jsonContent(toJson(task)).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.fhir.r4b.model.OperationOutcome in project openmrs-module-fhir2 by openmrs.
the class TaskFhirResourceIntegrationTest method shouldReturnNotFoundWhenUpdatingNonExistentTaskAsJson.
@Test
public void shouldReturnNotFoundWhenUpdatingNonExistentTaskAsJson() throws Exception {
MockHttpServletResponse response = get("/Task/" + TASK_UUID).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
Task patient = readResponse(response);
patient.setId(WRONG_TASK_UUID);
response = put("/Task/" + WRONG_TASK_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.fhir.r4b.model.OperationOutcome in project openmrs-module-fhir2 by openmrs.
the class TaskFhirResourceIntegrationTest method shouldReturnNotFoundWhenDeletingNonExistentTask.
@Test
public void shouldReturnNotFoundWhenDeletingNonExistentTask() throws Exception {
MockHttpServletResponse response = delete("/Patient/" + WRONG_TASK_UUID).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));
}
Aggregations