Package org.camunda.bpm.engine.runtime

Examples of org.camunda.bpm.engine.runtime.ActivityInstance


    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("compensateProcess");

    List<Task> compensationHandlerTasks = taskService.createTaskQuery().taskDefinitionKey("undoBookHotel").list();
    assertEquals(5, compensationHandlerTasks.size());

    ActivityInstance rootActivityInstance = runtimeService.getActivityInstance(processInstance.getId());
    List<ActivityInstance> compensationHandlerInstances = getInstancesForActivitiyId(rootActivityInstance, "undoBookHotel");
    assertEquals(5, compensationHandlerInstances.size());

    for (Task task : compensationHandlerTasks) {
      taskService.complete(task.getId());
View Full Code Here


  "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"})
  public void testActivityInstancePopulated() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", "business-key");

    // validate properties of root
    ActivityInstance rootActInstance = runtimeService.getActivityInstance(processInstance.getId());
    assertEquals(processInstance.getId(), rootActInstance.getProcessInstanceId());
    assertEquals(processInstance.getProcessDefinitionId(), rootActInstance.getProcessDefinitionId());
    assertEquals(processInstance.getId(), rootActInstance.getProcessInstanceId());
    assertTrue(rootActInstance.getExecutionIds()[0].equals(processInstance.getId()));
    assertEquals(rootActInstance.getProcessDefinitionId(), rootActInstance.getActivityId());
    assertNull(rootActInstance.getParentActivityInstanceId());
    assertEquals("processDefinition", rootActInstance.getActivityType());

    // validate properties of child:
    Task task = taskService.createTaskQuery().singleResult();
    ActivityInstance childActivityInstance = rootActInstance.getChildActivityInstances()[0];
    assertEquals(processInstance.getId(), childActivityInstance.getProcessInstanceId());
    assertEquals(processInstance.getProcessDefinitionId(), childActivityInstance.getProcessDefinitionId());
    assertEquals(processInstance.getId(), childActivityInstance.getProcessInstanceId());
    assertTrue(childActivityInstance.getExecutionIds()[0].equals(task.getExecutionId()));
    assertEquals("theTask", childActivityInstance.getActivityId());
    assertEquals(rootActInstance.getId(), childActivityInstance.getParentActivityInstanceId());
    assertEquals("userTask", childActivityInstance.getActivityType());
    assertNotNull(childActivityInstance.getChildActivityInstances());
    assertNotNull(childActivityInstance.getChildTransitionInstances());
    assertEquals(0, childActivityInstance.getChildActivityInstances().length);
    assertEquals(0, childActivityInstance.getChildTransitionInstances().length);

  }
View Full Code Here

                                                   .singleResult();
    assertEquals("Task in subprocess", subProcessTask.getName());

    // we have 3 levels in the activityInstance:
    // pd
    ActivityInstance rootActivityInstance = runtimeService.getActivityInstance(pi.getProcessInstanceId());
    assertEquals(pi.getProcessDefinitionId(), rootActivityInstance.getActivityId());
    //subprocess
    assertEquals(1, rootActivityInstance.getChildActivityInstances().length);
    ActivityInstance subProcessInstance = rootActivityInstance.getChildActivityInstances()[0];
    assertEquals("subProcess", subProcessInstance.getActivityId());
    // usertask
    assertEquals(1, subProcessInstance.getChildActivityInstances().length);
    ActivityInstance userTaskInstance = subProcessInstance.getChildActivityInstances()[0];
    assertEquals("subProcessTask", userTaskInstance.getActivityId());

    // After completing the task in the subprocess,
    // the subprocess scope is destroyed and the complete process ends
    taskService.complete(subProcessTask.getId());
    assertNull(runtimeService.createProcessInstanceQuery().processInstanceId(pi.getId()).singleResult());
View Full Code Here

                                                   .singleResult();
    assertEquals("Task in subprocess", subProcessTask.getName());

    // we have 3 levels in the activityInstance:
    // pd
    ActivityInstance rootActivityInstance = runtimeService.getActivityInstance(pi.getProcessInstanceId());
    assertEquals(pi.getProcessDefinitionId(), rootActivityInstance.getActivityId());
    //subprocess
    assertEquals(1, rootActivityInstance.getChildActivityInstances().length);
    ActivityInstance subProcessInstance = rootActivityInstance.getChildActivityInstances()[0];
    assertEquals("subProcess", subProcessInstance.getActivityId());
    // usertask
    assertEquals(1, subProcessInstance.getChildActivityInstances().length);
    ActivityInstance userTaskInstance = subProcessInstance.getChildActivityInstances()[0];
    assertEquals("subProcessTask", userTaskInstance.getActivityId());

    // Setting the clock forward 2 hours 1 second (timer fires in 2 hours) and fire up the job executor
    ClockUtil.setCurrentTime(new Date(startTime.getTime() + (2 * 60 * 60 * 1000 ) + 1000));
    waitForJobExecutorToProcessAllJobs(5000L);

