use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class MigrationSignallableServiceTaskTest method testCannotMigrateActivityInstance.
@Test
public void testCannotMigrateActivityInstance() {
// given
BpmnModelInstance model = ProcessModels.newModel().startEvent().serviceTask("serviceTask").camundaClass(SignallableServiceTaskDelegate.class.getName()).endEvent().done();
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(model);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(model);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("serviceTask", "serviceTask").build();
// when
try {
testHelper.createProcessInstanceAndMigrate(migrationPlan);
Assert.fail("should fail");
} catch (MigratingProcessInstanceValidationException e) {
// then
assertThat(e.getValidationReport()).hasActivityInstanceFailures("serviceTask", "The type of the source activity is not supported for activity instance migration");
}
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class MigrationTransitionInstancesTest method testFailMigrateFailedJobIncident.
@Test
public void testFailMigrateFailedJobIncident() {
// given
BpmnModelInstance model = ProcessModels.newModel().startEvent().serviceTask("serviceTask").camundaAsyncBefore().camundaClass(AlwaysFailingDelegate.class.getName()).endEvent().done();
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(model);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(model).changeElementId("serviceTask", "newServiceTask"));
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
String processInstanceId = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId()).getId();
testHelper.executeAvailableJobs();
// when
try {
rule.getRuntimeService().newMigration(migrationPlan).processInstanceIds(processInstanceId).execute();
Assert.fail("should fail");
} catch (MigratingProcessInstanceValidationException e) {
// then
Assert.assertTrue(e instanceof MigratingProcessInstanceValidationException);
}
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class MigrationTransitionInstancesTest method testMigrateAsyncBeforeInnerMultiInstance.
@Test
public void testMigrateAsyncBeforeInnerMultiInstance() {
// given
BpmnModelInstance model = modify(MultiInstanceProcessModels.PAR_MI_ONE_TASK_PROCESS).asyncBeforeInnerMiActivity("userTask");
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(model);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(model);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
// when
testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then
List<Job> jobs = testHelper.snapshotAfterMigration.getJobs();
Assert.assertEquals(3, jobs.size());
testHelper.assertJobMigrated(jobs.get(0), "userTask");
testHelper.assertJobMigrated(jobs.get(1), "userTask");
testHelper.assertJobMigrated(jobs.get(2), "userTask");
// and it is possible to successfully execute the migrated jobs
for (Job job : jobs) {
rule.getManagementService().executeJob(job.getId());
}
// and complete the task and process instance
testHelper.completeAnyTask("userTask");
testHelper.completeAnyTask("userTask");
testHelper.completeAnyTask("userTask");
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class MigrationTransitionInstancesTest method testMigrateAsyncAfterBoundaryEventWithChangedEventScope.
/**
* Does not apply since asyncAfter cannot be used with boundary events
*/
@Ignore
@Test
public void testMigrateAsyncAfterBoundaryEventWithChangedEventScope() {
BpmnModelInstance sourceProcess = modify(ProcessModels.PARALLEL_GATEWAY_PROCESS).activityBuilder("userTask1").boundaryEvent("boundary").message("Message").camundaAsyncAfter().userTask("afterBoundaryTask").endEvent().done();
BpmnModelInstance targetProcess = modify(sourceProcess).swapElementIds("userTask1", "userTask2");
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(sourceProcess);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(targetProcess);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("boundary", "boundary").mapActivities("userTask1", "userTask1").mapActivities("userTask2", "userTask2").build();
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then
testHelper.assertJobMigrated("boundary", "boundary", AsyncContinuationJobHandler.TYPE);
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance 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");
}
}
Aggregations