use of org.hl7.gravity.refimpl.sdohexchange.model.Server in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderIntegrationTest method shouldUpdateExistingLocationAsXML.
@Test
public void shouldUpdateExistingLocationAsXML() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/Location/" + LOCATION_UUID).accept(FhirMediaTypes.XML).go();
Location location = readResponse(response);
// update the existing record
location.getAddress().setCountry("France");
// send the update to the server
response = put("/Location/" + LOCATION_UUID).xmlContent(toXML(location)).accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
// read the updated record
Location updatedLocation = readResponse(response);
assertThat(updatedLocation, notNullValue());
assertThat(updatedLocation.getIdElement().getIdPart(), equalTo(LOCATION_UUID));
assertThat(updatedLocation.getAddress().getCountry(), equalTo("France"));
assertThat(updatedLocation, validResource());
// double-check the record returned via get
response = get("/Location/" + LOCATION_UUID).accept(FhirMediaTypes.XML).go();
Location reReadLocation = readResponse(response);
assertThat(reReadLocation.getAddress().getCountry(), equalTo("France"));
}
use of org.hl7.gravity.refimpl.sdohexchange.model.Server in project openmrs-module-fhir2 by openmrs.
the class MedicationFhirResourceProviderIntegrationTest method shouldReturnBadRequestWhenDocumentIdDoesNotMatchMedicationIdAsXML.
@Test
public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchMedicationIdAsXML() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/Medication/" + MEDICATION_UUID).accept(FhirMediaTypes.XML).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).xmlContent(toXML(medication)).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 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.gravity.refimpl.sdohexchange.model.Server in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirResourceProviderIntegrationTest method shouldReturnBadRequestWhenDocumentIdDoesNotMatchAllergyIdAsJson.
@Test
public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchAllergyIdAsJson() 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/" + ALLERGY_UUID).jsonContent(toJson(allergy)).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 AllergyIntoleranceFhirResourceProviderIntegrationTest method shouldReturnBadRequestWhenDocumentIdDoesNotMatchAllergyIdAsXML.
@Test
public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchAllergyIdAsXML() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/AllergyIntolerance/" + ALLERGY_UUID).accept(FhirMediaTypes.XML).go();
AllergyIntolerance allergy = readResponse(response);
// update the existing record
allergy.setId(UNKNOWN_ALLERGY_UUID);
// send the update to the server
response = put("/AllergyIntolerance/" + ALLERGY_UUID).xmlContent(toXML(allergy)).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