use of org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder in project camunda-bpm-platform by camunda.
the class MigrationRestServiceInteractionTest method executeMigrationPlanAsyncSkipListeners.
@Test
public void executeMigrationPlanAsyncSkipListeners() {
Batch batchMock = createMockBatch();
when(migrationPlanExecutionBuilderMock.executeAsync()).thenReturn(batchMock);
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).skipCustomListeners(true).build();
given().contentType(POST_JSON_CONTENT_TYPE).body(migrationExecution).then().expect().statusCode(Status.OK.getStatusCode()).when().post(EXECUTE_MIGRATION_ASYNC_URL);
verifyMigrationPlanAsyncExecutionInteraction(migrationExecution);
}
use of org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder in project camunda-bpm-platform by camunda.
the class MigrationRestServiceInteractionTest method executeMigrationPlanAsyncWithNullTargetActivityId.
@Test
public void executeMigrationPlanAsyncWithNullTargetActivityId() {
String message = "targetActivityId is null";
when(migrationPlanBuilderMock.mapActivities(anyString(), isNull(String.class))).thenThrow(new BadUserRequestException(message));
Map<String, Object> migrationExecution = new MigrationExecutionDtoBuilder().migrationPlan(EXAMPLE_PROCESS_DEFINITION_ID, ANOTHER_EXAMPLE_PROCESS_DEFINITION_ID).instruction(EXAMPLE_ACTIVITY_ID, null).instruction(ANOTHER_EXAMPLE_ACTIVITY_ID, 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("message", is(message)).when().post(EXECUTE_MIGRATION_ASYNC_URL);
}
use of org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder 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);
}
use of org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder in project camunda-bpm-platform by camunda.
the class MigrationRestServiceInteractionTest method executeMigrationPlanAsyncWithNonExistingTargetProcessDefinitionId.
@Test
public void executeMigrationPlanAsyncWithNonExistingTargetProcessDefinitionId() {
String message = "target process definition with id " + NON_EXISTING_PROCESS_DEFINITION_ID + " does not exist";
JoinedMigrationPlanBuilderMock migrationPlanBuilder = mock(JoinedMigrationPlanBuilderMock.class, new FluentAnswer());
when(runtimeServiceMock.createMigrationPlan(anyString(), eq(NON_EXISTING_PROCESS_DEFINITION_ID))).thenReturn(migrationPlanBuilder);
when(migrationPlanBuilder.build()).thenThrow(new BadUserRequestException(message));
Map<String, Object> migrationExecution = new MigrationExecutionDtoBuilder().migrationPlan(EXAMPLE_PROCESS_DEFINITION_ID, NON_EXISTING_PROCESS_DEFINITION_ID).instruction(EXAMPLE_ACTIVITY_ID, ANOTHER_EXAMPLE_ACTIVITY_ID).instruction(ANOTHER_EXAMPLE_ACTIVITY_ID, 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("message", is(message)).when().post(EXECUTE_MIGRATION_ASYNC_URL);
}
use of org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder in project camunda-bpm-platform by camunda.
the class MigrationRestServiceInteractionTest method executeMigrationPlanAsyncWithNonExistingTargetActivityId.
@Test
public void executeMigrationPlanAsyncWithNonExistingTargetActivityId() {
String message = "targetActivity is null";
when(migrationPlanBuilderMock.mapActivities(anyString(), eq(NON_EXISTING_ACTIVITY_ID))).thenThrow(new BadUserRequestException(message));
Map<String, Object> migrationExecution = new MigrationExecutionDtoBuilder().migrationPlan(EXAMPLE_PROCESS_DEFINITION_ID, ANOTHER_EXAMPLE_PROCESS_DEFINITION_ID).instruction(EXAMPLE_ACTIVITY_ID, NON_EXISTING_ACTIVITY_ID).instruction(ANOTHER_EXAMPLE_ACTIVITY_ID, 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("message", is(message)).when().post(EXECUTE_MIGRATION_URL);
}
Aggregations