Search in sources :

Example 86 with ActivityInstance

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

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

the class ProcessInstanceModificationAsyncTest method testCancelAsyncAfterTransitionInstance.

@Deployment(resources = NESTED_ASYNC_AFTER_TASK_PROCESS)
public void testCancelAsyncAfterTransitionInstance() {
    // given a process instance with an asyncAfter task in a subprocess
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nestedOneTaskProcess");
    Task innerTask = taskService.createTaskQuery().taskDefinitionKey("innerTask").singleResult();
    assertNotNull(innerTask);
    taskService.complete(innerTask.getId());
    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    assertEquals(1, managementService.createJobQuery().count());
    // when the async task is cancelled via cancelTransitionInstance
    runtimeService.createProcessInstanceModification(processInstance.getId()).cancelTransitionInstance(getChildTransitionInstanceForTargetActivity(tree, "innerTask").getId()).execute();
    // then the job has been removed
    assertEquals(0, managementService.createJobQuery().count());
    // and the activity instance and execution trees match
    ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstance.getId());
    assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("outerTask").done());
    ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.getId(), processEngine);
    assertThat(executionTree).matches(describeExecutionTree("outerTask").scope().done());
    // and the process can be completed successfully
    completeTasksInOrder("outerTask");
    assertProcessEnded(processInstance.getId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) 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 88 with ActivityInstance

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

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

the class ProcessInstanceModificationAsyncTest method testCancelParentScopeOfParallelAsyncBeforeScopeActivity.

@Deployment(resources = NESTED_PARALLEL_ASYNC_BEFORE_SCOPE_TASK_PROCESS)
public void testCancelParentScopeOfParallelAsyncBeforeScopeActivity() {
    // given a process instance with two concurrent async scope tasks in a subprocess
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nestedConcurrentTasksProcess");
    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    // when I cancel the subprocess
    runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(getInstanceIdForActivity(tree, "subProcess")).execute();
    // then the process instance is in a valid state
    ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstance.getId());
    assertNotNull(updatedTree);
    assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("outerTask").done());
    ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.getId(), processEngine);
    assertThat(executionTree).matches(describeExecutionTree("outerTask").scope().done());
    completeTasksInOrder("outerTask");
    assertProcessEnded(processInstance.getId());
}
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 90 with ActivityInstance

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

the class ProcessInstanceModificationAsyncTest method testCancelAsyncAfterEndEventTransitionInstance.

@Deployment(resources = NESTED_ASYNC_AFTER_END_EVENT_PROCESS)
public void testCancelAsyncAfterEndEventTransitionInstance() {
    // given a process instance with an asyncAfter end event in a subprocess
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nestedAsyncEndEventProcess");
    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    assertEquals(1, managementService.createJobQuery().count());
    // when the async task is cancelled via cancelTransitionInstance
    runtimeService.createProcessInstanceModification(processInstance.getId()).cancelTransitionInstance(getChildTransitionInstanceForTargetActivity(tree, "subProcessEnd").getId()).execute();
    // then the job has been removed
    assertEquals(0, managementService.createJobQuery().count());
    // and the activity instance and execution trees match
    ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstance.getId());
    assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("outerTask").done());
    ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.getId(), processEngine);
    assertThat(executionTree).matches(describeExecutionTree("outerTask").scope().done());
    // and the process can be completed successfully
    completeTasksInOrder("outerTask");
    assertProcessEnded(processInstance.getId());
}
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