Package org.activiti.engine.task

Examples of org.activiti.engine.task.TaskQuery


  @Deployment
  public void testNestedForkJoin() {
   runtimeService.startProcessInstanceByKey("nestedForkJoin");
  
   // After process startm, only task 0 should be active
   TaskQuery query = taskService.createTaskQuery().orderByTaskName().asc();
   List<Task> tasks = query.list();
   assertEquals(1, tasks.size());
   assertEquals("Task 0", tasks.get(0).getName());
  
   // Completing task 0 will create Task A and B
   taskService.complete(tasks.get(0).getId());
   tasks = query.list();
   assertEquals(2, tasks.size());
   assertEquals("Task A", tasks.get(0).getName());
   assertEquals("Task B", tasks.get(1).getName());
  
   // Completing task A should not trigger any new tasks
   taskService.complete(tasks.get(0).getId());
   tasks = query.list();
   assertEquals(1, tasks.size());
   assertEquals("Task B", tasks.get(0).getName());

   // Completing task B creates tasks B1 and B2
   taskService.complete(tasks.get(0).getId());
   tasks = query.list();
   assertEquals(2, tasks.size());
   assertEquals("Task B1", tasks.get(0).getName());
   assertEquals("Task B2", tasks.get(1).getName());
  
   // Completing B1 and B2 will activate both joins, and process reaches task C
   taskService.complete(tasks.get(0).getId());
   taskService.complete(tasks.get(1).getId());
   tasks = query.list();
   assertEquals(1, tasks.size());
   assertEquals("Task C", tasks.get(0).getName());  
  }
View Full Code Here


  @Deployment
  public void testReceyclingExecutionWithCallActivity() {
    runtimeService.startProcessInstanceByKey("parent-process");
   
    // After process start we have two tasks, one from the parent and one from the sub process
    TaskQuery query = taskService.createTaskQuery().orderByTaskName().asc();
    List<Task> tasks = query.list();
    assertEquals(2, tasks.size());
    assertEquals("Another task", tasks.get(0).getName());
    assertEquals("Some Task", tasks.get(1).getName());
   
    // we complete the task from the parent process, the root execution is receycled, the task in the sub process is still there
    taskService.complete(tasks.get(1).getId());
    tasks = query.list();
    assertEquals(1, tasks.size());
    assertEquals("Another task", tasks.get(0).getName());

    // we end the task in the sub process and the sub process instance end is propagated to the parent process
    taskService.complete(tasks.get(0).getId());
View Full Code Here

  }

  @Deployment
  public void testTimerWithCycle() throws Exception {
    runtimeService.startProcessInstanceByKey("nonInterruptingCycle").getId();
    TaskQuery tq = taskService.createTaskQuery().taskDefinitionKey("timerFiredTask");
    assertEquals(0, tq.count());
    moveByHours(1);
    assertEquals(1, tq.count());
    moveByHours(1);
    assertEquals(2, tq.count());

    Task task = taskService.createTaskQuery().taskDefinitionKey("task").singleResult();
    taskService.complete(task.getId());

    moveByHours(1);
    assertEquals(2, tq.count());
  }
View Full Code Here

   * see http://jira.codehaus.org/browse/ACT-1173
   */
  public void testTimerOnEmbeddedSubprocess() {
    String id = runtimeService.startProcessInstanceByKey("nonInterruptingTimerOnEmbeddedSubprocess").getId();
   
    TaskQuery tq = taskService.createTaskQuery().taskAssignee("kermit");
   
    assertEquals(1, tq.count());
   
    // Simulate timer
    Job timer = managementService.createJobQuery().singleResult();
    managementService.executeJob(timer.getId());
   
    tq = taskService.createTaskQuery().taskAssignee("kermit");
   
    assertEquals(2, tq.count());
   
    List<Task> tasks = tq.list();
   
    taskService.complete(tasks.get(0).getId());
    taskService.complete(tasks.get(1).getId());
   
    assertProcessEnded(id);
View Full Code Here

    tasks = taskService.createTaskQuery().taskCandidateUser("fozzie").list();
    assertEquals(1, tasks.size());
    assertEquals("make profit", tasks.get(0).getName());

    // Test the task query find-by-candidate-group operation
    TaskQuery query = taskService.createTaskQuery();
    assertEquals(1, query.taskCandidateGroup("management").count());
    assertEquals(1, query.taskCandidateGroup("accountancy").count());
  }
