use of org.camunda.bpm.engine.rest.util.migration.MigrationPlanDtoBuilder 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.rest.util.migration.MigrationPlanDtoBuilder in project camunda-bpm-platform by camunda.
the class MigrationRestServiceInteractionTest method generateMigrationPlanWithNonExistingTargetProcessDefinition.
@Test
public void generateMigrationPlanWithNonExistingTargetProcessDefinition() {
String message = "target process definition with id " + NON_EXISTING_PROCESS_DEFINITION_ID + " does not exist";
MigrationPlanBuilder migrationPlanBuilder = mock(MigrationPlanBuilder.class, Mockito.RETURNS_DEEP_STUBS);
when(runtimeServiceMock.createMigrationPlan(anyString(), eq(NON_EXISTING_PROCESS_DEFINITION_ID))).thenReturn(migrationPlanBuilder);
when(migrationPlanBuilder.mapEqualActivities().build()).thenThrow(new BadUserRequestException(message));
Map<String, Object> initialMigrationPlan = new MigrationPlanDtoBuilder(EXAMPLE_PROCESS_DEFINITION_ID, NON_EXISTING_PROCESS_DEFINITION_ID).build();
given().contentType(POST_JSON_CONTENT_TYPE).body(initialMigrationPlan).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("message", is(message)).when().post(GENERATE_MIGRATION_URL);
}
use of org.camunda.bpm.engine.rest.util.migration.MigrationPlanDtoBuilder in project camunda-bpm-platform by camunda.
the class MigrationRestServiceInteractionTest method generateMigrationPlanIgnoringInitialInstructions.
@Test
public void generateMigrationPlanIgnoringInitialInstructions() {
Map<String, Object> initialMigrationPlan = new MigrationPlanDtoBuilder(EXAMPLE_PROCESS_DEFINITION_ID, ANOTHER_EXAMPLE_PROCESS_DEFINITION_ID).instruction("ignored", "ignored").build();
Response response = given().contentType(POST_JSON_CONTENT_TYPE).body(initialMigrationPlan).then().expect().statusCode(Status.OK.getStatusCode()).when().post(GENERATE_MIGRATION_URL);
verifyGenerateMigrationPlanInteraction(migrationPlanBuilderMock, initialMigrationPlan);
verifyGenerateMigrationPlanResponse(response);
}
use of org.camunda.bpm.engine.rest.util.migration.MigrationPlanDtoBuilder in project camunda-bpm-platform by camunda.
the class MigrationRestServiceInteractionTest method generateMigrationPlanWithNonExistingSourceProcessDefinition.
@Test
public void generateMigrationPlanWithNonExistingSourceProcessDefinition() {
String message = "source process definition with id " + NON_EXISTING_PROCESS_DEFINITION_ID + " does not exist";
MigrationPlanBuilder migrationPlanBuilder = mock(MigrationPlanBuilder.class, Mockito.RETURNS_DEEP_STUBS);
when(runtimeServiceMock.createMigrationPlan(eq(NON_EXISTING_PROCESS_DEFINITION_ID), anyString())).thenReturn(migrationPlanBuilder);
when(migrationPlanBuilder.mapEqualActivities().build()).thenThrow(new BadUserRequestException(message));
Map<String, Object> initialMigrationPlan = new MigrationPlanDtoBuilder(NON_EXISTING_PROCESS_DEFINITION_ID, ANOTHER_EXAMPLE_PROCESS_DEFINITION_ID).build();
given().contentType(POST_JSON_CONTENT_TYPE).body(initialMigrationPlan).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("message", is(message)).when().post(GENERATE_MIGRATION_URL);
}
use of org.camunda.bpm.engine.rest.util.migration.MigrationPlanDtoBuilder in project camunda-bpm-platform by camunda.
the class MigrationRestServiceInteractionTest method validateMigrationPlan.
@Test
public void validateMigrationPlan() {
Map<String, Object> migrationPlan = new MigrationPlanDtoBuilder(EXAMPLE_PROCESS_DEFINITION_ID, ANOTHER_EXAMPLE_PROCESS_DEFINITION_ID).instruction(EXAMPLE_ACTIVITY_ID, ANOTHER_EXAMPLE_ACTIVITY_ID).instruction(ANOTHER_EXAMPLE_ACTIVITY_ID, EXAMPLE_ACTIVITY_ID, true).build();
given().contentType(POST_JSON_CONTENT_TYPE).body(migrationPlan).then().expect().statusCode(Status.OK.getStatusCode()).body("instructionReports", hasSize(0)).when().post(VALIDATE_MIGRATION_URL);
verifyCreateMigrationPlanInteraction(migrationPlanBuilderMock, migrationPlan);
}
Aggregations