use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class TaskQueryTest method testQueryByInvalidNameOr.
public void testQueryByInvalidNameOr() {
TaskQuery query = taskService.createTaskQuery().or().taskId("invalid").taskName("invalid");
assertThat(query.singleResult()).isNull();
assertThat(query.list()).hasSize(0);
assertThat(query.count()).isEqualTo(0);
assertThatExceptionOfType(ActivitiIllegalArgumentException.class).isThrownBy(() -> taskService.createTaskQuery().or().taskId("invalid").taskName(null).singleResult());
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class SubTaskQueryTest method testTaskQueryParentTask.
public void testTaskQueryParentTask() throws Exception {
Task rootTask = taskService.newTask();
taskService.saveTask(rootTask);
taskIds.add(rootTask.getId());
Task subTask = taskService.newTask();
subTask.setParentTaskId(rootTask.getId());
taskService.saveTask(subTask);
taskIds.add(subTask.getId());
subTask = taskService.newTask();
subTask.setAssignee("gonzo");
subTask.setParentTaskId(rootTask.getId());
taskService.saveTask(subTask);
taskIds.add(subTask.getId());
TaskQuery query = taskService.createTaskQuery().taskParentTaskId(rootTask.getId());
assertThat(query.count()).isEqualTo(2);
query = taskService.createTaskQuery().taskAssignee("gonzo").taskParentTaskId(rootTask.getId());
assertThat(query.count()).isEqualTo(1);
query = taskService.createTaskQuery().taskAssignee("kermit").taskParentTaskId(rootTask.getId());
assertThat(query.count()).isEqualTo(0);
query = taskService.createTaskQuery().taskAssignee("gonzo").or().taskName("A sub task").taskParentTaskId(rootTask.getId()).endOr();
assertThat(query.count()).isEqualTo(1);
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class SubTaskQueryTest method testQueryExcludeSubtasksSorted.
/**
* test for task inclusion/exclusion (no other filters, order by task assignee )
*/
public void testQueryExcludeSubtasksSorted() throws Exception {
// query all tasks, including subtasks
TaskQuery query = taskService.createTaskQuery().orderByTaskAssignee().asc();
assertThat(query.count()).isEqualTo(10);
assertThat(query.list()).hasSize(10);
// query only parent tasks (exclude subtasks)
query = taskService.createTaskQuery().excludeSubtasks().orderByTaskAssignee().desc();
assertThat(query.count()).isEqualTo(3);
assertThat(query.list()).hasSize(3);
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class SubTaskQueryTest method testQueryByAssigneeExcludeSubtasks.
/**
* test for task inclusion/exclusion when additional filter is specified (like assignee), no order.
*/
public void testQueryByAssigneeExcludeSubtasks() throws Exception {
// gonzo has 2 root tasks and 3+2 subtasks assigned
// include subtasks
TaskQuery query = taskService.createTaskQuery().taskAssignee("gonzo");
assertThat(query.count()).isEqualTo(7);
assertThat(query.list()).hasSize(7);
// exclude subtasks
query = taskService.createTaskQuery().taskAssignee("gonzo").excludeSubtasks();
assertThat(query.count()).isEqualTo(2);
assertThat(query.list()).hasSize(2);
// kermit has no root tasks and no subtasks assigned
// include subtasks
query = taskService.createTaskQuery().taskAssignee(KERMIT);
assertThat(query.count()).isEqualTo(0);
assertThat(query.list()).hasSize(0);
assertThat(query.singleResult()).isNull();
// exclude subtasks
query = taskService.createTaskQuery().taskAssignee(KERMIT).excludeSubtasks();
assertThat(query.count()).isEqualTo(0);
assertThat(query.list()).hasSize(0);
assertThat(query.singleResult()).isNull();
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class SubTaskQueryTest method testQueryByAssigneeExcludeSubtasksOrdered.
/**
* test for task inclusion/exclusion when additional filter is specified (like assignee), ordered.
*/
public void testQueryByAssigneeExcludeSubtasksOrdered() throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss.SSS");
// gonzo has 2 root tasks and 3+2 subtasks assigned
// include subtasks
TaskQuery query = taskService.createTaskQuery().taskAssignee("gonzo").orderByTaskCreateTime().desc();
assertThat(query.count()).isEqualTo(7);
assertThat(query.list()).hasSize(7);
assertThat(query.list().get(0).getCreateTime()).isEqualTo(sdf.parse("02/01/2009 01:01:01.000"));
// exclude subtasks
query = taskService.createTaskQuery().taskAssignee("gonzo").excludeSubtasks().orderByTaskCreateTime().asc();
assertThat(query.count()).isEqualTo(2);
assertThat(query.list()).hasSize(2);
assertThat(query.list().get(0).getCreateTime()).isEqualTo(sdf.parse("01/02/2008 02:02:02.000"));
assertThat(query.list().get(1).getCreateTime()).isEqualTo(sdf.parse("05/02/2008 02:02:02.000"));
// kermit has no root tasks and no subtasks assigned include subtasks
query = taskService.createTaskQuery().taskAssignee(KERMIT).orderByTaskCreateTime().asc();
assertThat(query.count()).isEqualTo(0);
assertThat(query.list()).hasSize(0);
assertThat(query.singleResult()).isNull();
// exclude subtasks
query = taskService.createTaskQuery().taskAssignee(KERMIT).excludeSubtasks().orderByTaskCreateTime().desc();
assertThat(query.count()).isEqualTo(0);
assertThat(query.list()).hasSize(0);
assertThat(query.singleResult()).isNull();
}
Aggregations