Search in sources :

Example 16 with TransitionInstance

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

the class ProcessInstanceModificationAsyncTest method testRepeatedStartAndCancellationForTransitionInstance.

/**
 * CAM-4090
 */
@Deployment(resources = NESTED_PARALLEL_ASYNC_BEFORE_SCOPE_TASK_PROCESS)
public void testRepeatedStartAndCancellationForTransitionInstance() {
    // given there is one transition instance in a scope
    ProcessInstance instance = runtimeService.createProcessInstanceByKey("nestedConcurrentTasksProcess").startBeforeActivity("innerTask1").execute();
    ActivityInstance tree = runtimeService.getActivityInstance(instance.getId());
    TransitionInstance transitionInstance = tree.getTransitionInstances("innerTask1")[0];
    // when I start an activity in the same scope
    // and cancel the first transition instance
    runtimeService.createProcessInstanceModification(instance.getId()).startBeforeActivity(// expand tree
    "innerTask2").cancelAllForActivity(// compact tree
    "innerTask2").startBeforeActivity(// expand tree
    "innerTask2").cancelAllForActivity(// compact tree
    "innerTask2").startBeforeActivity(// expand tree
    "innerTask2").cancelAllForActivity(// compact tree
    "innerTask2").cancelTransitionInstance(transitionInstance.getId()).execute();
    // then the process has ended
    assertProcessEnded(instance.getId());
}
Also used : TransitionInstance(org.camunda.bpm.engine.runtime.TransitionInstance) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 17 with TransitionInstance

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

the class ProcessInstanceModificationAsyncTest method testStartBeforeAndCancelSingleTransitionInstance.

/**
 * CAM-4090
 */
@Deployment(resources = NESTED_PARALLEL_ASYNC_BEFORE_SCOPE_TASK_PROCESS)
public void testStartBeforeAndCancelSingleTransitionInstance() {
    // given there is one transition instance in a scope
    ProcessInstance instance = runtimeService.createProcessInstanceByKey("nestedConcurrentTasksProcess").startBeforeActivity("innerTask1").execute();
    ActivityInstance tree = runtimeService.getActivityInstance(instance.getId());
    TransitionInstance transitionInstance = tree.getTransitionInstances("innerTask1")[0];
    // when I start an activity in the same scope
    // and cancel the first transition instance
    runtimeService.createProcessInstanceModification(instance.getId()).startBeforeActivity("innerTask2").cancelTransitionInstance(transitionInstance.getId()).execute();
    // then the activity was successfully instantiated
    tree = runtimeService.getActivityInstance(instance.getId());
    assertThat(tree).hasStructure(describeActivityInstanceTree(instance.getProcessDefinitionId()).beginScope("subProcess").transition("innerTask2").done());
    // assert executions
    ExecutionTree executionTree = ExecutionTree.forExecution(instance.getId(), processEngine);
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child("innerTask2").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 18 with TransitionInstance

use of org.camunda.bpm.engine.runtime.TransitionInstance 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 19 with TransitionInstance

use of org.camunda.bpm.engine.runtime.TransitionInstance 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 20 with TransitionInstance

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

the class ActivityInstanceImpl method collectTransitionInstances.

protected void collectTransitionInstances(String activityId, List<TransitionInstance> instances) {
    boolean instanceFound = false;
    for (TransitionInstance childTransitionInstance : childTransitionInstances) {
        if (activityId.equals(childTransitionInstance.getActivityId())) {
            instances.add(childTransitionInstance);
            instanceFound = true;
        }
    }
    if (!instanceFound) {
        for (ActivityInstance childActivityInstance : childActivityInstances) {
            ((ActivityInstanceImpl) childActivityInstance).collectTransitionInstances(activityId, instances);
        }
    }
}
Also used : TransitionInstance(org.camunda.bpm.engine.runtime.TransitionInstance) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance)

Aggregations

TransitionInstance (org.camunda.bpm.engine.runtime.TransitionInstance)34 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)31 Deployment (org.camunda.bpm.engine.test.Deployment)27 Test (org.junit.Test)21 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)20 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)19 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)13 ExecutionAssert.describeExecutionTree (org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree)5 ExecutionTree (org.camunda.bpm.engine.test.util.ExecutionTree)5 Task (org.camunda.bpm.engine.task.Task)4 NotValidException (org.camunda.bpm.engine.exception.NotValidException)3 Job (org.camunda.bpm.engine.runtime.Job)3 ArrayList (java.util.ArrayList)2 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)2 ProcessDefinitionImpl (org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl)1 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)1 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)1 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)1