Search in sources :

Example 61 with ExecutionTree

use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.

the class ProcessInstanceModificationEventSubProcessTest method testStartBeforeTaskInsideNonInterruptingEventSubProcessInsideSubProcessTask2ShouldStay.

@Deployment(resources = NON_INTERRUPTING_EVENT_SUBPROCESS_INSIDE_SUBPROCESS)
public void testStartBeforeTaskInsideNonInterruptingEventSubProcessInsideSubProcessTask2ShouldStay() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
    String processInstanceId = processInstance.getId();
    String taskId = taskService.createTaskQuery().singleResult().getId();
    taskService.complete(taskId);
    runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("eventSubProcessTask").execute();
    ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
    assertNotNull(updatedTree);
    assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
    assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginScope("subProcess").activity("task2").beginScope("eventSubProcess").activity("eventSubProcessTask").done());
    ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).scope().child("task2").concurrent().noScope().up().child(null).concurrent().noScope().child("eventSubProcessTask").scope().done());
    completeTasksInOrder("task2", "eventSubProcessTask");
    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 62 with ExecutionTree

use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.

the class ProcessInstanceModificationEventSubProcessTest method testStartBeforeTaskInsideEventSubProcessInsideSubProcessTask2ShouldStay.

@Deployment(resources = INTERRUPTING_EVENT_SUBPROCESS_INSIDE_SUBPROCESS)
public void testStartBeforeTaskInsideEventSubProcessInsideSubProcessTask2ShouldStay() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
    String processInstanceId = processInstance.getId();
    String taskId = taskService.createTaskQuery().singleResult().getId();
    taskService.complete(taskId);
    runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("eventSubProcessTask").execute();
    ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
    assertNotNull(updatedTree);
    assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
    assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginScope("subProcess").activity("task2").beginScope("eventSubProcess").activity("eventSubProcessTask").done());
    ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).scope().child("task2").concurrent().noScope().up().child(null).concurrent().noScope().child("eventSubProcessTask").scope().done());
    completeTasksInOrder("task2", "eventSubProcessTask");
    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 63 with ExecutionTree

use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.

the class MigrationVariablesTest method testVariableAtConcurrentExecutionInScopeActivityRemoveParentScope.

@Test
public void testVariableAtConcurrentExecutionInScopeActivityRemoveParentScope() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(SUBPROCESS_CONCURRENT_BOUNDARY_TASKS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CONCURRENT_BOUNDARY_TASKS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask1", "userTask1").mapActivities("userTask2", "userTask2").build();
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
    ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.getId(), rule.getProcessEngine());
    ExecutionTree userTask1CCExecutionBefore = executionTreeBeforeMigration.getLeafExecutions("userTask1").get(0).getParent();
    runtimeService.setVariableLocal(userTask1CCExecutionBefore.getId(), "foo", 42);
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then
    VariableInstance beforeMigration = testHelper.snapshotBeforeMigration.getSingleVariable("foo");
    ExecutionTree userTask1CCExecutionAfter = testHelper.snapshotAfterMigration.getExecutionTree().getLeafExecutions("userTask1").get(0).getParent();
    Assert.assertEquals(1, testHelper.snapshotAfterMigration.getVariables().size());
    // for variables at concurrent executions that are parent of a leaf-scope-execution, the activity instance is
    // the activity instance id of the parent activity instance (which is probably a bug)
    testHelper.assertVariableMigratedToExecution(beforeMigration, userTask1CCExecutionAfter.getId(), processInstance.getId());
}
Also used : ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Test(org.junit.Test)

Example 64 with ExecutionTree

use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.

the class MigrationVariablesTest method testVariableAtTaskAddParentScope.

@Test
public void testVariableAtTaskAddParentScope() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_SUBPROCESS_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask1", "userTask1").mapActivities("userTask2", "userTask2").build();
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
    Task task = taskService.createTaskQuery().taskDefinitionKey("userTask1").singleResult();
    taskService.setVariableLocal(task.getId(), "foo", 42);
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then
    VariableInstance beforeMigration = testHelper.snapshotBeforeMigration.getSingleVariable("foo");
    ExecutionTree userTask1ExecutionAfter = testHelper.snapshotAfterMigration.getExecutionTree().getLeafExecutions("userTask1").get(0);
    Assert.assertEquals(1, testHelper.snapshotAfterMigration.getVariables().size());
    testHelper.assertVariableMigratedToExecution(beforeMigration, userTask1ExecutionAfter.getId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Test(org.junit.Test)

Example 65 with ExecutionTree

use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.

the class MigrationVariablesTest method testVariableAtTaskAndConcurrentExecutionAddParentScope.

@Test
public void testVariableAtTaskAndConcurrentExecutionAddParentScope() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_SUBPROCESS_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask1", "userTask1").mapActivities("userTask2", "userTask2").build();
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
    Task task = taskService.createTaskQuery().taskDefinitionKey("userTask1").singleResult();
    taskService.setVariableLocal(task.getId(), "foo", 42);
    runtimeService.setVariableLocal(task.getExecutionId(), "foo", 52);
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then
    VariableInstance taskVarBeforeMigration = testHelper.snapshotBeforeMigration.getSingleTaskVariable(task.getId(), "foo");
    ExecutionTree userTask1ExecutionAfter = testHelper.snapshotAfterMigration.getExecutionTree().getLeafExecutions("userTask1").get(0);
    Assert.assertEquals(2, testHelper.snapshotAfterMigration.getVariables().size());
    testHelper.assertVariableMigratedToExecution(taskVarBeforeMigration, userTask1ExecutionAfter.getId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) ExecutionTree(org.camunda.bpm.engine.test.util.ExecutionTree) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Test(org.junit.Test)

Aggregations

ExecutionTree (org.camunda.bpm.engine.test.util.ExecutionTree)155 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)149 Deployment (org.camunda.bpm.engine.test.Deployment)134 ExecutionAssert.describeExecutionTree (org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree)134 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)130 Task (org.camunda.bpm.engine.task.Task)40 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)20 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)20 Test (org.junit.Test)20 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)17 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)15 Execution (org.camunda.bpm.engine.runtime.Execution)9 Job (org.camunda.bpm.engine.runtime.Job)6 TransitionInstance (org.camunda.bpm.engine.runtime.TransitionInstance)5 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)4 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)2 RecorderExecutionListener (org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener)2 RecordedEvent (org.camunda.bpm.engine.test.bpmn.executionlistener.RecorderExecutionListener.RecordedEvent)2 ArrayList (java.util.ArrayList)1 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)1