Search in sources :

Example 61 with TaskQuery

use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.

the class SubTaskQueryTest method testQueryExcludeSubtasks.

/**
   * test for task inclusion/exclusion (no other filters, no sort) 
   */
public void testQueryExcludeSubtasks() throws Exception {
    // query all tasks, including subtasks
    TaskQuery query = taskService.createTaskQuery();
    assertEquals(10, query.count());
    assertEquals(10, query.list().size());
    // query only parent tasks (exclude subtasks)
    query = taskService.createTaskQuery().excludeSubtasks();
    assertEquals(3, query.count());
    assertEquals(3, query.list().size());
}
Also used : TaskQuery(org.activiti.engine.task.TaskQuery)

Example 62 with TaskQuery

use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.

the class SubTaskQueryTest method testQueryByAssigneeExcludeSubtasksOrderedAndPaginated.

/**
   * test for task inclusion/exclusion when additional filter is specified (like assignee), ordered. 
   */
public void testQueryByAssigneeExcludeSubtasksOrderedAndPaginated() 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().asc();
    assertEquals(7, query.count());
    assertEquals(1, query.listPage(0, 1).size());
    assertEquals(sdf.parse("01/02/2008 02:02:02.000"), query.listPage(0, 1).get(0).getCreateTime());
    assertEquals(1, query.listPage(1, 1).size());
    assertEquals(sdf.parse("05/02/2008 02:02:02.000"), query.listPage(1, 1).get(0).getCreateTime());
    assertEquals(2, query.listPage(0, 2).size());
    assertEquals(sdf.parse("01/02/2008 02:02:02.000"), query.listPage(0, 2).get(0).getCreateTime());
    assertEquals(sdf.parse("05/02/2008 02:02:02.000"), query.listPage(0, 2).get(1).getCreateTime());
    // exclude subtasks
    query = taskService.createTaskQuery().taskAssignee("gonzo").excludeSubtasks().orderByTaskCreateTime().desc();
    assertEquals(2, query.count());
    assertEquals(1, query.listPage(1, 1).size());
    assertEquals(sdf.parse("01/02/2008 02:02:02.000"), query.listPage(1, 1).get(0).getCreateTime());
    assertEquals(1, query.listPage(0, 1).size());
    assertEquals(sdf.parse("05/02/2008 02:02:02.000"), query.listPage(0, 1).get(0).getCreateTime());
    // kermit has no root tasks and no subtasks assigned
    // include subtasks
    query = taskService.createTaskQuery().taskAssignee("kermit").orderByTaskCreateTime().asc();
    assertEquals(0, query.count());
    assertEquals(0, query.listPage(0, 2).size());
    assertNull(query.singleResult());
    // exclude subtasks
    query = taskService.createTaskQuery().taskAssignee("kermit").excludeSubtasks().orderByTaskCreateTime().desc();
    assertEquals(0, query.count());
    assertEquals(0, query.listPage(0, 2).size());
    assertNull(query.singleResult());
}
Also used : TaskQuery(org.activiti.engine.task.TaskQuery) SimpleDateFormat(java.text.SimpleDateFormat)

Example 63 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();
    assertEquals(7, query.count());
    assertEquals(7, query.list().size());
    assertEquals(sdf.parse("02/01/2009 01:01:01.000"), query.list().get(0).getCreateTime());
    // exclude subtasks
    query = taskService.createTaskQuery().taskAssignee("gonzo").excludeSubtasks().orderByTaskCreateTime().asc();
    assertEquals(2, query.count());
    assertEquals(2, query.list().size());
    assertEquals(sdf.parse("01/02/2008 02:02:02.000"), query.list().get(0).getCreateTime());
    assertEquals(sdf.parse("05/02/2008 02:02:02.000"), query.list().get(1).getCreateTime());
    // kermit has no root tasks and no subtasks assigned
    // include subtasks
    query = taskService.createTaskQuery().taskAssignee("kermit").orderByTaskCreateTime().asc();
    assertEquals(0, query.count());
    assertEquals(0, query.list().size());
    assertNull(query.singleResult());
    // exclude subtasks
    query = taskService.createTaskQuery().taskAssignee("kermit").excludeSubtasks().orderByTaskCreateTime().desc();
    assertEquals(0, query.count());
    assertEquals(0, query.list().size());
    assertNull(query.singleResult());
}
Also used : TaskQuery(org.activiti.engine.task.TaskQuery) SimpleDateFormat(java.text.SimpleDateFormat)

Example 64 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();
    assertEquals(10, query.count());
    assertEquals(10, query.list().size());
    // query only parent tasks (exclude subtasks)
    query = taskService.createTaskQuery().excludeSubtasks().orderByTaskAssignee().desc();
    assertEquals(3, query.count());
    assertEquals(3, query.list().size());
}
Also used : TaskQuery(org.activiti.engine.task.TaskQuery)

Example 65 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");
    assertEquals(7, query.count());
    assertEquals(7, query.list().size());
    // exclude subtasks
    query = taskService.createTaskQuery().taskAssignee("gonzo").excludeSubtasks();
    assertEquals(2, query.count());
    assertEquals(2, query.list().size());
    // kermit has no root tasks and no subtasks assigned
    // include subtasks
    query = taskService.createTaskQuery().taskAssignee("kermit");
    assertEquals(0, query.count());
    assertEquals(0, query.list().size());
    assertNull(query.singleResult());
    // exclude subtasks
    query = taskService.createTaskQuery().taskAssignee("kermit").excludeSubtasks();
    assertEquals(0, query.count());
    assertEquals(0, query.list().size());
    assertNull(query.singleResult());
}
Also used : TaskQuery(org.activiti.engine.task.TaskQuery)

Aggregations

TaskQuery (org.activiti.engine.task.TaskQuery)92 Task (org.activiti.engine.task.Task)32 Deployment (org.activiti.engine.test.Deployment)29 ActivitiException (org.activiti.engine.ActivitiException)19 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)19 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)12 ArrayList (java.util.ArrayList)10 SimpleDateFormat (java.text.SimpleDateFormat)8 Date (java.util.Date)7 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)6 DelegateTask (org.activiti.engine.delegate.DelegateTask)3 HistoricVariableInstance (org.activiti.engine.history.HistoricVariableInstance)3 HistoricVariableInstanceEntity (org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity)3 Job (org.activiti.engine.runtime.Job)3 HashMap (java.util.HashMap)2 TaskService (org.activiti.engine.TaskService)2 Test (org.testng.annotations.Test)2 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)1 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)1 PrismValue (com.evolveum.midpoint.prism.PrismValue)1