use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrationTransitionInstancesTest method testCannotMigrateUnmappedTransitionInstanceWithIncident.
@Test
public void testCannotMigrateUnmappedTransitionInstanceWithIncident() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS);
// the user task is not mapped in the migration plan, i.e. there is no instruction to migrate the job
// and the incident
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).build();
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(migrationPlan.getSourceProcessDefinitionId());
Job job = rule.getManagementService().createJobQuery().singleResult();
rule.getManagementService().setJobRetries(job.getId(), 0);
// when
try {
testHelper.migrateProcessInstance(migrationPlan, processInstance);
Assert.fail("should fail");
} catch (MigratingProcessInstanceValidationException e) {
// then
assertThat(e.getValidationReport()).hasTransitionInstanceFailures("userTask", "There is no migration instruction for this instance's activity");
}
}
use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrationTransitionInstancesTest method testMigrateAsyncBeforeTransitionInstanceAddIncomingFlow.
@Test
public void testMigrateAsyncBeforeTransitionInstanceAddIncomingFlow() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(modify(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS).removeFlowNode("startEvent"));
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask", "userTask").build();
// when
ProcessInstance processInstance = rule.getRuntimeService().createProcessInstanceById(sourceProcessDefinition.getId()).startBeforeActivity("userTask").execute();
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then
testHelper.assertJobMigrated("userTask", "userTask", AsyncContinuationJobHandler.TYPE);
// and it is possible to successfully execute the migrated job
Job job = testHelper.snapshotAfterMigration.getJobs().get(0);
rule.getManagementService().executeJob(job.getId());
// and complete the task and process instance
testHelper.completeTask("userTask");
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrationTransitionInstancesTest method testMigrateAsyncAfterTransitionInstanceAddOutgoingFlowCase1.
@Test
public void testMigrateAsyncAfterTransitionInstanceAddOutgoingFlowCase1() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(modify(AsyncProcessModels.ASYNC_AFTER_USER_TASK_PROCESS).removeFlowNode("endEvent").removeFlowNode("userTask2"));
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_AFTER_USER_TASK_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
testHelper.completeTask("userTask1");
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then
testHelper.assertJobMigrated("userTask1", "userTask1", AsyncContinuationJobHandler.TYPE);
// and it is possible to successfully execute the migrated job
Job job = testHelper.snapshotAfterMigration.getJobs().get(0);
rule.getManagementService().executeJob(job.getId());
// and complete the process instance
testHelper.completeTask("userTask2");
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrationUserTaskTest method testCannotMigrateWhenNotAllTransitionInstancesAreMapped.
@Test
public void testCannotMigrateWhenNotAllTransitionInstancesAreMapped() {
// given
BpmnModelInstance model = ModifiableBpmnModelInstance.modify(ProcessModels.PARALLEL_GATEWAY_PROCESS).activityBuilder("userTask1").camundaAsyncBefore().moveToActivity("userTask2").camundaAsyncBefore().done();
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(model);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(model);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask1", "userTask1").build();
// when
try {
testHelper.createProcessInstanceAndMigrate(migrationPlan);
Assert.fail("should not succeed because the userTask2 instance is not mapped");
} catch (MigratingProcessInstanceValidationException e) {
assertThat(e.getValidationReport()).hasTransitionInstanceFailures("userTask2", "There is no migration instruction for this instance's activity");
}
}
use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrationUserTaskTest method testCannotMigrateWhenNotAllActivityInstancesAreMapped.
@Test
public void testCannotMigrateWhenNotAllActivityInstancesAreMapped() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask1", "userTask1").build();
// when
try {
testHelper.createProcessInstanceAndMigrate(migrationPlan);
Assert.fail("should not succeed because the userTask2 instance is not mapped");
} catch (MigratingProcessInstanceValidationException e) {
assertThat(e.getValidationReport()).hasActivityInstanceFailures("userTask2", "There is no migration instruction for this instance's activity");
}
}
Aggregations