use of org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder in project camunda-bpm-platform by camunda.
the class MigrationRestServiceInteractionTest method executeMigrationPlanWithNonExistingSourceActivityId.
@Test
public void executeMigrationPlanWithNonExistingSourceActivityId() {
String message = "sourceActivity is null";
when(migrationPlanBuilderMock.mapActivities(eq(NON_EXISTING_ACTIVITY_ID), anyString())).thenThrow(new BadUserRequestException(message));
Map<String, Object> migrationExecution = new MigrationExecutionDtoBuilder().migrationPlan(EXAMPLE_PROCESS_DEFINITION_ID, ANOTHER_EXAMPLE_PROCESS_DEFINITION_ID).instruction(NON_EXISTING_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_URL);
}
use of org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder in project camunda-bpm-platform by camunda.
the class MigrationRestServiceInteractionTest method executeMigrationPlanAsyncWithNullSourceProcessDefinitionId.
@Test
public void executeMigrationPlanAsyncWithNullSourceProcessDefinitionId() {
String message = "source process definition id is null";
JoinedMigrationPlanBuilderMock migrationPlanBuilder = mock(JoinedMigrationPlanBuilderMock.class, new FluentAnswer());
when(runtimeServiceMock.createMigrationPlan(isNull(String.class), anyString())).thenReturn(migrationPlanBuilder);
when(migrationPlanBuilder.build()).thenThrow(new BadUserRequestException(message));
Map<String, Object> migrationExecution = new MigrationExecutionDtoBuilder().migrationPlan(null, ANOTHER_EXAMPLE_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 executeMigrationPlanWithNullTargetProcessInstanceId.
@Test
public void executeMigrationPlanWithNullTargetProcessInstanceId() {
String message = "target process definition id is null";
JoinedMigrationPlanBuilderMock migrationPlanBuilder = mock(JoinedMigrationPlanBuilderMock.class, new FluentAnswer());
when(runtimeServiceMock.createMigrationPlan(anyString(), isNull(String.class))).thenReturn(migrationPlanBuilder);
when(migrationPlanBuilder.build()).thenThrow(new BadUserRequestException(message));
Map<String, Object> migrationExecution = new MigrationExecutionDtoBuilder().migrationPlan(EXAMPLE_PROCESS_DEFINITION_ID, null).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_URL);
}
use of org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder in project camunda-bpm-platform by camunda.
the class MigrationRestServiceInteractionTest method executeMigrationPlanAsyncWithEmptyInstructions.
@Test
public void executeMigrationPlanAsyncWithEmptyInstructions() {
MigrationInstructionValidationReport instructionReport = mock(MigrationInstructionValidationReport.class);
when(instructionReport.getMigrationInstruction()).thenReturn(null);
when(instructionReport.getFailures()).thenReturn(Collections.singletonList("failure"));
MigrationPlanValidationReport validationReport = mock(MigrationPlanValidationReport.class);
when(validationReport.getInstructionReports()).thenReturn(Collections.singletonList(instructionReport));
when(migrationPlanBuilderMock.build()).thenThrow(new MigrationPlanValidationException("fooo", validationReport));
Map<String, Object> migrationExecution = new MigrationExecutionDtoBuilder().migrationPlan(EXAMPLE_PROCESS_DEFINITION_ID, ANOTHER_EXAMPLE_PROCESS_DEFINITION_ID).done().processInstances(EXAMPLE_PROCESS_INSTANCE_ID, ANOTHER_EXAMPLE_PROCESS_INSTANCE_ID).build();
((Map<String, Object>) migrationExecution.get(MigrationExecutionDtoBuilder.PROP_MIGRATION_PLAN)).put(MigrationPlanDtoBuilder.PROP_INSTRUCTIONS, Collections.<MigrationInstructionDto>emptyList());
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(1)).body("validationReport.instructionReports[0].instruction", nullValue()).body("validationReport.instructionReports[0].failures", hasSize(1)).body("validationReport.instructionReports[0].failures[0]", is("failure")).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 executeMigrationPlanWithNullTargetActivityId.
@Test
public void executeMigrationPlanWithNullTargetActivityId() {
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_URL);
}
Aggregations