Search in sources :

Example 16 with MigrationExecutionDtoBuilder

use of org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder in project camunda-bpm-platform by camunda.

the class MigrationRestServiceInteractionTest method executeMigrationPlanWithNullSourceProcessInstanceId.

@Test
public void executeMigrationPlanWithNullSourceProcessInstanceId() {
    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_URL);
}
Also used : MigrationExecutionDtoBuilder(org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder) FluentAnswer(org.camunda.bpm.engine.rest.helper.FluentAnswer) JoinedMigrationPlanBuilderMock(org.camunda.bpm.engine.rest.helper.MockMigrationPlanBuilder.JoinedMigrationPlanBuilderMock) Matchers.anyString(org.mockito.Matchers.anyString) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Example 17 with MigrationExecutionDtoBuilder

use of org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder in project camunda-bpm-platform by camunda.

the class MigrationRestServiceInteractionTest method executeMigrationPlanWithNullInstructions.

@Test
public void executeMigrationPlanWithNullInstructions() {
    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();
    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_URL);
}
Also used : MigrationExecutionDtoBuilder(org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder) MigrationInstructionValidationReport(org.camunda.bpm.engine.migration.MigrationInstructionValidationReport) 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 18 with MigrationExecutionDtoBuilder

use of org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder in project camunda-bpm-platform by camunda.

the class MigrationRestServiceInteractionTest method executeMigrationPlanWithNonExistingSourceProcessInstanceId.

@Test
public void executeMigrationPlanWithNonExistingSourceProcessInstanceId() {
    String message = "source process definition with id " + NON_EXISTING_PROCESS_DEFINITION_ID + " does not exist";
    JoinedMigrationPlanBuilderMock migrationPlanBuilder = mock(JoinedMigrationPlanBuilderMock.class, new FluentAnswer());
    when(runtimeServiceMock.createMigrationPlan(eq(NON_EXISTING_PROCESS_DEFINITION_ID), anyString())).thenReturn(migrationPlanBuilder);
    when(migrationPlanBuilder.build()).thenThrow(new BadUserRequestException(message));
    Map<String, Object> migrationExecution = new MigrationExecutionDtoBuilder().migrationPlan(NON_EXISTING_PROCESS_DEFINITION_ID, 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_URL);
}
Also used : MigrationExecutionDtoBuilder(org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder) FluentAnswer(org.camunda.bpm.engine.rest.helper.FluentAnswer) JoinedMigrationPlanBuilderMock(org.camunda.bpm.engine.rest.helper.MockMigrationPlanBuilder.JoinedMigrationPlanBuilderMock) Matchers.anyString(org.mockito.Matchers.anyString) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Example 19 with MigrationExecutionDtoBuilder

use of org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder in project camunda-bpm-platform by camunda.

the class MigrationRestServiceInteractionTest method executeMigrationPlanAsyncWithNonExistingSourceProcessDefinitionId.

@Test
public void executeMigrationPlanAsyncWithNonExistingSourceProcessDefinitionId() {
    String message = "source process definition with id " + NON_EXISTING_PROCESS_DEFINITION_ID + " does not exist";
    JoinedMigrationPlanBuilderMock migrationPlanBuilder = mock(JoinedMigrationPlanBuilderMock.class, new FluentAnswer());
    when(runtimeServiceMock.createMigrationPlan(eq(NON_EXISTING_PROCESS_DEFINITION_ID), anyString())).thenReturn(migrationPlanBuilder);
    when(migrationPlanBuilder.build()).thenThrow(new BadUserRequestException(message));
    Map<String, Object> migrationExecution = new MigrationExecutionDtoBuilder().migrationPlan(NON_EXISTING_PROCESS_DEFINITION_ID, 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);
}
Also used : MigrationExecutionDtoBuilder(org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder) FluentAnswer(org.camunda.bpm.engine.rest.helper.FluentAnswer) JoinedMigrationPlanBuilderMock(org.camunda.bpm.engine.rest.helper.MockMigrationPlanBuilder.JoinedMigrationPlanBuilderMock) Matchers.anyString(org.mockito.Matchers.anyString) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Example 20 with MigrationExecutionDtoBuilder

use of org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder in project camunda-bpm-platform by camunda.

the class MigrationRestServiceInteractionTest method executeMigrationPlanAsyncWithNullInstructions.

@Test
public void executeMigrationPlanAsyncWithNullInstructions() {
    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();
    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);
}
Also used : MigrationExecutionDtoBuilder(org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder) MigrationInstructionValidationReport(org.camunda.bpm.engine.migration.MigrationInstructionValidationReport) MigrationPlanValidationException(org.camunda.bpm.engine.migration.MigrationPlanValidationException) Matchers.anyString(org.mockito.Matchers.anyString) MigrationPlanValidationReport(org.camunda.bpm.engine.migration.MigrationPlanValidationReport) Test(org.junit.Test)

Aggregations

MigrationExecutionDtoBuilder (org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder)28 Test (org.junit.Test)28 Matchers.anyString (org.mockito.Matchers.anyString)28 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)16 FluentAnswer (org.camunda.bpm.engine.rest.helper.FluentAnswer)8 JoinedMigrationPlanBuilderMock (org.camunda.bpm.engine.rest.helper.MockMigrationPlanBuilder.JoinedMigrationPlanBuilderMock)8 MigrationInstructionValidationReport (org.camunda.bpm.engine.migration.MigrationInstructionValidationReport)6 MigrationPlanValidationException (org.camunda.bpm.engine.migration.MigrationPlanValidationException)6 MigrationPlanValidationReport (org.camunda.bpm.engine.migration.MigrationPlanValidationReport)6 Batch (org.camunda.bpm.engine.batch.Batch)4 MockProvider.createMockBatch (org.camunda.bpm.engine.rest.helper.MockProvider.createMockBatch)4 MigrationInstruction (org.camunda.bpm.engine.migration.MigrationInstruction)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ProcessInstanceQueryImpl (org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl)2 ProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto)2 MigratingActivityInstanceValidationReport (org.camunda.bpm.engine.migration.MigratingActivityInstanceValidationReport)1 MigratingProcessInstanceValidationException (org.camunda.bpm.engine.migration.MigratingProcessInstanceValidationException)1 MigratingProcessInstanceValidationReport (org.camunda.bpm.engine.migration.MigratingProcessInstanceValidationReport)1 MigratingTransitionInstanceValidationReport (org.camunda.bpm.engine.migration.MigratingTransitionInstanceValidationReport)1