Package org.camunda.bpm.engine.runtime

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


    runtimeService.startProcessInstanceByKey("process");

    // send message
    runtimeService.correlateMessage("message");

    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


    INVOCATION = false;
    // start process
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("asyncService");

    // now we have one transition instance below the process instance:
    ActivityInstance activityInstance = runtimeService.getActivityInstance(processInstance.getId());
    assertEquals(1, activityInstance.getChildTransitionInstances().length);
    assertEquals(0, activityInstance.getChildActivityInstances().length);

    assertNotNull(activityInstance.getChildTransitionInstances()[0]);

    // now there should be one job in the database:
    assertEquals(1, managementService.createJobQuery().count());
    // the service was not invoked:
    assertFalse(INVOCATION);
View Full Code Here

  @Override
  public ActivityInstanceDto getActivityInstanceTree() {
    RuntimeService runtimeService = engine.getRuntimeService();

    ActivityInstance activityInstance = null;

    try {
      activityInstance = runtimeService.getActivityInstance(processInstanceId);
    } catch (ProcessEngineException e) {
      throw new InvalidRequestException(Status.INTERNAL_SERVER_ERROR, e, e.getMessage());
View Full Code Here

    String procId = processInstance.getId();

    // now there is now 1 activity instance below the pi:
    ActivityInstance[] childInstances = runtimeService.getActivityInstance(processInstance.getId()).getChildActivityInstances();
    assertEquals(1, childInstances.length);
    ActivityInstance firstActInstance = childInstances[0];
    assertEquals(processInstance.getId(), firstActInstance.getParentActivityInstanceId());

    Task task = taskService.createTaskQuery().singleResult();
    assertEquals("My Task", task.getName());
    assertEquals("kermit_0", task.getAssignee());
    taskService.complete(task.getId());

    childInstances = runtimeService.getActivityInstance(processInstance.getId()).getChildActivityInstances();
    assertEquals(1, childInstances.length);
    assertFalse(childInstances[0].getId().equals(firstActInstance.getId()));

    task = taskService.createTaskQuery().singleResult();
    assertEquals("My Task", task.getName());
    assertEquals("kermit_1", task.getAssignee());
    taskService.complete(task.getId());

    childInstances = runtimeService.getActivityInstance(processInstance.getId()).getChildActivityInstances();
    assertEquals(1, childInstances.length);
    assertFalse(childInstances[0].getId().equals(firstActInstance.getId()));

    task = taskService.createTaskQuery().singleResult();
    assertEquals("My Task", task.getName());
    assertEquals("kermit_2", task.getAssignee());
    taskService.complete(task.getId());
View Full Code Here

    String procId = runtimeService.startProcessInstanceByKey("miNestedSequentialUserTasks").getId();

    for (int i=0; i<3; i++) {
      Task task = taskService.createTaskQuery().taskAssignee("kermit").singleResult();
      assertEquals("My Task", task.getName());
      ActivityInstance processInstance = runtimeService.getActivityInstance(procId);
      List<ActivityInstance> instancesForActivitiyId = getInstancesForActivitiyId(processInstance, "miTasks");
      assertEquals(1, instancesForActivitiyId.size());
      ActivityInstance userTaskActInst = instancesForActivitiyId.get(0);
      taskService.complete(task.getId());
    }

    assertProcessEnded(procId);
  }
View Full Code Here

    assertEquals(3, tasks.size());
    assertEquals("My Task 0", tasks.get(0).getName());
    assertEquals("My Task 1", tasks.get(1).getName());
    assertEquals("My Task 2", tasks.get(2).getName());

    ActivityInstance processInstance = runtimeService.getActivityInstance(procId);
    assertEquals(3, processInstance.getChildActivityInstances().length);

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

    processInstance = runtimeService.getActivityInstance(procId);

    assertEquals(2, processInstance.getChildActivityInstances().length);

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

    processInstance = runtimeService.getActivityInstance(procId);
    assertEquals(1, processInstance.getChildActivityInstances().length);

    taskService.complete(tasks.get(2).getId());
    assertProcessEnded(procId);
  }