View Full Code Here

    Task subProcessTask = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("Task in subprocess", subProcessTask.getName());

    // now we have 4 levels in the activityInstance:
    // pd
    ActivityInstance rootActivityInstance = runtimeService.getActivityInstance(pi.getProcessInstanceId());
    assertEquals(pi.getProcessDefinitionId(), rootActivityInstance.getActivityId());
    //subprocess1
    assertEquals(1, rootActivityInstance.getChildActivityInstances().length);
    ActivityInstance subProcessInstance1 = rootActivityInstance.getChildActivityInstances()[0];
    assertEquals("outerSubProcess", subProcessInstance1.getActivityId());
    //subprocess2
    assertEquals(1, rootActivityInstance.getChildActivityInstances().length);
    ActivityInstance subProcessInstance2 = subProcessInstance1.getChildActivityInstances()[0];
    assertEquals("innerSubProcess", subProcessInstance2.getActivityId());
    // usertask
    assertEquals(1, subProcessInstance2.getChildActivityInstances().length);
    ActivityInstance userTaskInstance = subProcessInstance2.getChildActivityInstances()[0];
    assertEquals("innerSubProcessTask", userTaskInstance.getActivityId());

    // After completing the task in the subprocess,
    // both subprocesses are destroyed and the task after the subprocess should be active
    taskService.complete(subProcessTask.getId());
    Task taskAfterSubProcesses = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
View Full Code Here

    Task subProcessTask = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("Task in subprocess", subProcessTask.getName());

    // now we have 4 levels in the activityInstance:
    // pd
    ActivityInstance rootActivityInstance = runtimeService.getActivityInstance(pi.getProcessInstanceId());
    assertEquals(pi.getProcessDefinitionId(), rootActivityInstance.getActivityId());
    //subprocess1
    assertEquals(1, rootActivityInstance.getChildActivityInstances().length);
    ActivityInstance subProcessInstance1 = rootActivityInstance.getChildActivityInstances()[0];
    assertEquals("outerSubProcess", subProcessInstance1.getActivityId());
    //subprocess2
    assertEquals(1, rootActivityInstance.getChildActivityInstances().length);
    ActivityInstance subProcessInstance2 = subProcessInstance1.getChildActivityInstances()[0];
    assertEquals("innerSubProcess", subProcessInstance2.getActivityId());
    // usertask
    assertEquals(1, subProcessInstance2.getChildActivityInstances().length);
    ActivityInstance userTaskInstance = subProcessInstance2.getChildActivityInstances()[0];
    assertEquals("innerSubProcessTask", userTaskInstance.getActivityId());

    // Setting the clock forward 1 hour 1 second (timer fires in 1 hour) and fire up the job executor
    ClockUtil.setCurrentTime(new Date(startTime.getTime() + ( 60 * 60 * 1000 ) + 1000));
    waitForJobExecutorToProcessAllJobs(5000L);

    // The inner subprocess should be destoyed, and the escalated task should be active
    Task escalationTask = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("Escalated task", escalationTask.getName());

    // now we have 3 levels in the activityInstance:
    // pd
    rootActivityInstance = runtimeService.getActivityInstance(pi.getProcessInstanceId());
    assertEquals(pi.getProcessDefinitionId(), rootActivityInstance.getActivityId());
    //subprocess1
    assertEquals(1, rootActivityInstance.getChildActivityInstances().length);
    subProcessInstance1 = rootActivityInstance.getChildActivityInstances()[0];
    assertEquals("outerSubProcess", subProcessInstance1.getActivityId());
    //subprocess2
    assertEquals(1, rootActivityInstance.getChildActivityInstances().length);
    ActivityInstance escalationTaskInst = subProcessInstance1.getChildActivityInstances()[0];
    assertEquals("escalationTask", escalationTaskInst.getActivityId());

    // Completing the escalated task, destroys the outer scope and activates the task after the subprocess
    taskService.complete(escalationTask.getId());
    Task taskAfterSubProcess = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("Task after subprocesses", taskAfterSubProcess.getName());
