Search in sources :

Example 81 with MigrationPlan

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");
    }
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) MigratingProcessInstanceValidationException(org.camunda.bpm.engine.migration.MigratingProcessInstanceValidationException) Job(org.camunda.bpm.engine.runtime.Job) Test(org.junit.Test)

Example 82 with MigrationPlan

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());
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Job(org.camunda.bpm.engine.runtime.Job) Test(org.junit.Test)

Example 83 with MigrationPlan

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());
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Job(org.camunda.bpm.engine.runtime.Job) Test(org.junit.Test)

Example 84 with MigrationPlan

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");
    }
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) MigratingProcessInstanceValidationException(org.camunda.bpm.engine.migration.MigratingProcessInstanceValidationException) Test(org.junit.Test)

Example 85 with MigrationPlan

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");
    }
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) MigratingProcessInstanceValidationException(org.camunda.bpm.engine.migration.MigratingProcessInstanceValidationException) Test(org.junit.Test)

Aggregations

MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)485 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)474 Test (org.junit.Test)474 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)272 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)67 Job (org.camunda.bpm.engine.runtime.Job)48 Task (org.camunda.bpm.engine.task.Task)45 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)26 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)22 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)22 MigratingProcessInstanceValidationException (org.camunda.bpm.engine.migration.MigratingProcessInstanceValidationException)21 UserTask (org.camunda.bpm.model.bpmn.instance.UserTask)21 ExecutionTree (org.camunda.bpm.engine.test.util.ExecutionTree)20 Incident (org.camunda.bpm.engine.runtime.Incident)14 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)14 MigratingBpmnEventTrigger (org.camunda.bpm.engine.test.api.runtime.migration.util.MigratingBpmnEventTrigger)14 Batch (org.camunda.bpm.engine.batch.Batch)13 LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)13 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)13 Execution (org.camunda.bpm.engine.runtime.Execution)11