Skip to content

Commit

Permalink
Merge 4c402e4 into 89c85af
Browse files Browse the repository at this point in the history
  • Loading branch information
rehammuzzamil committed Jul 9, 2020
2 parents 89c85af + 4c402e4 commit 8aabf8f
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ public enum ResourceType {
FAMILY("Family"),
PERSON("Person"),
TASK("Task"),
QUESTIONAIRRE_RESPONSE("QuestionnaireResponse");

QUESTIONAIRRE_RESPONSE("QuestionnaireResponse"),
GLOBAL_TASK("Global.Task");

private String value;

private ResourceType(String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ public List<? extends Resource> getConditionSubjectResources(Resource resource,

case QUESTIONAIRRE_RESPONSE:
return PathEvaluatorLibrary.getInstance().getEventProvider().getEvents(resource, planIdentifier);

case GLOBAL_TASK:
return PathEvaluatorLibrary.getInstance().getTaskProvider().getAllTasks(resource.getId());

default:
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ public interface TaskDao {
void saveTask(org.smartregister.domain.Task task, QuestionnaireResponse questionnaireResponse);

boolean checkIfTaskExists(String baseEntityId, String planIdentifier, String code);

List<Task> findAllTasksForEntity(String id);

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,11 @@ public List<Task> getTasks(Resource resource, String planIdentifier) {
return taskDao.findTasksForEntity(resource.getId(), planIdentifier);

}

public List<Task> getAllTasks(String id) {

return taskDao.findAllTasksForEntity(id);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,14 @@ public void testGetQuestionnaireConditionResourcesV2() {
assertEquals(expected, actionHelper.getConditionSubjectResources(condition, action, questionnaireResponse, plan));
verify(eventProvider).getEvents(questionnaireResponse, plan);
}

@Test
public void testGetGlobalTaskConditionResources() {
subjectConcept.setText(ResourceType.GLOBAL_TASK.value());
List<Task> expected = Collections.singletonList(TestData.createTask());
when(taskProvider.getAllTasks(patient.getId())).thenReturn(expected);
assertEquals(expected, actionHelper.getConditionSubjectResources(condition, action, patient, plan));
verify(taskProvider).getAllTasks(patient.getId());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,14 @@ public void testGetTasks() {
assertEquals(expected, taskProvider.getTasks(patient, planIdentifier));
verify(taskDao).findTasksForEntity(patient.getId(), planIdentifier);
}

@Test
public void testGetAllTasks() {
Patient patient = TestData.createPatient();
List<Task> expected = Collections.singletonList(TestData.createTask());
String planIdentifier = UUID.randomUUID().toString();
when(taskDao.findAllTasksForEntity(patient.getId())).thenReturn(expected);
assertEquals(expected, taskProvider.getAllTasks(patient.getId()));
verify(taskDao).findAllTasksForEntity(patient.getId());
}
}

0 comments on commit 8aabf8f

Please sign in to comment.