Search in sources :

Example 11 with MigrationPlanValidationException

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

the class MigrationRemoveSubprocessTest method testCannotRemoveParentScopeAndMoveOutOfGrandParentScope.

@Test
public void testCannotRemoveParentScopeAndMoveOutOfGrandParentScope() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.TRIPLE_SUBPROCESS_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.TRIPLE_SUBPROCESS_PROCESS);
    // when
    try {
        // subProcess2 is not migrated
        // subProcess 3 is moved out of the subProcess1 scope (by becoming a subProcess1 itself)
        rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("subProcess1", "subProcess1").mapActivities("subProcess3", "subProcess1").mapActivities("userTask", "userTask").build();
        Assert.fail("should not validate");
    } catch (MigrationPlanValidationException e) {
        MigrationPlanValidationReportAssert.assertThat(e.getValidationReport()).hasInstructionFailures("subProcess3", "The closest mapped ancestor 'subProcess1' is mapped to scope 'subProcess1' which is not an ancestor of target scope 'subProcess1'");
    }
}
Also used : MigrationPlanValidationException(org.camunda.bpm.engine.migration.MigrationPlanValidationException) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test)

Example 12 with MigrationPlanValidationException

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

the class MigrationRemoveSubprocessTest method testCannotRemoveScopeAndMoveToConcurrentActivity.

/**
 * Remove when implementing CAM-5407
 */
@Test
public void testCannotRemoveScopeAndMoveToConcurrentActivity() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_SUBPROCESS_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_TASK_AND_SUBPROCESS_PROCESS);
    // when
    try {
        rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("subProcess", "subProcess").mapActivities("userTask1", "userTask1").mapActivities("userTask2", "userTask2").build();
        Assert.fail("should not validate");
    } catch (MigrationPlanValidationException e) {
        MigrationPlanValidationReportAssert.assertThat(e.getValidationReport()).hasInstructionFailures("userTask2", "The closest mapped ancestor 'subProcess' is mapped to scope 'subProcess' which is not an ancestor of target scope 'userTask2'");
    }
}
Also used : MigrationPlanValidationException(org.camunda.bpm.engine.migration.MigrationPlanValidationException) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test)

Example 13 with MigrationPlanValidationException

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

the class MigrationMultiInstanceTest method testMigrateSequenatialMiBodyRemoveSubprocess.

@Test
public void testMigrateSequenatialMiBodyRemoveSubprocess() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(MultiInstanceProcessModels.SEQ_MI_SUBPROCESS_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(MultiInstanceProcessModels.SEQ_MI_ONE_TASK_PROCESS);
    try {
        rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities(miBodyOf("subProcess"), miBodyOf("userTask")).mapActivities("userTask", "userTask").build();
        fail("Should not succeed");
    } catch (MigrationPlanValidationException e) {
        assertThat(e.getValidationReport()).hasInstructionFailures(miBodyOf("subProcess"), "Cannot remove the inner activity of a multi-instance body when the body is mapped");
    }
}
Also used : MigrationPlanValidationException(org.camunda.bpm.engine.migration.MigrationPlanValidationException) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test)

Example 14 with MigrationPlanValidationException

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

the class MigrationMultiInstanceTest method testMigrateParallelToSequential.

@Test
public void testMigrateParallelToSequential() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(MultiInstanceProcessModels.PAR_MI_ONE_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(MultiInstanceProcessModels.SEQ_MI_ONE_TASK_PROCESS);
    try {
        rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities(miBodyOf("userTask"), miBodyOf("userTask")).mapActivities("userTask", "userTask").build();
        fail("Should not succeed");
    } catch (MigrationPlanValidationException e) {
        assertThat(e.getValidationReport()).hasInstructionFailures(miBodyOf("userTask"), "Activities have incompatible types (ParallelMultiInstanceActivityBehavior is not " + "compatible with SequentialMultiInstanceActivityBehavior)");
    }
}
Also used : MigrationPlanValidationException(org.camunda.bpm.engine.migration.MigrationPlanValidationException) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test)

Example 15 with MigrationPlanValidationException

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

the class MigrationEventSubProcessTest method testMigrateEventSubprocessChangeStartEventType.

@Test
public void testMigrateEventSubprocessChangeStartEventType() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(EventSubProcessModels.SIGNAL_EVENT_SUBPROCESS_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(EventSubProcessModels.TIMER_EVENT_SUBPROCESS_PROCESS);
    try {
        // when
        rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities(USER_TASK_ID, USER_TASK_ID).mapActivities(EVENT_SUB_PROCESS_START_ID, EVENT_SUB_PROCESS_START_ID).build();
        Assert.fail("exception expected");
    } catch (MigrationPlanValidationException e) {
        // then
        assertThat(e.getValidationReport()).hasInstructionFailures(EVENT_SUB_PROCESS_START_ID, "Events are not of the same type (signalStartEvent != startTimerEvent)");
    }
}
Also used : MigrationPlanValidationException(org.camunda.bpm.engine.migration.MigrationPlanValidationException) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test)

Aggregations

MigrationPlanValidationException (org.camunda.bpm.engine.migration.MigrationPlanValidationException)46 Test (org.junit.Test)46 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)39 MigrationInstructionValidationReport (org.camunda.bpm.engine.migration.MigrationInstructionValidationReport)7 MigrationPlanValidationReport (org.camunda.bpm.engine.migration.MigrationPlanValidationReport)7 Matchers.anyString (org.mockito.Matchers.anyString)7 MigrationExecutionDtoBuilder (org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder)6 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)5 MigrationInstruction (org.camunda.bpm.engine.migration.MigrationInstruction)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 MigrationPlanDtoBuilder (org.camunda.bpm.engine.rest.util.migration.MigrationPlanDtoBuilder)1 UserTaskBuilder (org.camunda.bpm.model.bpmn.builder.UserTaskBuilder)1