Search in sources :

Example 96 with ActivityInstance

use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.

the class ProcessInstanceModificationAsyncTest method testCancelAllTransitionInstanceInScope.

/**
 * CAM-4090
 */
@Deployment(resources = NESTED_ASYNC_BEFORE_TASK_PROCESS)
public void testCancelAllTransitionInstanceInScope() {
    // given there are two transition instances in an inner scope
    // and an active activity instance in an outer scope
    ProcessInstance instance = runtimeService.createProcessInstanceByKey("nestedOneTaskProcess").startBeforeActivity("innerTask").startBeforeActivity("innerTask").startBeforeActivity("outerTask").execute();
    ActivityInstance tree = runtimeService.getActivityInstance(instance.getId());
    // when i cancel both transition instances
    TransitionInstance[] transitionInstances = tree.getTransitionInstances("innerTask");
    runtimeService.createProcessInstanceModification(instance.getId()).cancelTransitionInstance(transitionInstances[0].getId()).cancelTransitionInstance(transitionInstances[1].getId()).execute();
    // then the outer activity instance is the only one remaining
    tree = runtimeService.getActivityInstance(instance.getId());
    assertThat(tree).hasStructure(describeActivityInstanceTree(instance.getProcessDefinitionId()).activity("outerTask").done());
    // assert executions
    ExecutionTree executionTree = ExecutionTree.forExecution(instance.getId(), processEngine);
    assertThat(executionTree).matches(describeExecutionTree("outerTask").scope().done());
}
Also used : TransitionInstance(org.camunda.bpm.engine.runtime.TransitionInstance) ExecutionAssert.describeExecutionTree(org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree) ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 97 with ActivityInstance

use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.

the class ProcessInstanceModificationAsyncTest method testStartBeforeSyncEndAndCancelSingleTransitionInstance.

/**
 * CAM-4090
 */
@Deployment(resources = NESTED_PARALLEL_ASYNC_BEFORE_SCOPE_TASK_PROCESS)
public void testStartBeforeSyncEndAndCancelSingleTransitionInstance() {
    // given there is one transition instance in a scope and an outer activity instance
    ProcessInstance instance = runtimeService.createProcessInstanceByKey("nestedConcurrentTasksProcess").startBeforeActivity("outerTask").startBeforeActivity("innerTask1").execute();
    ActivityInstance tree = runtimeService.getActivityInstance(instance.getId());
    TransitionInstance transitionInstance = tree.getTransitionInstances("innerTask1")[0];
    // when I start an activity in the same scope that ends immediately
    // and cancel the first transition instance
    runtimeService.createProcessInstanceModification(instance.getId()).startBeforeActivity("subProcessEnd2").cancelTransitionInstance(transitionInstance.getId()).execute();
    // then only the outer activity instance is left
    tree = runtimeService.getActivityInstance(instance.getId());
    assertThat(tree).hasStructure(describeActivityInstanceTree(instance.getProcessDefinitionId()).activity("outerTask").done());
    // assert executions
    ExecutionTree executionTree = ExecutionTree.forExecution(instance.getId(), processEngine);
    assertThat(executionTree).matches(describeExecutionTree("outerTask").scope().done());
}
Also used : TransitionInstance(org.camunda.bpm.engine.runtime.TransitionInstance) ExecutionAssert.describeExecutionTree(org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree) ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 98 with ActivityInstance

use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.

the class ProcessInstanceModificationBoundaryEventTest method testTask2AndStartBeforeTaskAfterBoundaryEventInsideSubProcess.

@Deployment(resources = INTERRUPTING_BOUNDARY_EVENT_INSIDE_SUBPROCESS)
public void testTask2AndStartBeforeTaskAfterBoundaryEventInsideSubProcess() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
    String processInstanceId = processInstance.getId();
    String taskId = taskService.createTaskQuery().singleResult().getId();
    taskService.complete(taskId);
    runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("innerTaskAfterBoundaryEvent").execute();
    ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
    assertNotNull(updatedTree);
    assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
    assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginScope("subProcess").activity("innerTask2").activity("innerTaskAfterBoundaryEvent").done());
    ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).scope().child("innerTaskAfterBoundaryEvent").concurrent().noScope().up().child("innerTask2").concurrent().noScope().done());
    completeTasksInOrder("innerTask2", "innerTaskAfterBoundaryEvent");
    assertProcessEnded(processInstanceId);
}
Also used : ExecutionAssert.describeExecutionTree(org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree) ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 99 with ActivityInstance

use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.

the class ProcessInstanceModificationBoundaryEventTest method testTask2AndStartBeforeNonInterruptingBoundaryEvent.

@Deployment(resources = NON_INTERRUPTING_BOUNDARY_EVENT)
public void testTask2AndStartBeforeNonInterruptingBoundaryEvent() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
    String processInstanceId = processInstance.getId();
    String taskId = taskService.createTaskQuery().singleResult().getId();
    taskService.complete(taskId);
    runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("boundaryEvent").execute();
    ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
    assertNotNull(updatedTree);
    assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
    assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("task2").activity("taskAfterBoundaryEvent").done());
    ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child("taskAfterBoundaryEvent").concurrent().noScope().up().child("task2").concurrent().noScope().done());
    completeTasksInOrder("task2", "taskAfterBoundaryEvent");
    assertProcessEnded(processInstanceId);
}
Also used : ExecutionAssert.describeExecutionTree(org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree) ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 100 with ActivityInstance

use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.

the class ProcessInstanceModificationBoundaryEventTest method testTask2AndStartBeforeTaskAfterNonInterruptingBoundaryEvent.

@Deployment(resources = NON_INTERRUPTING_BOUNDARY_EVENT)
public void testTask2AndStartBeforeTaskAfterNonInterruptingBoundaryEvent() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
    String processInstanceId = processInstance.getId();
    String taskId = taskService.createTaskQuery().singleResult().getId();
    taskService.complete(taskId);
    runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("taskAfterBoundaryEvent").execute();
    ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
    assertNotNull(updatedTree);
    assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
    assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("task2").activity("taskAfterBoundaryEvent").done());
    ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child("taskAfterBoundaryEvent").concurrent().noScope().up().child("task2").concurrent().noScope().done());
    completeTasksInOrder("task2", "taskAfterBoundaryEvent");
    assertProcessEnded(processInstanceId);
}
Also used : ExecutionAssert.describeExecutionTree(org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree) ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)427 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)372 Deployment (org.camunda.bpm.engine.test.Deployment)277 Test (org.junit.Test)159 ExecutionTree (org.camunda.bpm.engine.test.util.ExecutionTree)130 ExecutionAssert.describeExecutionTree (org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree)129 Task (org.camunda.bpm.engine.task.Task)108 ScenarioUnderTest (org.camunda.bpm.qa.upgrade.ScenarioUnderTest)80 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)56 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)54 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)47 TransitionInstance (org.camunda.bpm.engine.runtime.TransitionInstance)31 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)22 Job (org.camunda.bpm.engine.runtime.Job)21 Batch (org.camunda.bpm.engine.batch.Batch)15 DeploymentWithDefinitions (org.camunda.bpm.engine.repository.DeploymentWithDefinitions)12 Execution (org.camunda.bpm.engine.runtime.Execution)12 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)10 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)10 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)9