Search in sources :

Example 16 with MigratingProcessInstanceValidationException

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

the class MigrationCompensationTest method testCannotMigrateActivityInstanceForCompensationThrowingEvent.

@Test
public void testCannotMigrateActivityInstanceForCompensationThrowingEvent() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    testHelper.completeTask("userTask1");
    testHelper.completeTask("userTask2");
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("compensationEvent", "compensationEvent").mapActivities("compensationHandler", "compensationHandler").build();
    // when
    try {
        testHelper.migrateProcessInstance(migrationPlan, processInstance);
        Assert.fail("should fail");
    } catch (MigratingProcessInstanceValidationException e) {
        // then
        assertThat(e.getValidationReport()).hasProcessInstanceId(testHelper.snapshotBeforeMigration.getProcessInstanceId()).hasActivityInstanceFailures("compensationEvent", "The type of the source activity is not supported for activity instance migration");
    }
}
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 17 with MigratingProcessInstanceValidationException

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

the class MigrationSignallableServiceTaskTest method testCannotMigrateAsyncActivityInstance.

@Test
public void testCannotMigrateAsyncActivityInstance() {
    // given
    BpmnModelInstance model = ProcessModels.newModel().startEvent().serviceTask("serviceTask").camundaAsyncBefore().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();
    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
        assertThat(e.getValidationReport()).hasActivityInstanceFailures("serviceTask", "The type of the source activity is not supported for activity instance migration");
    }
}
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 18 with MigratingProcessInstanceValidationException

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

the class MigrationTransitionInstancesTest method testMigrateAsyncBeforeStartEventTransitionInstanceCase2.

@Test
public void testMigrateAsyncBeforeStartEventTransitionInstanceCase2() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_START_EVENT_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_SUBPROCESS_START_EVENT_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("startEvent", "subProcessStart").build();
    // when
    try {
        testHelper.createProcessInstanceAndMigrate(migrationPlan);
        Assert.fail("should fail");
    } catch (MigratingProcessInstanceValidationException e) {
        assertThat(e.getValidationReport()).hasTransitionInstanceFailures("startEvent", "A transition instance that instantiates the process can only be migrated to a process-level flow node");
    }
}
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 19 with MigratingProcessInstanceValidationException

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

the class MigrationTransitionInstancesTest method testCannotMigrateUnmappedTransitionInstance.

@Test
public void testCannotMigrateUnmappedTransitionInstance() {
    // 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()).build();
    // when
    try {
        testHelper.createProcessInstanceAndMigrate(migrationPlan);
        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) MigratingProcessInstanceValidationException(org.camunda.bpm.engine.migration.MigratingProcessInstanceValidationException) Test(org.junit.Test)

Example 20 with MigratingProcessInstanceValidationException

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

the class MigrationTransitionInstancesTest method testCannotMigrateUnmappedTransitionInstanceAtNonLeafActivity.

@Test
public void testCannotMigrateUnmappedTransitionInstanceAtNonLeafActivity() {
    // given
    BpmnModelInstance model = modify(ProcessModels.SUBPROCESS_PROCESS).activityBuilder("subProcess").camundaAsyncBefore(true).done();
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(model);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(model);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).build();
    // when
    try {
        testHelper.createProcessInstanceAndMigrate(migrationPlan);
        Assert.fail("should fail");
    } catch (MigratingProcessInstanceValidationException e) {
        // then
        assertThat(e.getValidationReport()).hasTransitionInstanceFailures("subProcess", "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