View Full Code Here

  @Deployment
  public void IGNORE_testSimpleSubProcessWithConcurrentTimer() {
   
    // After staring the process, the task in the subprocess should be active
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("simpleSubProcessWithConcurrentTimer");
    TaskQuery taskQuery = taskService
      .createTaskQuery()
      .processInstanceId(pi.getId())
      .orderByTaskName()
      .asc();
   
    Task subProcessTask = taskQuery.singleResult();
    assertEquals("Task in subprocess", subProcessTask.getName());
   
    // When the timer is fired (after 2 hours), two concurrent paths should be created
    Job job = managementService.createJobQuery().singleResult();
    managementService.executeJob(job.getId());
   
    List<Task> tasksAfterTimer = taskQuery.list();
    assertEquals(2, tasksAfterTimer.size());
    Task taskAfterTimer1 = tasksAfterTimer.get(0);
    Task taskAfterTimer2 = tasksAfterTimer.get(1);
    assertEquals("Task after timer 1", taskAfterTimer1.getName());
    assertEquals("Task after timer 2", taskAfterTimer2.getName());
View Full Code Here

  }
 
  @Deployment
  public void testTwoSubProcessInParallel() {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("twoSubProcessInParallel");
    TaskQuery taskQuery = taskService
      .createTaskQuery()
      .processInstanceId(pi.getId())
      .orderByTaskName()
      .asc();
    List<Task> tasks = taskQuery.list();
   
    // After process start, both tasks in the subprocesses should be active
    assertEquals("Task in subprocess A", tasks.get(0).getName());
    assertEquals("Task in subprocess B", tasks.get(1).getName());
   
    // Completing both tasks should active the tasks outside the subprocesses
    taskService.complete(tasks.get(0).getId());
   
    tasks = taskQuery.list();
    assertEquals("Task after subprocess A", tasks.get(0).getName());
    assertEquals("Task in subprocess B", tasks.get(1).getName());

    taskService.complete(tasks.get(1).getId());

    tasks = taskQuery.list();
   
    assertEquals("Task after subprocess A", tasks.get(0).getName());
    assertEquals("Task after subprocess B", tasks.get(1).getName());
   
    // Completing these tasks should end the process
View Full Code Here

  }
 
  @Deployment
  public void testTwoSubProcessInParallelWithinSubProcess() {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("twoSubProcessInParallelWithinSubProcess");
    TaskQuery taskQuery = taskService
      .createTaskQuery()
      .processInstanceId(pi.getId())
      .orderByTaskName()
      .asc();
    List<Task> tasks = taskQuery.list();
   
    // After process start, both tasks in the subprocesses should be active
    Task taskA = tasks.get(0);
    Task taskB = tasks.get(1);
    assertEquals("Task in subprocess A", taskA.getName());
    assertEquals("Task in subprocess B", taskB.getName());
   
    // Completing both tasks should active the tasks outside the subprocesses
    taskService.complete(taskA.getId());
    taskService.complete(taskB.getId());
   
    Task taskAfterSubProcess = taskQuery.singleResult();
    assertEquals("Task after subprocess", taskAfterSubProcess.getName());
   
    // Completing this task should end the process
    taskService.complete(taskAfterSubProcess.getId());
    assertProcessEnded(pi.getId());
View Full Code Here

  public void testTwoNestedSubProcessesInParallelWithTimer() {
   
//    Date startTime = new Date();
   
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("nestedParallelSubProcessesWithTimer");
    TaskQuery taskQuery = taskService
      .createTaskQuery()
      .processInstanceId(pi.getId())
      .orderByTaskName()
      .asc();
    List<Task> tasks = taskQuery.list();
   
    // After process start, both tasks in the subprocesses should be active
    Task taskA = tasks.get(0);
    Task taskB = tasks.get(1);
    assertEquals("Task in subprocess A", taskA.getName());
    assertEquals("Task in subprocess B", taskB.getName());
   
    // Firing the timer should destroy all three subprocesses and activate the task after the timer
//    processEngineConfiguration.getClock().setCurrentTime(new Date(startTime.getTime() + (2 * 60 * 60 * 1000 ) + 1000));
//    waitForJobExecutorToProcessAllJobs(5000L, 50L);
    Job job = managementService.createJobQuery().singleResult();
    managementService.executeJob(job.getId());
   
    Task taskAfterTimer = taskQuery.singleResult();
    assertEquals("Task after timer", taskAfterTimer.getName());
   
    // Completing the task should end the process instance
    taskService.complete(taskAfterTimer.getId());
    assertProcessEnded(pi.getId());
View Full Code Here

      // OK
    }
  }

  public void testQueryByDelegationState() {
    TaskQuery query = taskService.createTaskQuery().taskDelegationState(null);
    assertEquals(12, query.count());
    assertEquals(12, query.list().size());
    query = taskService.createTaskQuery().taskDelegationState(DelegationState.PENDING);
    assertEquals(0, query.count());
    assertEquals(0, query.list().size());
    query = taskService.createTaskQuery().taskDelegationState(DelegationState.RESOLVED);
    assertEquals(0, query.count());
    assertEquals(0, query.list().size());

    String taskId= taskService.createTaskQuery().taskAssignee("gonzo").singleResult().getId();
    taskService.delegateTask(taskId, "kermit");

    query = taskService.createTaskQuery().taskDelegationState(null);
    assertEquals(11, query.count());
    assertEquals(11, query.list().size());
    query = taskService.createTaskQuery().taskDelegationState(DelegationState.PENDING);
    assertEquals(1, query.count());
    assertEquals(1, query.list().size());
    query = taskService.createTaskQuery().taskDelegationState(DelegationState.RESOLVED);
    assertEquals(0, query.count());
    assertEquals(0, query.list().size());

    taskService.resolveTask(taskId);

    query = taskService.createTaskQuery().taskDelegationState(null);
    assertEquals(11, query.count());
    assertEquals(11, query.list().size());
    query = taskService.createTaskQuery().taskDelegationState(DelegationState.PENDING);
    assertEquals(0, query.count());
    assertEquals(0, query.list().size());
    query = taskService.createTaskQuery().taskDelegationState(DelegationState.RESOLVED);
    assertEquals(1, query.count());
    assertEquals(1, query.list().size());
  }
View Full Code Here

TOP

Related Classes of org.activiti.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.