View Full Code Here

  @Deployment
  public void testSubProcessVariablesWithParallelGateway() {
    // given
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("processWithSubProcess");

    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    assertNotNull(tree);
    assertEquals(5, tree.getChildActivityInstances().length);

    //when
    String activityInstanceId1 = tree.getChildActivityInstances()[0].getId();
    VariableInstanceQuery query1 = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(activityInstanceId1);

    String activityInstanceId2 = tree.getChildActivityInstances()[1].getId();
    VariableInstanceQuery query2 = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(activityInstanceId2);

    String activityInstanceId3 = tree.getChildActivityInstances()[2].getId();
    VariableInstanceQuery query3 = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(activityInstanceId3);

    String activityInstanceId4 = tree.getChildActivityInstances()[3].getId();
    VariableInstanceQuery query4 = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(activityInstanceId4);

    String activityInstanceId5 = tree.getChildActivityInstances()[4].getId();
    VariableInstanceQuery query5 = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(activityInstanceId5);

    // then
    checkVariables(query1.list());
    checkVariables(query2.list());
View Full Code Here

    // given
    Map<String, Object> processVariables = new HashMap<String, Object>();
    processVariables.put("processVariable", "aProcessVariable");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("processWithSubProcess", processVariables);

    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    assertNotNull(tree);
    assertEquals(1, tree.getChildActivityInstances().length);

    // when
    VariableInstanceQuery query1 = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(tree.getId());

    // then
    VariableInstance processVariable = query1.singleResult();
    assertNotNull(processVariable);
    assertEquals("processVariable", processVariable.getName());
    assertEquals("aProcessVariable", processVariable.getValue());

    // when
    ActivityInstance subProcessActivityInstance = tree.getChildActivityInstances()[0];
    VariableInstanceQuery query2 = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(subProcessActivityInstance.getId());

    // then
    checkVariables(query2.list());

    // when setting a task local variable
    Task task = taskService.createTaskQuery().singleResult();
    taskService.setVariableLocal(task.getId(), "taskVariable", "taskVariableValue");

    ActivityInstance taskActivityInstance = subProcessActivityInstance.getChildActivityInstances()[0];
    VariableInstanceQuery query3 = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(taskActivityInstance.getId());

    // then
    VariableInstance taskVariable = query3.singleResult();
    assertNotNull(taskVariable);
    assertEquals("taskVariable", taskVariable.getName());
View Full Code Here

    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("parallelGatewayProcess", processVariables);

    Execution execution = runtimeService.createExecutionQuery().activityId("task1").singleResult();
    runtimeService.setVariableLocal(execution.getId(), "aLocalVariable", "aLocalValue");

    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    assertEquals(2, tree.getChildActivityInstances().length);
    ActivityInstance task1Instance = tree.getChildActivityInstances()[0];
    if (!task1Instance.getActivityId().equals("task1")) {
      task1Instance = tree.getChildActivityInstances()[1];
    }

    VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(task1Instance.getId());
    VariableInstance localVariable = query.singleResult();
    assertNotNull(localVariable);
    assertEquals("aLocalVariable", localVariable.getName());
    assertEquals("aLocalValue", localVariable.getValue());

    Task task = taskService.createTaskQuery().executionId(execution.getId()).singleResult();
    taskService.complete(task.getId());

    tree = runtimeService.getActivityInstance(processInstance.getId());
    assertEquals(2, tree.getChildActivityInstances().length);
    ActivityInstance task3Instance = tree.getChildActivityInstances()[0];
    if (!task3Instance.getActivityId().equals("task3")) {
      task3Instance = tree.getChildActivityInstances()[1];
    }

    query = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(task3Instance.getId());
    localVariable = query.singleResult();
    assertNotNull(localVariable);
    assertEquals("aLocalVariable", localVariable.getName());
    assertEquals("aLocalValue", localVariable.getValue());
  }
View Full Code Here

    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("processWithSubProcess", processVariables);

    Task task = taskService.createTaskQuery().taskDefinitionKey("UserTask_1").singleResult();
    runtimeService.setVariableLocal(task.getExecutionId(), "aLocalVariable", "aLocalValue");

    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    assertEquals(1, tree.getChildActivityInstances().length);
    ActivityInstance task1Instance = tree.getChildActivityInstances()[0];
    if (!task1Instance.getActivityId().equals("UserTask_1")) {
      task1Instance = tree.getChildActivityInstances()[0];
    }

    // then the local variable has activity instance Id of the subprocess
    VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(task1Instance.getId());
    VariableInstance localVariable = query.singleResult();
    assertNotNull(localVariable);
    assertEquals("aLocalVariable", localVariable.getName());
    assertEquals("aLocalValue", localVariable.getValue());
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.