Search in sources :

Example 21 with MigratingProcessInstanceValidationException

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

the class MigrationTransitionInstancesTest method testCannotMigrateAsyncAfterTransitionInstanceToNonAsyncActivity.

@Test
public void testCannotMigrateAsyncAfterTransitionInstanceToNonAsyncActivity() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_AFTER_USER_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask1", "userTask").build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    testHelper.completeTask("userTask1");
    // when
    try {
        testHelper.migrateProcessInstance(migrationPlan, processInstance);
        Assert.fail("should fail");
    } catch (MigratingProcessInstanceValidationException e) {
        // then
        assertThat(e.getValidationReport()).hasTransitionInstanceFailures("userTask1", "Target activity is not asyncAfter");
    }
}
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 22 with MigratingProcessInstanceValidationException

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

the class MigrationRestServiceInteractionTest method executeMigratingProcessInstanceValidationException.

@Test
public void executeMigratingProcessInstanceValidationException() {
    MigrationInstruction migrationInstruction = mock(MigrationInstruction.class);
    when(migrationInstruction.getSourceActivityId()).thenReturn(EXAMPLE_ACTIVITY_ID);
    when(migrationInstruction.getTargetActivityId()).thenReturn(ANOTHER_EXAMPLE_ACTIVITY_ID);
    MigratingActivityInstanceValidationReport instanceReport1 = mock(MigratingActivityInstanceValidationReport.class);
    when(instanceReport1.getActivityInstanceId()).thenReturn(EXAMPLE_ACTIVITY_INSTANCE_ID);
    when(instanceReport1.getMigrationInstruction()).thenReturn(migrationInstruction);
    when(instanceReport1.getSourceScopeId()).thenReturn(EXAMPLE_ACTIVITY_ID);
    when(instanceReport1.getFailures()).thenReturn(Arrays.asList("failure1", "failure2"));
    MigratingTransitionInstanceValidationReport instanceReport2 = mock(MigratingTransitionInstanceValidationReport.class);
    when(instanceReport2.getTransitionInstanceId()).thenReturn("transitionInstanceId");
    when(instanceReport2.getMigrationInstruction()).thenReturn(migrationInstruction);
    when(instanceReport2.getSourceScopeId()).thenReturn(EXAMPLE_ACTIVITY_ID);
    when(instanceReport2.getFailures()).thenReturn(Arrays.asList("failure1", "failure2"));
    MigratingProcessInstanceValidationReport processInstanceReport = mock(MigratingProcessInstanceValidationReport.class);
    when(processInstanceReport.getProcessInstanceId()).thenReturn(EXAMPLE_PROCESS_INSTANCE_ID);
    when(processInstanceReport.getFailures()).thenReturn(Arrays.asList("failure1", "failure2"));
    when(processInstanceReport.getActivityInstanceReports()).thenReturn(Arrays.asList(instanceReport1));
    when(processInstanceReport.getTransitionInstanceReports()).thenReturn(Arrays.asList(instanceReport2));
    doThrow(new MigratingProcessInstanceValidationException("fooo", processInstanceReport)).when(migrationPlanExecutionBuilderMock).execute();
    Map<String, Object> migrationExecution = new MigrationExecutionDtoBuilder().migrationPlan(EXAMPLE_PROCESS_DEFINITION_ID, ANOTHER_EXAMPLE_PROCESS_DEFINITION_ID).instruction(EXAMPLE_ACTIVITY_ID, ANOTHER_EXAMPLE_ACTIVITY_ID).done().processInstances(EXAMPLE_PROCESS_INSTANCE_ID, ANOTHER_EXAMPLE_PROCESS_INSTANCE_ID).build();
    given().contentType(POST_JSON_CONTENT_TYPE).body(migrationExecution).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("type", equalTo(MigratingProcessInstanceValidationException.class.getSimpleName())).body("message", is("fooo")).body("validationReport.processInstanceId", is(EXAMPLE_PROCESS_INSTANCE_ID)).body("validationReport.failures", hasSize(2)).body("validationReport.failures[0]", is("failure1")).body("validationReport.failures[1]", is("failure2")).body("validationReport.activityInstanceValidationReports", hasSize(1)).body("validationReport.activityInstanceValidationReports[0].migrationInstruction.sourceActivityIds", hasSize(1)).body("validationReport.activityInstanceValidationReports[0].migrationInstruction.sourceActivityIds[0]", is(EXAMPLE_ACTIVITY_ID)).body("validationReport.activityInstanceValidationReports[0].migrationInstruction.targetActivityIds", hasSize(1)).body("validationReport.activityInstanceValidationReports[0].migrationInstruction.targetActivityIds[0]", is(ANOTHER_EXAMPLE_ACTIVITY_ID)).body("validationReport.activityInstanceValidationReports[0].activityInstanceId", is(EXAMPLE_ACTIVITY_INSTANCE_ID)).body("validationReport.activityInstanceValidationReports[0].sourceScopeId", is(EXAMPLE_ACTIVITY_ID)).body("validationReport.activityInstanceValidationReports[0].failures", hasSize(2)).body("validationReport.activityInstanceValidationReports[0].failures[0]", is("failure1")).body("validationReport.activityInstanceValidationReports[0].failures[1]", is("failure2")).body("validationReport.transitionInstanceValidationReports", hasSize(1)).body("validationReport.transitionInstanceValidationReports[0].migrationInstruction.sourceActivityIds", hasSize(1)).body("validationReport.transitionInstanceValidationReports[0].migrationInstruction.sourceActivityIds[0]", is(EXAMPLE_ACTIVITY_ID)).body("validationReport.transitionInstanceValidationReports[0].migrationInstruction.targetActivityIds", hasSize(1)).body("validationReport.transitionInstanceValidationReports[0].migrationInstruction.targetActivityIds[0]", is(ANOTHER_EXAMPLE_ACTIVITY_ID)).body("validationReport.transitionInstanceValidationReports[0].transitionInstanceId", is("transitionInstanceId")).body("validationReport.transitionInstanceValidationReports[0].sourceScopeId", is(EXAMPLE_ACTIVITY_ID)).body("validationReport.transitionInstanceValidationReports[0].failures", hasSize(2)).body("validationReport.transitionInstanceValidationReports[0].failures[0]", is("failure1")).body("validationReport.transitionInstanceValidationReports[0].failures[1]", is("failure2")).when().post(EXECUTE_MIGRATION_URL);
}
Also used : MigrationExecutionDtoBuilder(org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder) MigratingActivityInstanceValidationReport(org.camunda.bpm.engine.migration.MigratingActivityInstanceValidationReport) MigrationInstruction(org.camunda.bpm.engine.migration.MigrationInstruction) MigratingProcessInstanceValidationReport(org.camunda.bpm.engine.migration.MigratingProcessInstanceValidationReport) MigratingProcessInstanceValidationException(org.camunda.bpm.engine.migration.MigratingProcessInstanceValidationException) Matchers.anyString(org.mockito.Matchers.anyString) MigratingTransitionInstanceValidationReport(org.camunda.bpm.engine.migration.MigratingTransitionInstanceValidationReport) 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