Search in sources :

Example 6 with MigrationPlanDtoBuilder

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);
}
Also used : MigrationInstructionValidationReport(org.camunda.bpm.engine.migration.MigrationInstructionValidationReport) MigrationInstruction(org.camunda.bpm.engine.migration.MigrationInstruction) MigrationPlanValidationException(org.camunda.bpm.engine.migration.MigrationPlanValidationException) MigrationPlanDtoBuilder(org.camunda.bpm.engine.rest.util.migration.MigrationPlanDtoBuilder) Matchers.anyString(org.mockito.Matchers.anyString) MigrationPlanValidationReport(org.camunda.bpm.engine.migration.MigrationPlanValidationReport) Test(org.junit.Test)

Example 7 with MigrationPlanDtoBuilder

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);
}
Also used : MockMigrationPlanBuilder(org.camunda.bpm.engine.rest.helper.MockMigrationPlanBuilder) MigrationPlanBuilder(org.camunda.bpm.engine.migration.MigrationPlanBuilder) MigrationPlanDtoBuilder(org.camunda.bpm.engine.rest.util.migration.MigrationPlanDtoBuilder) Matchers.anyString(org.mockito.Matchers.anyString) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Example 8 with MigrationPlanDtoBuilder

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);
}
Also used : Response(com.jayway.restassured.response.Response) MigrationPlanDtoBuilder(org.camunda.bpm.engine.rest.util.migration.MigrationPlanDtoBuilder) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 9 with MigrationPlanDtoBuilder

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);
}
Also used : MockMigrationPlanBuilder(org.camunda.bpm.engine.rest.helper.MockMigrationPlanBuilder) MigrationPlanBuilder(org.camunda.bpm.engine.migration.MigrationPlanBuilder) MigrationPlanDtoBuilder(org.camunda.bpm.engine.rest.util.migration.MigrationPlanDtoBuilder) Matchers.anyString(org.mockito.Matchers.anyString) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Example 10 with MigrationPlanDtoBuilder

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);
}
Also used : MigrationPlanDtoBuilder(org.camunda.bpm.engine.rest.util.migration.MigrationPlanDtoBuilder) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

MigrationPlanDtoBuilder (org.camunda.bpm.engine.rest.util.migration.MigrationPlanDtoBuilder)10 Test (org.junit.Test)10 Matchers.anyString (org.mockito.Matchers.anyString)10 Response (com.jayway.restassured.response.Response)4 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)4 MigrationPlanBuilder (org.camunda.bpm.engine.migration.MigrationPlanBuilder)4 MockMigrationPlanBuilder (org.camunda.bpm.engine.rest.helper.MockMigrationPlanBuilder)4 HashMap (java.util.HashMap)1 Map (java.util.Map)1 MigrationInstruction (org.camunda.bpm.engine.migration.MigrationInstruction)1 MigrationInstructionValidationReport (org.camunda.bpm.engine.migration.MigrationInstructionValidationReport)1 MigrationPlanValidationException (org.camunda.bpm.engine.migration.MigrationPlanValidationException)1 MigrationPlanValidationReport (org.camunda.bpm.engine.migration.MigrationPlanValidationReport)1