use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class MigrationTransitionInstancesTest method testMigrateAsyncAfterTransitionInstanceRemoveOutgoingFlowCase2.
@Test
public void testMigrateAsyncAfterTransitionInstanceRemoveOutgoingFlowCase2() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_AFTER_USER_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_AFTER_SUBPROCESS_USER_TASK_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask1", "userTask1").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());
testHelper.completeTask("userTask2");
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class MigrationTransitionInstancesTest method testMigrateAsyncBeforeTransitionInstance.
@Test
public void testMigrateAsyncBeforeTransitionInstance() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
// when
testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then
testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree("userTask").scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).done());
testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).transition("userTask").done());
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.runtime.Job in project camunda-bpm-platform by camunda.
the class MigrationTransitionInstancesTest method testMigrateAsyncBeforeTransitionInstanceWithIncident.
@Test
public void testMigrateAsyncBeforeTransitionInstanceWithIncident() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS).changeElementId("userTask", "newUserTask"));
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask", "newUserTask").build();
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(migrationPlan.getSourceProcessDefinitionId());
Job job = rule.getManagementService().createJobQuery().singleResult();
rule.getManagementService().setJobRetries(job.getId(), 0);
Incident incidentBeforeMigration = rule.getRuntimeService().createIncidentQuery().singleResult();
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then
Incident incidentAfterMigration = rule.getRuntimeService().createIncidentQuery().singleResult();
assertNotNull(incidentAfterMigration);
// and it is still the same incident
assertEquals(incidentBeforeMigration.getId(), incidentAfterMigration.getId());
assertEquals(job.getId(), incidentAfterMigration.getConfiguration());
// and the activity and process definition references were updated
assertEquals("newUserTask", incidentAfterMigration.getActivityId());
assertEquals(targetProcessDefinition.getId(), incidentAfterMigration.getProcessDefinitionId());
// and it is possible to successfully execute the migrated job
rule.getManagementService().executeJob(job.getId());
// and complete the task and process instance
testHelper.completeTask("newUserTask");
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class MigrationTransitionInstancesTest method testMigrateAsyncBeforeTransitionInstanceChangeActivityId.
@Test
public void testMigrateAsyncBeforeTransitionInstanceChangeActivityId() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS).changeElementId("userTask", "userTaskReplacement"));
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask", "userTaskReplacement").build();
// when
testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then
testHelper.assertJobMigrated("userTask", "userTaskReplacement", 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("userTaskReplacement");
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class MigrationTransitionInstancesTest method testMigrateAsyncBeforeTransitionInstanceConcurrent.
@Test
public void testMigrateAsyncBeforeTransitionInstanceConcurrent() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask", "userTask").build();
ProcessInstance processInstance = rule.getRuntimeService().createProcessInstanceById(migrationPlan.getSourceProcessDefinitionId()).startBeforeActivity("userTask").startBeforeActivity("userTask").execute();
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then
TransitionInstance[] transitionInstances = testHelper.snapshotAfterMigration.getActivityTree().getTransitionInstances("userTask");
testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree(null).scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).child("userTask").concurrent().noScope().id(transitionInstances[0].getExecutionId()).up().child("userTask").concurrent().noScope().id(transitionInstances[1].getExecutionId()).done());
testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).transition("userTask").transition("userTask").done());
Assert.assertEquals(2, testHelper.snapshotAfterMigration.getJobs().size());
// and it is possible to successfully execute the migrated job
for (Job job : testHelper.snapshotAfterMigration.getJobs()) {
rule.getManagementService().executeJob(job.getId());
testHelper.completeTask("userTask");
}
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
Aggregations