use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderIntegrationTest method shouldThrow404ForNonExistingLocationAsJson.
@Test
public void shouldThrow404ForNonExistingLocationAsJson() throws Exception {
MockHttpServletResponse response = get("/Location/" + UNKNOWN_LOCATION_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.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderIntegrationTest method shouldReturnBadRequestWhenDocumentIdDoesNotMatchLocationIdAsJson.
@Test
public void shouldReturnBadRequestWhenDocumentIdDoesNotMatchLocationIdAsJson() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/Location/" + LOCATION_UUID).accept(FhirMediaTypes.JSON).go();
Location location = readResponse(response);
// update the existing record
location.setId(UNKNOWN_LOCATION_UUID);
// send the update to the server
response = put("/Location/" + LOCATION_UUID).jsonContent(toJson(location)).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.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderIntegrationTest method shouldReturnNotFoundWhenDeletingNonExistentLocationAsXML.
@Test
public void shouldReturnNotFoundWhenDeletingNonExistentLocationAsXML() throws Exception {
MockHttpServletResponse response = delete("/Location/" + UNKNOWN_LOCATION_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.hasIssue(), is(true));
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderIntegrationTest method shouldSearchForExistingLocationsAsXML.
@Test
public void shouldSearchForExistingLocationsAsXML() throws Exception {
MockHttpServletResponse response = get("/Location").accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
Bundle results = readBundleResponse(response);
assertThat(results, notNullValue());
assertThat(results.getType(), equalTo(Bundle.BundleType.SEARCHSET));
assertThat(results.hasEntry(), is(true));
List<Bundle.BundleEntryComponent> entries = results.getEntry();
assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R3/Location/"))));
assertThat(entries, everyItem(hasResource(instanceOf(Location.class))));
assertThat(entries, everyItem(hasResource(validResource())));
response = get("/Location?address-city=Kerio&partof=" + PARENT_LOCATION_UUID + "&_sort=name").accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
results = readBundleResponse(response);
assertThat(results, notNullValue());
assertThat(results.getType(), equalTo(Bundle.BundleType.SEARCHSET));
assertThat(results.hasEntry(), is(true));
entries = results.getEntry();
assertThat(entries, everyItem(hasResource(hasProperty("address", hasProperty("city", equalTo("Kerio"))))));
assertThat(entries, everyItem(hasResource(hasProperty("partOf", hasProperty("referenceElement", hasProperty("idPart", equalTo(PARENT_LOCATION_UUID)))))));
assertThat(entries, containsInRelativeOrder(hasResource(hasProperty("name", equalTo("Test location 6"))), hasResource(hasProperty("name", equalTo("Test location 8")))));
assertThat(entries, everyItem(hasResource(validResource())));
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderIntegrationTest method shouldReturnNotFoundWhenUpdatingNonExistentLocationAsXML.
@Test
public void shouldReturnNotFoundWhenUpdatingNonExistentLocationAsXML() 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.setId(UNKNOWN_LOCATION_UUID);
// send the update to the server
response = put("/Location/" + UNKNOWN_LOCATION_UUID).xmlContent(toXML(location)).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.hasIssue(), is(true));
}
Aggregations