Search in sources :

Example 1 with MigrationPlanValidationReport

use of org.camunda.bpm.engine.migration.MigrationPlanValidationReport in project camunda-bpm-platform by camunda.

the class MigrationRestServiceInteractionTest method executeMigrationPlanWithEmptyInstructions.

@Test
public void executeMigrationPlanWithEmptyInstructions() {
    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_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) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 2 with MigrationPlanValidationReport

use of org.camunda.bpm.engine.migration.MigrationPlanValidationReport in project camunda-bpm-platform by camunda.

the class MigrationRestServiceInteractionTest method executeMigrationPlanValidationException.

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

use of org.camunda.bpm.engine.migration.MigrationPlanValidationReport 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);
}
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) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 4 with MigrationPlanValidationReport

use of org.camunda.bpm.engine.migration.MigrationPlanValidationReport 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);
}
Also used : MigrationExecutionDtoBuilder(org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder) MigrationInstructionValidationReport(org.camunda.bpm.engine.migration.MigrationInstructionValidationReport) MigrationInstruction(org.camunda.bpm.engine.migration.MigrationInstruction) 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 5 with MigrationPlanValidationReport

use of org.camunda.bpm.engine.migration.MigrationPlanValidationReport 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)

Aggregations

MigrationInstructionValidationReport (org.camunda.bpm.engine.migration.MigrationInstructionValidationReport)7 MigrationPlanValidationException (org.camunda.bpm.engine.migration.MigrationPlanValidationException)7 MigrationPlanValidationReport (org.camunda.bpm.engine.migration.MigrationPlanValidationReport)7 Test (org.junit.Test)7 Matchers.anyString (org.mockito.Matchers.anyString)7 MigrationExecutionDtoBuilder (org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder)6 MigrationInstruction (org.camunda.bpm.engine.migration.MigrationInstruction)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 MigrationPlanDtoBuilder (org.camunda.bpm.engine.rest.util.migration.MigrationPlanDtoBuilder)1