use of org.hl7.gravity.refimpl.sdohexchange.model.Server in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirResourceProviderIntegrationTest method shouldReturnNotFoundWhenUpdatingNonExistentAllergyAsJson.
@Test
public void shouldReturnNotFoundWhenUpdatingNonExistentAllergyAsJson() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/AllergyIntolerance/" + ALLERGY_UUID).accept(FhirMediaTypes.JSON).go();
AllergyIntolerance allergy = readResponse(response);
// update the existing record
allergy.setId(UNKNOWN_ALLERGY_UUID);
// send the update to the server
response = put("/AllergyIntolerance/" + UNKNOWN_ALLERGY_UUID).jsonContent(toJson(allergy)).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 AllergyIntoleranceFhirResourceProviderIntegrationTest method shouldUpdateExistingAllergyAsXML.
@Test
public void shouldUpdateExistingAllergyAsXML() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/AllergyIntolerance/" + ALLERGY_UUID).accept(FhirMediaTypes.XML).go();
AllergyIntolerance allergy = readResponse(response);
// update the existing record
Enumeration<AllergyIntolerance.AllergyIntoleranceCategory> category = new Enumeration<>(new AllergyIntolerance.AllergyIntoleranceCategoryEnumFactory());
category.setValue(AllergyIntolerance.AllergyIntoleranceCategory.ENVIRONMENT);
allergy.getCategory().set(0, category);
// send the update to the server
response = put("/AllergyIntolerance/" + ALLERGY_UUID).xmlContent(toXML(allergy)).accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
// read the updated record
AllergyIntolerance updatedAllergy = readResponse(response);
assertThat(updatedAllergy, notNullValue());
assertThat(updatedAllergy.getIdElement().getIdPart(), equalTo(ALLERGY_UUID));
assertThat(updatedAllergy.getCategory().get(0).getValue().toCode(), equalTo("environment"));
assertThat(updatedAllergy, validResource());
// double-check the record returned via get
response = get("/AllergyIntolerance/" + ALLERGY_UUID).accept(FhirMediaTypes.XML).go();
AllergyIntolerance reReadAllergy = readResponse(response);
assertThat(reReadAllergy.getCategory().get(0).getValue().toCode(), equalTo("environment"));
}
use of org.hl7.gravity.refimpl.sdohexchange.model.Server in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportResourceProviderIntegrationTest method shouldReturnBadRequestWhenDocumentIdDoesNotMatchPatientIdAsXML.
@Test
public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchPatientIdAsXML() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/DiagnosticReport/" + DIAGNOSTIC_REPORT_UUID).accept(FhirMediaTypes.XML).go();
DiagnosticReport diagnosticReport = readResponse(response);
// update the existing record
diagnosticReport.setId(WRONG_DIAGNOSTIC_REPORT_UUID);
// send the update to the server
response = put("/DiagnosticReport/" + DIAGNOSTIC_REPORT_UUID).xmlContent(toXML(diagnosticReport)).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));
}
use of org.hl7.gravity.refimpl.sdohexchange.model.Server in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportResourceProviderIntegrationTest method shouldUpdateExistingDiagnosticReportAsXML.
@Test
public void shouldUpdateExistingDiagnosticReportAsXML() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/DiagnosticReport/" + DIAGNOSTIC_REPORT_UUID).accept(FhirMediaTypes.XML).go();
DiagnosticReport diagnosticReport = readResponse(response);
// verify condition we will change
assertThat(diagnosticReport.getStatus(), not(is(DiagnosticReport.DiagnosticReportStatus.FINAL)));
// update the existing record
diagnosticReport.setStatus(DiagnosticReport.DiagnosticReportStatus.FINAL);
// send the update to the server
response = put("/DiagnosticReport/" + DIAGNOSTIC_REPORT_UUID).xmlContent(toXML(diagnosticReport)).accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
// read the updated record
DiagnosticReport updatedDiagnosticReport = readResponse(response);
assertThat(updatedDiagnosticReport, notNullValue());
assertThat(updatedDiagnosticReport.getIdElement().getIdPart(), equalTo(DIAGNOSTIC_REPORT_UUID));
assertThat(updatedDiagnosticReport.getStatus(), is(DiagnosticReport.DiagnosticReportStatus.FINAL));
assertThat(diagnosticReport, validResource());
// double-check the record returned via get
response = get("/DiagnosticReport/" + DIAGNOSTIC_REPORT_UUID).accept(FhirMediaTypes.JSON).go();
DiagnosticReport reReadDiagnosticReport = readResponse(response);
assertThat(reReadDiagnosticReport.getStatus(), is(DiagnosticReport.DiagnosticReportStatus.FINAL));
}
use of org.hl7.gravity.refimpl.sdohexchange.model.Server in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportResourceProviderIntegrationTest method shouldUpdateExistingDiagnosticReportAsJson.
@Test
public void shouldUpdateExistingDiagnosticReportAsJson() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/DiagnosticReport/" + DIAGNOSTIC_REPORT_UUID).accept(FhirMediaTypes.JSON).go();
DiagnosticReport diagnosticReport = readResponse(response);
// verify condition we will change
assertThat(diagnosticReport.getStatus(), not(is(DiagnosticReport.DiagnosticReportStatus.FINAL)));
// update the existing record
diagnosticReport.setStatus(DiagnosticReport.DiagnosticReportStatus.FINAL);
// send the update to the server
response = put("/DiagnosticReport/" + DIAGNOSTIC_REPORT_UUID).jsonContent(toJson(diagnosticReport)).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
// read the updated record
DiagnosticReport updatedDiagnosticReport = readResponse(response);
assertThat(updatedDiagnosticReport, notNullValue());
assertThat(updatedDiagnosticReport.getIdElement().getIdPart(), equalTo(DIAGNOSTIC_REPORT_UUID));
assertThat(updatedDiagnosticReport.getStatus(), is(DiagnosticReport.DiagnosticReportStatus.FINAL));
assertThat(diagnosticReport, validResource());
// double-check the record returned via get
response = get("/DiagnosticReport/" + DIAGNOSTIC_REPORT_UUID).accept(FhirMediaTypes.JSON).go();
DiagnosticReport reReadDiagnosticReport = readResponse(response);
assertThat(reReadDiagnosticReport.getStatus(), is(DiagnosticReport.DiagnosticReportStatus.FINAL));
}
Aggregations