use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class MigrationCompensationRemoveSubProcessTest method testCase1AssertActivityInstance.
@Test
public void testCase1AssertActivityInstance() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_TWO_TASKS_SUBPROCESS_MODEL);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
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");
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// when
testHelper.completeTask("userTask2");
// then
ActivityInstance activityInstance = rule.getRuntimeService().getActivityInstance(processInstance.getId());
assertThat(activityInstance).hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).activity("compensationEvent").activity("compensationHandler").done());
}
use of org.camunda.bpm.engine.runtime.ActivityInstance 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.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class MigrationCompensationTest method testCanMigrateWithEventSubProcessHandlerAssertActivityInstance.
@Test
public void testCanMigrateWithEventSubProcessHandlerAssertActivityInstance() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_EVENT_SUBPROCESS_MODEL);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_EVENT_SUBPROCESS_MODEL);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask2", "userTask2").mapActivities("subProcess", "subProcess").mapActivities("eventSubProcessStart", "eventSubProcessStart").mapActivities("compensationBoundary", "compensationBoundary").build();
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
testHelper.completeTask("userTask1");
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// when compensation is triggered
testHelper.completeTask("userTask2");
// then
ActivityInstance activityInstance = rule.getRuntimeService().getActivityInstance(processInstance.getId());
assertThat(activityInstance).hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).activity("compensationEvent").beginScope("subProcess").beginScope("eventSubProcess").activity("eventSubProcessTask").done());
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class MigrationCompensationTest method testCanMigrateWithCompensationSubscriptionsInMigratingScopeAssertActivityInstance.
@Test
public void testCanMigrateWithCompensationSubscriptionsInMigratingScopeAssertActivityInstance() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
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");
// a migrated process instance
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// when triggering compensation
testHelper.completeTask("userTask2");
// then the activity instance tree is correct
ActivityInstance activityInstance = rule.getRuntimeService().getActivityInstance(processInstance.getId());
assertThat(activityInstance).hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).activity("compensationEvent").activity("compensationHandler").done());
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class MigrationTestRule method getSingleExecutionIdForActivity.
public String getSingleExecutionIdForActivity(ActivityInstance activityInstance, String activityId) {
ActivityInstance singleInstance = getSingleActivityInstance(activityInstance, activityId);
String[] executionIds = singleInstance.getExecutionIds();
if (executionIds.length == 1) {
return executionIds[0];
} else {
throw new RuntimeException("There is more than one execution assigned to activity instance " + singleInstance.getId());
}
}
Aggregations