Search in sources :

Example 1 with MigrationInstruction

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

the class MigrationRestServiceInteractionTest method executeMigrationPlanValidationException.

@Test
public void executeMigrationPlanValidationException() {
    MigrationInstruction migrationInstruction = mock(MigrationInstruction.class);
    when(migrationInstruction.getSourceActivityId()).thenReturn(EXAMPLE_ACTIVITY_ID);
    when(migrationInstruction.getTargetActivityId()).thenReturn(ANOTHER_EXAMPLE_ACTIVITY_ID);
    MigrationInstructionValidationReport instructionReport1 = mock(MigrationInstructionValidationReport.class);
    when(instructionReport1.getMigrationInstruction()).thenReturn(migrationInstruction);
    when(instructionReport1.getFailures()).thenReturn(Arrays.asList("failure1", "failure2"));
    MigrationInstructionValidationReport instructionReport2 = mock(MigrationInstructionValidationReport.class);
    when(instructionReport2.getMigrationInstruction()).thenReturn(migrationInstruction);
    when(instructionReport2.getFailures()).thenReturn(Arrays.asList("failure1", "failure2"));
    MigrationPlanValidationReport validationReport = mock(MigrationPlanValidationReport.class);
    when(validationReport.getInstructionReports()).thenReturn(Arrays.asList(instructionReport1, instructionReport2));
    when(migrationPlanBuilderMock.build()).thenThrow(new MigrationPlanValidationException("fooo", validationReport));
    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(MigrationPlanValidationException.class.getSimpleName())).body("message", is("fooo")).body("validationReport.instructionReports", hasSize(2)).body("validationReport.instructionReports[0].instruction.sourceActivityIds", hasSize(1)).body("validationReport.instructionReports[0].instruction.sourceActivityIds[0]", is(EXAMPLE_ACTIVITY_ID)).body("validationReport.instructionReports[0].instruction.targetActivityIds", hasSize(1)).body("validationReport.instructionReports[0].instruction.targetActivityIds[0]", is(ANOTHER_EXAMPLE_ACTIVITY_ID)).body("validationReport.instructionReports[0].failures", hasSize(2)).body("validationReport.instructionReports[0].failures[0]", is("failure1")).body("validationReport.instructionReports[0].failures[1]", is("failure2")).when().post(EXECUTE_MIGRATION_URL);
}
Also used : MigrationExecutionDtoBuilder(org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder) MigrationInstructionValidationReport(org.camunda.bpm.engine.migration.MigrationInstructionValidationReport) MigrationInstruction(org.camunda.bpm.engine.migration.MigrationInstruction) MigrationPlanValidationException(org.camunda.bpm.engine.migration.MigrationPlanValidationException) Matchers.anyString(org.mockito.Matchers.anyString) MigrationPlanValidationReport(org.camunda.bpm.engine.migration.MigrationPlanValidationReport) Test(org.junit.Test)

Example 2 with MigrationInstruction

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

the class MigrationRestServiceInteractionTest method executeMigrationPlanAsyncValidationException.

@Test
public void executeMigrationPlanAsyncValidationException() {
    MigrationInstruction migrationInstruction = mock(MigrationInstruction.class);
    when(migrationInstruction.getSourceActivityId()).thenReturn(EXAMPLE_ACTIVITY_ID);
    when(migrationInstruction.getTargetActivityId()).thenReturn(ANOTHER_EXAMPLE_ACTIVITY_ID);
    MigrationInstructionValidationReport instructionReport1 = mock(MigrationInstructionValidationReport.class);
    when(instructionReport1.getMigrationInstruction()).thenReturn(migrationInstruction);
    when(instructionReport1.getFailures()).thenReturn(Arrays.asList("failure1", "failure2"));
    MigrationInstructionValidationReport instructionReport2 = mock(MigrationInstructionValidationReport.class);
    when(instructionReport2.getMigrationInstruction()).thenReturn(migrationInstruction);
    when(instructionReport2.getFailures()).thenReturn(Arrays.asList("failure1", "failure2"));
    MigrationPlanValidationReport validationReport = mock(MigrationPlanValidationReport.class);
    when(validationReport.getInstructionReports()).thenReturn(Arrays.asList(instructionReport1, instructionReport2));
    when(migrationPlanBuilderMock.build()).thenThrow(new MigrationPlanValidationException("fooo", validationReport));
    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(MigrationPlanValidationException.class.getSimpleName())).body("message", is("fooo")).body("validationReport.instructionReports", hasSize(2)).body("validationReport.instructionReports[0].instruction.sourceActivityIds", hasSize(1)).body("validationReport.instructionReports[0].instruction.sourceActivityIds[0]", is(EXAMPLE_ACTIVITY_ID)).body("validationReport.instructionReports[0].instruction.targetActivityIds", hasSize(1)).body("validationReport.instructionReports[0].instruction.targetActivityIds[0]", is(ANOTHER_EXAMPLE_ACTIVITY_ID)).body("validationReport.instructionReports[0].failures", hasSize(2)).body("validationReport.instructionReports[0].failures[0]", is("failure1")).body("validationReport.instructionReports[0].failures[1]", is("failure2")).when().post(EXECUTE_MIGRATION_ASYNC_URL);
}
Also used : MigrationExecutionDtoBuilder(org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder) MigrationInstructionValidationReport(org.camunda.bpm.engine.migration.MigrationInstructionValidationReport) MigrationInstruction(org.camunda.bpm.engine.migration.MigrationInstruction) MigrationPlanValidationException(org.camunda.bpm.engine.migration.MigrationPlanValidationException) Matchers.anyString(org.mockito.Matchers.anyString) MigrationPlanValidationReport(org.camunda.bpm.engine.migration.MigrationPlanValidationReport) Test(org.junit.Test)

