Search in sources :

Example 6 with MigratingProcessInstanceValidationException

use of org.camunda.bpm.engine.migration.MigratingProcessInstanceValidationException in project camunda-bpm-platform by camunda.

the class MigrationTransitionInstancesTest method testMigrateAsyncAfterTransitionInstanceAddOutgoingFlowCase3.

@Test
public void testMigrateAsyncAfterTransitionInstanceAddOutgoingFlowCase3() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_AFTER_USER_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(AsyncProcessModels.ASYNC_AFTER_USER_TASK_PROCESS).changeElementId("flow1", "flow2").activityBuilder("userTask1").sequenceFlowId("flow3").userTask("userTask3").endEvent().done());
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    testHelper.completeTask("userTask1");
    // when
    try {
        testHelper.migrateProcessInstance(migrationPlan, processInstance);
        Assert.fail("should fail");
    } catch (MigratingProcessInstanceValidationException e) {
        assertThat(e.getValidationReport()).hasTransitionInstanceFailures("userTask1", "Transition instance is assigned to a sequence flow that cannot be matched in the target 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) Test(org.junit.Test)

Example 7 with MigratingProcessInstanceValidationException

use of org.camunda.bpm.engine.migration.MigratingProcessInstanceValidationException 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);
    }
}
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) AlwaysFailingDelegate(org.camunda.bpm.engine.test.api.mgmt.AlwaysFailingDelegate) Test(org.junit.Test)

Example 8 with MigratingProcessInstanceValidationException

use of org.camunda.bpm.engine.migration.MigratingProcessInstanceValidationException in project camunda-bpm-platform by camunda.

the class MigrationTransitionInstancesTest method testCannotMigrateAsyncBeforeTransitionInstanceToNonAsyncActivity.

@Test
public void testCannotMigrateAsyncBeforeTransitionInstanceToNonAsyncActivity() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
    // when
    try {
        testHelper.createProcessInstanceAndMigrate(migrationPlan);
        Assert.fail("should fail");
    } catch (MigratingProcessInstanceValidationException e) {
        // then
        assertThat(e.getValidationReport()).hasTransitionInstanceFailures("userTask", "Target activity is not asyncBefore");
    }
}
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)

Example 9 with MigratingProcessInstanceValidationException

use of org.camunda.bpm.engine.migration.MigratingProcessInstanceValidationException 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 10 with MigratingProcessInstanceValidationException

use of org.camunda.bpm.engine.migration.MigratingProcessInstanceValidationException 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)

Aggregations

MigratingProcessInstanceValidationException (org.camunda.bpm.engine.migration.MigratingProcessInstanceValidationException)22 Test (org.junit.Test)22 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)21 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)21 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)12 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)6 ExternalTask (org.camunda.bpm.engine.externaltask.ExternalTask)1 LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)1 MigratingActivityInstanceValidationReport (org.camunda.bpm.engine.migration.MigratingActivityInstanceValidationReport)1 MigratingProcessInstanceValidationReport (org.camunda.bpm.engine.migration.MigratingProcessInstanceValidationReport)1 MigratingTransitionInstanceValidationReport (org.camunda.bpm.engine.migration.MigratingTransitionInstanceValidationReport)1 MigrationInstruction (org.camunda.bpm.engine.migration.MigrationInstruction)1 MigrationPlanValidationException (org.camunda.bpm.engine.migration.MigrationPlanValidationException)1 MigrationExecutionDtoBuilder (org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder)1 Incident (org.camunda.bpm.engine.runtime.Incident)1 Job (org.camunda.bpm.engine.runtime.Job)1 AlwaysFailingDelegate (org.camunda.bpm.engine.test.api.mgmt.AlwaysFailingDelegate)1 Matchers.anyString (org.mockito.Matchers.anyString)1