use of org.hl7.fhir.r5.model.Task in project openmrs-module-fhir2 by openmrs.
the class TaskFhirResourceIntegrationTest method shouldSearchForFilteredAndSortedTasksAsXML.
@Test
public void shouldSearchForFilteredAndSortedTasksAsXML() throws Exception {
MockHttpServletResponse response = get("/Task?status=requested&_sort=_lastUpdated").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(), is(Bundle.BundleType.SEARCHSET));
assertThat(results.hasEntry(), is(true));
List<Bundle.BundleEntryComponent> entries = results.getEntry();
assertThat(entries, hasSize(2));
assertThat(entries, everyItem(hasResource(hasProperty("status", is(Task.TaskStatus.REQUESTED)))));
assertThat(entries, containsInRelativeOrder(hasResource(hasProperty("meta", hasProperty("lastUpdated", equalTo(Date.from(LocalDateTime.of(2012, 5, 1, 0, 0, 0).atZone(ZoneId.systemDefault()).toInstant()))))), hasResource(hasProperty("meta", hasProperty("lastUpdated", equalTo(Date.from(LocalDateTime.of(2012, 7, 1, 0, 0, 0).atZone(ZoneId.systemDefault()).toInstant())))))));
}
use of org.hl7.fhir.r5.model.Task in project openmrs-module-fhir2 by openmrs.
the class TaskFhirResourceIntegrationTest method shouldReturnExistingTaskAsXML.
@Test
public void shouldReturnExistingTaskAsXML() throws Exception {
MockHttpServletResponse response = get("/Task/" + TASK_UUID).accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
Task task = readResponse(response);
assertThat(task, notNullValue());
assertThat(task.getIdElement().getIdPart(), equalTo(TASK_UUID));
assertThat(task.getStatus(), is(Task.TaskStatus.ACCEPTED));
assertThat(task.getIntent(), is(Task.TaskIntent.ORDER));
assertThat(task, validResource());
}
use of org.hl7.fhir.r5.model.Task in project openmrs-module-fhir2 by openmrs.
the class TaskFhirResourceIntegrationTest method shouldUpdateExistingTaskAsJson.
@Test
public void shouldUpdateExistingTaskAsJson() throws Exception {
MockHttpServletResponse response = get("/Task/" + TASK_UUID).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
Task task = readResponse(response);
assertThat(task.getStatus(), is(Task.TaskStatus.ACCEPTED));
task.setStatus(Task.TaskStatus.COMPLETED);
response = put("/Task/" + TASK_UUID).jsonContent(toJson(task)).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
Task updatedTask = readResponse(response);
assertThat(updatedTask, notNullValue());
assertThat(updatedTask.getIdElement().getIdPart(), equalTo(TASK_UUID));
assertThat(updatedTask.getStatus(), is(Task.TaskStatus.COMPLETED));
assertThat(updatedTask, validResource());
response = get("/Task/" + TASK_UUID).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
Task reReadTask = readResponse(response);
assertThat(reReadTask.getStatus(), is(Task.TaskStatus.COMPLETED));
}
use of org.hl7.fhir.r5.model.Task 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.r5.model.Task in project openmrs-module-fhir2 by openmrs.
the class TaskFhirResourceIntegrationTest method shouldReturnExistingTaskAsJson.
@Test
public void shouldReturnExistingTaskAsJson() throws Exception {
MockHttpServletResponse response = get("/Task/" + TASK_UUID).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
Task task = readResponse(response);
assertThat(task, notNullValue());
assertThat(task.getIdElement().getIdPart(), equalTo(TASK_UUID));
assertThat(task.getStatus(), is(Task.TaskStatus.ACCEPTED));
assertThat(task.getIntent(), is(Task.TaskIntent.ORDER));
assertThat(task, validResource());
}
Aggregations