View Full Code Here

    Task taskA = subProcessTasks.get(0);
    Task taskB = subProcessTasks.get(1);
    assertEquals("Task A", taskA.getName());
    assertEquals("Task B", taskB.getName());

    ActivityInstance rootActivityInstance = runtimeService.getActivityInstance(pi.getProcessInstanceId());
    assertEquals(pi.getProcessDefinitionId(), rootActivityInstance.getActivityId());
    //subprocess1
    assertEquals(1, rootActivityInstance.getChildActivityInstances().length);
    ActivityInstance subProcessInstance = rootActivityInstance.getChildActivityInstances()[0];
    assertEquals("subProcess", subProcessInstance.getActivityId());
    // 2 tasks are present
    assertEquals(2, subProcessInstance.getChildActivityInstances().length);

    // Completing both tasks, should destroy the subprocess and activate the task after the subprocess
    taskService.complete(taskA.getId());

    rootActivityInstance = runtimeService.getActivityInstance(pi.getProcessInstanceId());
    assertEquals(pi.getProcessDefinitionId(), rootActivityInstance.getActivityId());
    subProcessInstance = rootActivityInstance.getChildActivityInstances()[0];
    // 1 task + 1 join
    assertEquals(2, subProcessInstance.getChildActivityInstances().length);

    taskService.complete(taskB.getId());
    Task taskAfterSubProcess = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("Task after sub process", taskAfterSubProcess.getName());
  }
View Full Code Here

    // 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());

    // validate activity instance tree
    ActivityInstance rootActivityInstance = runtimeService.getActivityInstance(pi.getProcessInstanceId());
    assertEquals(pi.getProcessDefinitionId(), rootActivityInstance.getActivityId());
    assertEquals(2, rootActivityInstance.getChildActivityInstances().length);
    ActivityInstance[] childActivityInstances = rootActivityInstance.getChildActivityInstances();
    for (ActivityInstance activityInstance : childActivityInstances) {
      assertTrue(Arrays.asList(new String[]{"subProcessA", "subProcessB"}).contains(activityInstance.getActivityId()));
      ActivityInstance[] subProcessChildren = activityInstance.getChildActivityInstances();
      assertEquals(1, subProcessChildren.length);
      assertTrue(Arrays.asList(new String[]{"subProcessATask", "subProcessBTask"}).contains(subProcessChildren[0].getActivityId()));
View Full Code Here

    Task taskB = tasks.get(1);
    assertEquals("Task in subprocess A", taskA.getName());
    assertEquals("Task in subprocess B", taskB.getName());

    // validate activity instance tree
    ActivityInstance rootActivityInstance = runtimeService.getActivityInstance(pi.getProcessInstanceId());
    assertEquals(pi.getProcessDefinitionId(), rootActivityInstance.getActivityId());
    assertEquals(1, rootActivityInstance.getChildActivityInstances().length);
    ActivityInstance outerSubProcessInstance = rootActivityInstance.getChildActivityInstances()[0];
    assertEquals("outerSubProcess", outerSubProcessInstance.getActivityId());
    ActivityInstance[] childActivityInstances = outerSubProcessInstance.getChildActivityInstances();
    for (ActivityInstance activityInstance : childActivityInstances) {
      assertTrue(Arrays.asList(new String[]{"subProcessA", "subProcessB"}).contains(activityInstance.getActivityId()));
      ActivityInstance[] subProcessChildren = activityInstance.getChildActivityInstances();
      assertEquals(1, subProcessChildren.length);
      assertTrue(Arrays.asList(new String[]{"subProcessATask", "subProcessBTask"}).contains(subProcessChildren[0].getActivityId()));
View Full Code Here

  // SEE https://app.camunda.com/jira/browse/CAM-2169
  public void testActivityInstanceTreeNestedCmd() {
    GetActInstanceDelegate.activityInstance = null;
    runtimeService.startProcessInstanceByKey("process");

    ActivityInstance activityInstance = GetActInstanceDelegate.activityInstance;

    assertNotNull(activityInstance);
    ActivityInstance subProcessInstance = activityInstance.getChildActivityInstances()[0];
    assertNotNull(subProcessInstance);
    assertEquals("SubProcess_1", subProcessInstance.getActivityId());

    ActivityInstance serviceTaskInstance = subProcessInstance.getChildActivityInstances()[0];
    assertNotNull(serviceTaskInstance);
    assertEquals("ServiceTask_1", serviceTaskInstance.getActivityId());
  }
View Full Code Here

TOP

Related Classes of org.camunda.bpm.engine.runtime.ActivityInstance

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.