Example 3 with MigrationInstruction

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

the class MockMigrationInstructionBuilder method build.

public MigrationInstruction build() {
    MigrationInstruction migrationInstructionMock = mock(MigrationInstruction.class);
    when(migrationInstructionMock.getSourceActivityId()).thenReturn(sourceActivityIds.get(0));
    when(migrationInstructionMock.getTargetActivityId()).thenReturn(targetActivityIds.get(0));
    when(migrationInstructionMock.isUpdateEventTrigger()).thenReturn(updateEventTrigger);
    return migrationInstructionMock;
}
Also used : MigrationInstruction(org.camunda.bpm.engine.migration.MigrationInstruction)

Example 4 with MigrationInstruction

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

the class MockMigrationPlanBuilder method instruction.

public MockMigrationPlanBuilder instruction(String sourceActivityId, String targetActivityId, Boolean updateEventTrigger) {
    MockMigrationInstructionBuilder instructionBuilder = new MockMigrationInstructionBuilder().sourceActivityId(sourceActivityId).targetActivityId(targetActivityId);
    if (Boolean.TRUE.equals(updateEventTrigger)) {
        instructionBuilder = instructionBuilder.updateEventTrigger();
    }
    MigrationInstruction instructionMock = instructionBuilder.build();
    return instruction(instructionMock);
}
Also used : MigrationInstruction(org.camunda.bpm.engine.migration.MigrationInstruction)

Example 5 with MigrationInstruction

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

the class CreateMigrationPlanCmd method execute.

@Override
public MigrationPlan execute(CommandContext commandContext) {
    ProcessDefinitionEntity sourceProcessDefinition = getProcessDefinition(commandContext, migrationBuilder.getSourceProcessDefinitionId(), "Source");
    ProcessDefinitionEntity targetProcessDefinition = getProcessDefinition(commandContext, migrationBuilder.getTargetProcessDefinitionId(), "Target");
    checkAuthorization(commandContext, sourceProcessDefinition, targetProcessDefinition);
    MigrationPlanImpl migrationPlan = new MigrationPlanImpl(sourceProcessDefinition.getId(), targetProcessDefinition.getId());
    List<MigrationInstruction> instructions = new ArrayList<MigrationInstruction>();
    if (migrationBuilder.isMapEqualActivities()) {
        instructions.addAll(generateInstructions(commandContext, sourceProcessDefinition, targetProcessDefinition, migrationBuilder.isUpdateEventTriggersForGeneratedInstructions()));
    }
    instructions.addAll(migrationBuilder.getExplicitMigrationInstructions());
    migrationPlan.setInstructions(instructions);
    validateMigrationPlan(commandContext, migrationPlan, sourceProcessDefinition, targetProcessDefinition);
    return migrationPlan;
}
Also used : MigrationInstruction(org.camunda.bpm.engine.migration.MigrationInstruction) ValidatingMigrationInstruction(org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstruction) ArrayList(java.util.ArrayList) MigrationPlanImpl(org.camunda.bpm.engine.impl.migration.MigrationPlanImpl) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)

Aggregations

MigrationInstruction (org.camunda.bpm.engine.migration.MigrationInstruction)18 Test (org.junit.Test)6 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)5 Matchers.anyString (org.mockito.Matchers.anyString)4 ArrayList (java.util.ArrayList)3 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)3 MigrationInstructionValidationReport (org.camunda.bpm.engine.migration.MigrationInstructionValidationReport)3 MigrationPlanValidationException (org.camunda.bpm.engine.migration.MigrationPlanValidationException)3 MigrationPlanValidationReport (org.camunda.bpm.engine.migration.MigrationPlanValidationReport)3 MigrationExecutionDtoBuilder (org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder)3 MigratingActivityInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance)2 ValidatingMigrationInstruction (org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstruction)2 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)2 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)2 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)2 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)2 Deployment (org.camunda.bpm.engine.test.Deployment)2 EventSubscriptionDeclaration (org.camunda.bpm.engine.impl.bpmn.parser.EventSubscriptionDeclaration)1 TimerDeclarationImpl (org.camunda.bpm.engine.impl.jobexecutor.TimerDeclarationImpl)1 MigrationPlanImpl (org.camunda.bpm.engine.impl.migration.MigrationPlanImpl)1