use of org.openmrs.module.fhir2.model.FhirTask in project openmrs-module-fhir2 by openmrs.
the class FhirTaskServiceImplTest method saveTask_shouldCreateNewTask.
@Test
public void saveTask_shouldCreateNewTask() {
org.hl7.fhir.r4.model.Task fhirTask = new org.hl7.fhir.r4.model.Task();
FhirTask openmrsTask = new FhirTask();
fhirTask.setStatus(FHIR_TASK_STATUS);
fhirTask.setIntent(FHIR_TASK_INTENT);
openmrsTask.setUuid(TASK_UUID);
openmrsTask.setStatus(OPENMRS_TASK_STATUS);
openmrsTask.setIntent(OPENMRS_TASK_INTENT);
when(translator.toOpenmrsType(fhirTask)).thenReturn(openmrsTask);
when(dao.createOrUpdate(openmrsTask)).thenReturn(openmrsTask);
when(translator.toFhirResource(openmrsTask)).thenReturn(fhirTask);
org.hl7.fhir.r4.model.Task result = fhirTaskService.create(fhirTask);
assertThat(result, notNullValue());
assertThat(result, equalTo(fhirTask));
}
use of org.openmrs.module.fhir2.model.FhirTask in project openmrs-module-fhir2 by openmrs.
the class FhirTaskServiceImplTest method updateTask_shouldThrowResourceNotFoundIfTaskDoesNotExist.
@Test(expected = ResourceNotFoundException.class)
public void updateTask_shouldThrowResourceNotFoundIfTaskDoesNotExist() {
org.hl7.fhir.r4.model.Task fhirTask = new org.hl7.fhir.r4.model.Task();
fhirTask.setId(WRONG_TASK_UUID);
when(dao.get(WRONG_TASK_UUID)).thenReturn(null);
fhirTaskService.update(WRONG_TASK_UUID, fhirTask);
}
use of org.openmrs.module.fhir2.model.FhirTask in project openmrs-module-fhir2 by openmrs.
the class FhirTaskServiceImplTest method searchForTasks_shouldReturnTasksByParameters.
@Test
public void searchForTasks_shouldReturnTasksByParameters() {
List<FhirTask> openmrsTasks = new ArrayList<>();
FhirTask openmrsTask = new FhirTask();
openmrsTask.setUuid(TASK_UUID);
openmrsTasks.add(openmrsTask);
Task task = new Task();
task.setId(TASK_UUID);
SearchParameterMap theParams = new SearchParameterMap();
when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(TASK_UUID));
when(dao.getSearchResults(any(), any())).thenReturn(openmrsTasks);
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, translator, fhirGlobalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
when(translator.toFhirResource(openmrsTask)).thenReturn(task);
IBundleProvider results = fhirTaskService.searchForTasks(null, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasItem(hasProperty("id", equalTo(TASK_UUID))));
}
use of org.openmrs.module.fhir2.model.FhirTask in project openmrs-module-fhir2 by openmrs.
the class FhirTaskServiceImplTest method updateTask_shouldThrowInvalidRequestForUuidMismatch.
@Test(expected = InvalidRequestException.class)
public void updateTask_shouldThrowInvalidRequestForUuidMismatch() {
org.hl7.fhir.r4.model.Task fhirTask = new org.hl7.fhir.r4.model.Task();
fhirTask.setId(TASK_UUID);
fhirTaskService.update(WRONG_TASK_UUID, fhirTask);
}
use of org.openmrs.module.fhir2.model.FhirTask in project openmrs-module-fhir2 by openmrs.
the class FhirTaskServiceImplTest method updateTask_shouldThrowInvalidRequestForMissingUuid.
@Test(expected = InvalidRequestException.class)
public void updateTask_shouldThrowInvalidRequestForMissingUuid() {
org.hl7.fhir.r4.model.Task fhirTask = new org.hl7.fhir.r4.model.Task();
fhirTaskService.update(TASK_UUID, fhirTask);
}
Aggregations