Package org.camunda.bpm.engine.task

Examples of org.camunda.bpm.engine.task.TaskQuery


  /**
   * test for task inclusion/exclusion (no other filters, no sort)
   */
  public void testQueryWithPagination() throws Exception {
    // query all tasks, including subtasks
    TaskQuery query = taskService.createTaskQuery();
    assertEquals(10, query.count());
    assertEquals(2, query.listPage(0, 2).size());
    // query only parent tasks (exclude subtasks)
    query = taskService.createTaskQuery().excludeSubtasks();
    assertEquals(3, query.count());
    assertEquals(1, query.listPage(0, 1).size());
  }
View Full Code Here


  /**
   * 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());
  }
View Full Code Here

   * 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());
  }
View Full Code Here

   * test for task inclusion/exclusion when additional filter is specified (like assignee), no order.
   */
  public void testQueryByAssigneeExcludeSubtasksPaginated() 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(2, query.listPage(0, 2).size());
    // exclude subtasks
    query = taskService.createTaskQuery().taskAssignee("gonzo").excludeSubtasks();
    assertEquals(2, query.count());
    assertEquals(1, query.listPage(0, 1).size());

    // kermit has no root tasks and no subtasks assigned
    // include subtasks
    query = taskService.createTaskQuery().taskAssignee("kermit");
    assertEquals(0, query.count());
    assertEquals(0, query.listPage(0, 2).size());
    assertNull(query.singleResult());
    // exclude subtasks
    query = taskService.createTaskQuery().taskAssignee("kermit").excludeSubtasks();
    assertEquals(0, query.count());
    assertEquals(0, query.listPage(0, 2).size());
    assertNull(query.singleResult());
  }
View Full Code Here

  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());
  }
View Full Code Here

  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());
  }
View Full Code Here

  @Deployment
  public void testSequentialSubProcessEndEvent() {
    // ACT-1185: end-event in subprocess causes inactivated execution
    String procId = runtimeService.startProcessInstanceByKey("miSequentialSubprocess").getId();

    TaskQuery query = taskService.createTaskQuery().orderByTaskName().asc();
    for (int i=0; i<4; i++) {
      List<Task> tasks = query.list();
      assertEquals(1, tasks.size());

      assertEquals("task one", tasks.get(0).getName());

      taskService.complete(tasks.get(0).getId());
View Full Code Here

  @Deployment
  public void testSequentialSubProcessCompletionCondition() {
    String procId = runtimeService.startProcessInstanceByKey("miSequentialSubprocessCompletionCondition").getId();

    TaskQuery query = taskService.createTaskQuery().orderByTaskName().asc();
    for (int i=0; i<3; i++) {
      List<Task> tasks = query.list();
      assertEquals(2, tasks.size());

      assertEquals("task one", tasks.get(0).getName());
      assertEquals("task two", tasks.get(1).getName());
View Full Code Here

//    assertEquals(1, processInstance.getChildInstances().size());
//    for (ActivityInstance subProcessInstance : processInstance.getChildInstances()) {
//      assertEquals(2, subProcessInstance.getChildInstances().size());
//    }

    TaskQuery query = taskService.createTaskQuery().orderByTaskName().asc();
    for (int i=0; i<4; i++) {
      List<Task> tasks = query.list();
      assertEquals(2, tasks.size());

      assertEquals("task one", tasks.get(0).getName());
      assertEquals("task two", tasks.get(1).getName());
View Full Code Here

 
  @Deployment
  public void testForkJoin() {

    ProcessInstance pi = runtimeService.startProcessInstanceByKey("forkJoin");
    TaskQuery query = taskService
                        .createTaskQuery()
                        .processInstanceId(pi.getId())
                        .orderByTaskName()
                        .asc();

    List<Task> tasks = query.list();
    assertEquals(2, tasks.size());
    // the tasks are ordered by name (see above)
    Task task1 = tasks.get(0);
    assertEquals("Receive Payment", task1.getName());
    Task task2 = tasks.get(1);
    assertEquals("Ship Order", task2.getName());
   
    // Completing both tasks will join the concurrent executions
    taskService.complete(tasks.get(0).getId());
    taskService.complete(tasks.get(1).getId());
   
    tasks = query.list();
    assertEquals(1, tasks.size());
    assertEquals("Archive Order", tasks.get(0).getName());
  }
View Full Code Here

TOP

Related Classes of org.camunda.bpm.engine.task.TaskQuery

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.