Search in sources :

Example 76 with ExecutionTree

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

the class MigrationHistoricVariablesTest method noHistoryUpdateOnSameStructureMigration.

@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void noHistoryUpdateOnSameStructureMigration() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ONE_BOUNDARY_TASK);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ONE_BOUNDARY_TASK);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
    ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.getId(), rule.getProcessEngine());
    ExecutionTree scopeExecution = executionTreeBeforeMigration.getExecutions().get(0);
    runtimeService.setVariableLocal(scopeExecution.getId(), "foo", 42);
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then there is still one historic variable instance
    Assert.assertEquals(1, historyService.createHistoricVariableInstanceQuery().count());
    // and no additional historic details
    Assert.assertEquals(1, historyService.createHistoricDetailQuery().count());
}
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) Test(org.junit.Test) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 77 with ExecutionTree

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

the class MessageEventSubprocessTest method testNonInterruptingWithReceiveTask.

@Deployment
public void testNonInterruptingWithReceiveTask() {
    String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
    // when (1)
    runtimeService.correlateMessage("firstMessage");
    // then (1)
    assertEquals(1, taskService.createTaskQuery().count());
    Task task1 = taskService.createTaskQuery().taskDefinitionKey("eventSubProcessTask").singleResult();
    assertNotNull(task1);
    ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
    // check that the parent execution of the event sub process task execution is the event
    // sub process execution
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).concurrent().noScope().child("receiveTask").scope().up().up().child(null).concurrent().noScope().child("eventSubProcessTask").scope().done());
    // when (2)
    runtimeService.correlateMessage("secondMessage");
    // then (2)
    assertEquals(2, taskService.createTaskQuery().count());
    task1 = taskService.createTaskQuery().taskDefinitionKey("eventSubProcessTask").singleResult();
    assertNotNull(task1);
    Task task2 = taskService.createTaskQuery().taskDefinitionKey("userTask").singleResult();
    assertNotNull(task2);
    executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
    // check that the parent execution of the event sub process task execution is the event
    // sub process execution
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child("userTask").concurrent().noScope().up().child(null).concurrent().noScope().child("eventSubProcessTask").scope().done());
    assertEquals(1, runtimeService.createEventSubscriptionQuery().count());
    taskService.complete(task1.getId());
    taskService.complete(task2.getId());
    assertProcessEnded(processInstanceId);
}
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) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 78 with ExecutionTree

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

the class MessageNonInterruptingBoundaryEventTest method testNonInterruptingEventInCombinationWithUserTaskInsideSubProcess.

@Deployment
public void testNonInterruptingEventInCombinationWithUserTaskInsideSubProcess() {
    // given
    String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
    // when (1)
    runtimeService.correlateMessage("firstMessage");
    // then (1)
    assertEquals(2, taskService.createTaskQuery().count());
    Task task1 = taskService.createTaskQuery().taskDefinitionKey("task1").singleResult();
    assertNotNull(task1);
    Task innerTask = taskService.createTaskQuery().taskDefinitionKey("innerTask").singleResult();
    assertNotNull(innerTask);
    ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).scope().child("task1").noScope().concurrent().up().child(null).noScope().concurrent().child("innerTask").scope().done());
    // when (2)
    taskService.complete(innerTask.getId());
    // then (2)
    assertEquals(2, taskService.createTaskQuery().count());
    task1 = taskService.createTaskQuery().taskDefinitionKey("task1").singleResult();
    assertNotNull(task1);
    Task task2 = taskService.createTaskQuery().taskDefinitionKey("task2").singleResult();
    assertNotNull(task2);
    assertEquals(0, runtimeService.createEventSubscriptionQuery().count());
    executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
    assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).scope().child("task1").noScope().concurrent().up().child("task2").noScope().concurrent().done());
    taskService.complete(task1.getId());
    taskService.complete(task2.getId());
    assertProcessEnded(processInstanceId);
}
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) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 79 with ExecutionTree

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

the class MigrationVariablesTest method testVariableAtScopeAndConcurrentExecutionRemoveParentScope.

@Test
public void testVariableAtScopeAndConcurrentExecutionRemoveParentScope() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_SUBPROCESS_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS);
    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);
    ExecutionTree userTask2CCExecutionBefore = executionTreeBeforeMigration.getLeafExecutions("userTask2").get(0);
    ExecutionTree subProcessExecution = userTask1CCExecutionBefore.getParent();
    runtimeService.setVariableLocal(subProcessExecution.getId(), "foo", "subProcessValue");
    runtimeService.setVariableLocal(userTask1CCExecutionBefore.getId(), "foo", "task1Value");
    runtimeService.setVariableLocal(userTask2CCExecutionBefore.getId(), "foo", "task2Value");
    VariableInstance task1Variable = runtimeService.createVariableInstanceQuery().variableValueEquals("foo", "task1Value").singleResult();
    VariableInstance task2Variable = runtimeService.createVariableInstanceQuery().variableValueEquals("foo", "task2Value").singleResult();
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then the scope variable instance has been overwritten during compaction (conform to prior behavior);
    // although this is tested here, changing this behavior may be ok in the future
    Collection<VariableInstance> variables = testHelper.snapshotAfterMigration.getVariables();
    Assert.assertEquals(2, variables.size());
    VariableInstance task1VariableAfterMigration = testHelper.snapshotAfterMigration.getVariable(task1Variable.getId());
    Assert.assertNotNull(task1VariableAfterMigration);
    Assert.assertEquals("task1Value", task1VariableAfterMigration.getValue());
    VariableInstance task2VariableAfterMigration = testHelper.snapshotAfterMigration.getVariable(task2Variable.getId());
    Assert.assertNotNull(task2VariableAfterMigration);
    Assert.assertEquals("task2Value", task2VariableAfterMigration.getValue());
}
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 80 with ExecutionTree

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

the class MigrationVariablesTest method testVariableAtConcurrentExecutionBecomeScope.

@Test
public void testVariableAtConcurrentExecutionBecomeScope() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_SCOPE_TASKS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
    ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.getId(), rule.getProcessEngine());
    ExecutionTree concurrentExecution = executionTreeBeforeMigration.getLeafExecutions("userTask1").get(0);
    runtimeService.setVariableLocal(concurrentExecution.getId(), "foo", 42);
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then
    VariableInstance beforeMigration = testHelper.snapshotBeforeMigration.getSingleVariable("foo");
    ExecutionTree userTask1CCExecution = testHelper.snapshotAfterMigration.getExecutionTree().getLeafExecutions("userTask1").get(0).getParent();
    Assert.assertEquals(1, testHelper.snapshotAfterMigration.getVariables().size());
    testHelper.assertVariableMigratedToExecution(beforeMigration, userTask1CCExecution.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)

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