use of org.camunda.bpm.engine.migration.MigrationInstruction in project camunda-bpm-platform by camunda.
the class MigrationPlanDto method from.
public static MigrationPlanDto from(MigrationPlan migrationPlan) {
MigrationPlanDto dto = new MigrationPlanDto();
dto.setSourceProcessDefinitionId(migrationPlan.getSourceProcessDefinitionId());
dto.setTargetProcessDefinitionId(migrationPlan.getTargetProcessDefinitionId());
ArrayList<MigrationInstructionDto> instructionDtos = new ArrayList<MigrationInstructionDto>();
if (migrationPlan.getInstructions() != null) {
for (MigrationInstruction migrationInstruction : migrationPlan.getInstructions()) {
MigrationInstructionDto migrationInstructionDto = MigrationInstructionDto.from(migrationInstruction);
instructionDtos.add(migrationInstructionDto);
}
}
dto.setInstructions(instructionDtos);
return dto;
}
use of org.camunda.bpm.engine.migration.MigrationInstruction in project camunda-bpm-platform by camunda.
the class MigrationRestServiceInteractionTest method validateMigrationPlanValidationException.
@Test
public void validateMigrationPlanValidationException() {
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> migrationPlan = new MigrationPlanDtoBuilder(EXAMPLE_PROCESS_DEFINITION_ID, ANOTHER_EXAMPLE_PROCESS_DEFINITION_ID).instruction(EXAMPLE_ACTIVITY_ID, ANOTHER_EXAMPLE_ACTIVITY_ID).build();
given().contentType(POST_JSON_CONTENT_TYPE).body(migrationPlan).then().expect().statusCode(Status.OK.getStatusCode()).body("instructionReports", hasSize(2)).body("instructionReports[0].instruction.sourceActivityIds", hasSize(1)).body("instructionReports[0].instruction.sourceActivityIds[0]", is(EXAMPLE_ACTIVITY_ID)).body("instructionReports[0].instruction.targetActivityIds", hasSize(1)).body("instructionReports[0].instruction.targetActivityIds[0]", is(ANOTHER_EXAMPLE_ACTIVITY_ID)).body("instructionReports[0].failures", hasSize(2)).body("instructionReports[0].failures[0]", is("failure1")).body("instructionReports[0].failures[1]", is("failure2")).when().post(VALIDATE_MIGRATION_URL);
}
use of org.camunda.bpm.engine.migration.MigrationInstruction 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);
}
Aggregations