Search in sources :

Example 96 with TaskQuery

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());
}
Also used : TaskQuery(org.activiti.engine.task.TaskQuery) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException)

Example 97 with TaskQuery

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);
}
Also used : Task(org.activiti.engine.task.Task) TaskQuery(org.activiti.engine.task.TaskQuery)

Example 98 with TaskQuery

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);
}
Also used : TaskQuery(org.activiti.engine.task.TaskQuery)

Example 99 with TaskQuery

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();
}
Also used : TaskQuery(org.activiti.engine.task.TaskQuery)

Example 100 with TaskQuery

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();
}
Also used : TaskQuery(org.activiti.engine.task.TaskQuery) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

TaskQuery (org.activiti.engine.task.TaskQuery)130 Task (org.activiti.engine.task.Task)53 Deployment (org.activiti.engine.test.Deployment)30 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)24 ArrayList (java.util.ArrayList)23 ActivitiException (org.activiti.engine.ActivitiException)21 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)12 SimpleDateFormat (java.text.SimpleDateFormat)8 Date (java.util.Date)8 HashMap (java.util.HashMap)8 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)7 Map (java.util.Map)5 WorkflowTaskQuery (org.alfresco.service.cmr.workflow.WorkflowTaskQuery)5 InvalidArgumentException (org.alfresco.rest.framework.core.exceptions.InvalidArgumentException)4 LazyActivitiWorkflowTask (org.alfresco.service.cmr.workflow.LazyActivitiWorkflowTask)4 WorkflowTask (org.alfresco.service.cmr.workflow.WorkflowTask)4 Test (org.junit.jupiter.api.Test)4 WorkflowTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)3 HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)3 HistoricTaskInstanceQuery (org.activiti.engine.history.HistoricTaskInstanceQuery)3