use of org.openmrs.module.fhir2.model.FhirTask in project openmrs-module-fhir2 by openmrs.
the class FhirTaskTranslatorImplTest method toFhirResource_shouldTranslateOwner.
// Task.owner
@Test
public void toFhirResource_shouldTranslateOwner() {
FhirTask task = new FhirTask();
shouldTranslateReferenceToFhir(task, FhirConstants.ORGANIZATION, OPENELIS_ID, task::setOwnerReference, Task::getOwner);
}
use of org.openmrs.module.fhir2.model.FhirTask in project openmrs-module-fhir2 by openmrs.
the class FhirTaskTranslatorImplTest method toOpenmrsType_shouldIgnoreUUIDForNewOpenmrsTask.
@Test
public void toOpenmrsType_shouldIgnoreUUIDForNewOpenmrsTask() {
Task fhirTask = new Task();
fhirTask.setId(TASK_UUID);
FhirTask result = taskTranslator.toOpenmrsType(fhirTask);
assertThat(result, notNullValue());
assertThat(result.getUuid(), not(equalTo(TASK_UUID)));
}
use of org.openmrs.module.fhir2.model.FhirTask in project openmrs-module-fhir2 by openmrs.
the class FhirTaskTranslatorImplTest method toOpenmrsType_shouldTranslateNewOpenmrsTask.
@Test
public void toOpenmrsType_shouldTranslateNewOpenmrsTask() {
Task fhirTask = new Task();
FhirTask result = taskTranslator.toOpenmrsType(fhirTask);
assertThat(result, notNullValue());
assertThat(result.getUuid(), notNullValue());
}
use of org.openmrs.module.fhir2.model.FhirTask in project openmrs-module-fhir2 by openmrs.
the class FhirTaskTranslatorImplTest method shouldTranslateReferenceToFhir.
/**
* Helpers for reference associations
*/
private Task shouldTranslateReferenceToFhir(FhirTask task, String refType, String refUuid, Consumer<FhirReference> setOpenmrsReference, Function<Task, Reference> getFhirReference) {
FhirReference openmrsReference = new FhirReference();
openmrsReference.setType(refType);
openmrsReference.setReference(refUuid);
setOpenmrsReference.accept(openmrsReference);
Reference fhirReference = new Reference().setReference(refUuid).setType(refType);
when(referenceTranslator.toFhirResource(any(FhirReference.class))).thenReturn(fhirReference);
Task result = taskTranslator.toFhirResource(task);
Reference resultReference = getFhirReference.apply(result);
assertThat(resultReference, notNullValue());
assertThat(resultReference.getType(), equalTo(refType));
assertThat(resultReference.getReference(), equalTo(refUuid));
return result;
}
use of org.openmrs.module.fhir2.model.FhirTask in project openmrs-module-fhir2 by openmrs.
the class FhirTaskTranslatorImplTest method toOpenmrsType_shouldTranslateUnsupportedStatusToUnknown.
@Test
public void toOpenmrsType_shouldTranslateUnsupportedStatusToUnknown() {
Task task = new Task();
task.setStatus(Task.TaskStatus.ENTEREDINERROR);
FhirTask result = taskTranslator.toOpenmrsType(task);
assertThat(result, notNullValue());
assertThat(result.getStatus(), equalTo(FhirTask.TaskStatus.UNKNOWN));
}
Aggregations