use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrationCallActivityTest method testCallCmmnCaseParallelMultiInstance.
@Test
public void testCallCmmnCaseParallelMultiInstance() {
// given
BpmnModelInstance model = modify(CallActivityModels.oneCmmnCallActivityProcess("oneTaskCase")).activityBuilder("callActivity").multiInstance().parallel().cardinality("1").done();
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(model);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(model);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("callActivity#multiInstanceBody", "callActivity#multiInstanceBody").mapActivities("callActivity", "callActivity").build();
// when
ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then
testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree(null).scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).child(null).scope().id(testHelper.getSingleExecutionIdForActivityBeforeMigration("callActivity#multiInstanceBody")).child("callActivity").concurrent().noScope().id(testHelper.getSingleExecutionIdForActivityBeforeMigration("callActivity")).done());
testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).beginMiBody("callActivity").activity("callActivity", testHelper.getSingleActivityInstanceBeforeMigration("callActivity").getId()).done());
// and the link between calling and called instance is maintained correctly
testHelper.assertSuperExecutionOfCaseInstance(rule.getCaseService().createCaseInstanceQuery().caseDefinitionKey("oneTaskCase").singleResult().getId(), testHelper.getSingleExecutionIdForActivityAfterMigration("callActivity"));
// and it is possible to complete the called case instance
CaseExecution caseExecution = rule.getCaseService().createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
testHelper.completeTask("PI_HumanTask_1");
// and the calling process instance
testHelper.completeTask("userTask");
testHelper.assertProcessEnded(processInstance.getId());
// and close the called case instance
rule.getCaseService().withCaseExecution(caseExecution.getCaseInstanceId()).close();
testHelper.assertCaseEnded(caseExecution.getCaseInstanceId());
}
use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrationCallActivityTest method testCallBpmnProcessReconfigureCallActivity.
@Test
public void testCallBpmnProcessReconfigureCallActivity() {
// given
BpmnModelInstance model = CallActivityModels.oneBpmnCallActivityProcess("oneTaskProcess");
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(model);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(model).callActivityBuilder("callActivity").calledElement("foo").done());
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("callActivity", "callActivity").build();
// when
ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then the called instance has not changed (e.g. not been migrated to a different process definition)
ProcessInstance calledInstance = rule.getRuntimeService().createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").singleResult();
Assert.assertNotNull(calledInstance);
// and it is possible to complete the called process instance
testHelper.completeTask("userTask");
// and the calling process instance
testHelper.completeTask("userTask");
testHelper.assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrationCallActivityTest method testCallCmmnCaseSimpleMigration.
@Test
public void testCallCmmnCaseSimpleMigration() {
// given
BpmnModelInstance model = CallActivityModels.oneCmmnCallActivityProcess("oneTaskCase");
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(model);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(model);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("callActivity", "callActivity").build();
// when
ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then
testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree(null).scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).child("callActivity").scope().id(testHelper.getSingleExecutionIdForActivityBeforeMigration("callActivity")).done());
testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).activity("callActivity", testHelper.getSingleActivityInstanceBeforeMigration("callActivity").getId()).done());
// and it is possible to complete the called case instance
CaseExecution caseExecution = rule.getCaseService().createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
testHelper.completeTask("PI_HumanTask_1");
// and the calling process instance
testHelper.completeTask("userTask");
testHelper.assertProcessEnded(processInstance.getId());
// and close the called case instance
rule.getCaseService().withCaseExecution(caseExecution.getCaseInstanceId()).close();
testHelper.assertCaseEnded(caseExecution.getCaseInstanceId());
}
use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrationCompensationAddSubProcessTest method testCase1CannotTriggerCompensationInNewScope.
/**
* The guarantee given by the API is: Compensation can be triggered in the scope that it could be triggered before
* migration. Thus, it should not be possible to trigger compensation from the new sub process instance but only from the
* parent scope, i.e. the process definition instance
*/
@Test
public void testCase1CannotTriggerCompensationInNewScope() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(CompensationModels.COMPENSATION_TWO_TASKS_SUBPROCESS_MODEL).endEventBuilder("subProcessEnd").compensateEventDefinition().waitForCompletion(true).compensateEventDefinitionDone().done());
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask2", "userTask2").mapActivities("compensationBoundary", "compensationBoundary").build();
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
testHelper.completeTask("userTask1");
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then compensation is only caught outside of the subProcess
testHelper.completeTask("userTask2");
ActivityInstance activityInstance = rule.getRuntimeService().getActivityInstance(processInstance.getId());
assertThat(activityInstance).hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).activity(// note: this is not subProcess and subProcessEnd
"compensationEvent").beginScope("subProcess").activity("compensationHandler").done());
}
use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrationCompensationAddSubProcessTest method testVariablesInParentEventScopeStillAccessible.
@Test
public void testVariablesInParentEventScopeStillAccessible() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.DOUBLE_SUBPROCESS_MODEL);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("subProcess", "outerSubProcess").mapActivities("compensationBoundary", "compensationBoundary").mapActivities("userTask2", "userTask2").build();
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
Execution subProcessExecution = rule.getRuntimeService().createExecutionQuery().activityId("userTask1").singleResult();
rule.getRuntimeService().setVariableLocal(subProcessExecution.getId(), "foo", "bar");
testHelper.completeTask("userTask1");
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// when throwing compensation
testHelper.completeAnyTask("userTask2");
// then the variable snapshot is available
Task compensationTask = rule.getTaskService().createTaskQuery().singleResult();
Assert.assertEquals("bar", rule.getTaskService().getVariable(compensationTask.getId(), "foo"));
}
Aggregations