use of org.hl7.fhir.r5.model.OperationOutcome in project openmrs-module-fhir2 by openmrs.
the class ConditionFhirResourceProviderIntegrationTest method shouldReturnBadRequestWhenDocumentIdDoesNotMatchConditionIdAsJson.
@Test
public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchConditionIdAsJson() throws Exception {
MockHttpServletResponse response = get("/Condition/" + CONDITION_UUID).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), equalTo(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
Condition condition = readResponse(response);
condition.setId(WRONG_CONDITION_UUID);
response = put("/Condition/" + CONDITION_UUID).jsonContent(toJson(condition)).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.r5.model.OperationOutcome in project openmrs-module-fhir2 by openmrs.
the class ConditionFhirResourceProviderIntegrationTest method shouldReturnNotFoundWhenConditionNotFoundAsJson.
@Test
public void shouldReturnNotFoundWhenConditionNotFoundAsJson() throws Exception {
MockHttpServletResponse response = get("/Condition/" + WRONG_CONDITION_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.r5.model.OperationOutcome in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportResourceProviderIntegrationTest method shouldReturnNotFoundWhenDiagnosticReportDoesNotExistAsXML.
@Test
public void shouldReturnNotFoundWhenDiagnosticReportDoesNotExistAsXML() throws Exception {
MockHttpServletResponse response = get("/DiagnosticReport/" + WRONG_DIAGNOSTIC_REPORT_UUID).accept(FhirMediaTypes.XML).go();
assertThat(response, isNotFound());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
OperationOutcome operationOutcome = readOperationOutcome(response);
assertThat(operationOutcome, notNullValue());
assertThat(operationOutcome.getIssue(), hasSize(greaterThanOrEqualTo(1)));
assertThat(operationOutcome.getIssue(), hasItem(hasProperty("severity", equalTo(OperationOutcome.IssueSeverity.ERROR))));
}
use of org.hl7.fhir.r5.model.OperationOutcome in project openmrs-module-fhir2 by openmrs.
the class GroupResourceProviderIntegrationTest method shouldReturnBadRequestWhenDocumentIdDoesNotMatchGroupIdAsJSON.
@Test
public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchGroupIdAsJSON() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/Group/" + GROUP_UUID).accept(FhirMediaTypes.JSON).go();
Group group = readResponse(response);
// update the existing record
group.setId(BAD_GROUP_UUID);
// send the update to the server
response = put("/Group/" + GROUP_UUID).jsonContent(toJson(group)).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.r5.model.OperationOutcome in project openmrs-module-fhir2 by openmrs.
the class GroupResourceProviderIntegrationTest method shouldReturnBadRequestWhenDocumentIdDoesNotMatchGroupIdAsXML.
@Test
public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchGroupIdAsXML() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/Group/" + GROUP_UUID).accept(FhirMediaTypes.XML).go();
Group group = readResponse(response);
// update the existing record
group.setId(BAD_GROUP_UUID);
// send the update to the server
response = put("/Group/" + GROUP_UUID).xmlContent(toXML(group)).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