Search in sources :

Example 1 with MigrationPlanBuilder

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

the class MigrationRestServiceInteractionTest method generateMigrationPlanWithNullSourceProcessDefinition.

@Test
public void generateMigrationPlanWithNullSourceProcessDefinition() {
    String message = "source process definition id is null";
    MigrationPlanBuilder planBuilder = mock(MigrationPlanBuilder.class, Mockito.RETURNS_DEEP_STUBS);
    when(runtimeServiceMock.createMigrationPlan(isNull(String.class), anyString())).thenReturn(planBuilder);
    when(planBuilder.mapEqualActivities().build()).thenThrow(new BadUserRequestException(message));
    Map<String, Object> initialMigrationPlan = new MigrationPlanDtoBuilder(null, 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 2 with MigrationPlanBuilder

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

the class MigrationRestServiceInteractionTest method generateMigrationPlanWithNullTargetProcessDefinition.

@Test
public void generateMigrationPlanWithNullTargetProcessDefinition() {
    String message = "target process definition id is null";
    MigrationPlanBuilder migrationPlanBuilder = mock(MigrationPlanBuilder.class, Mockito.RETURNS_DEEP_STUBS);
    when(runtimeServiceMock.createMigrationPlan(anyString(), isNull(String.class))).thenReturn(migrationPlanBuilder);
    when(migrationPlanBuilder.mapEqualActivities().build()).thenThrow(new BadUserRequestException(message));
    Map<String, Object> initialMigrationPlan = new MigrationPlanDtoBuilder(EXAMPLE_PROCESS_DEFINITION_ID, null).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 3 with MigrationPlanBuilder

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

the class MigrationPlanDto method toMigrationPlan.

public static MigrationPlan toMigrationPlan(ProcessEngine processEngine, MigrationPlanDto migrationPlanDto) {
    MigrationPlanBuilder migrationPlanBuilder = processEngine.getRuntimeService().createMigrationPlan(migrationPlanDto.getSourceProcessDefinitionId(), migrationPlanDto.getTargetProcessDefinitionId());
    if (migrationPlanDto.getInstructions() != null) {
        for (MigrationInstructionDto migrationInstructionDto : migrationPlanDto.getInstructions()) {
            MigrationInstructionBuilder migrationInstructionBuilder = migrationPlanBuilder.mapActivities(migrationInstructionDto.getSourceActivityIds().get(0), migrationInstructionDto.getTargetActivityIds().get(0));
            if (Boolean.TRUE.equals(migrationInstructionDto.isUpdateEventTrigger())) {
                migrationInstructionBuilder = migrationInstructionBuilder.updateEventTrigger();
            }
            migrationPlanBuilder = migrationInstructionBuilder;
        }
    }
    return migrationPlanBuilder.build();
}
Also used : MigrationPlanBuilder(org.camunda.bpm.engine.migration.MigrationPlanBuilder) MigrationInstructionBuilder(org.camunda.bpm.engine.migration.MigrationInstructionBuilder)

Example 4 with MigrationPlanBuilder

use of org.camunda.bpm.engine.migration.MigrationPlanBuilder 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 5 with MigrationPlanBuilder

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

Aggregations

MigrationPlanBuilder (org.camunda.bpm.engine.migration.MigrationPlanBuilder)5 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)4 MockMigrationPlanBuilder (org.camunda.bpm.engine.rest.helper.MockMigrationPlanBuilder)4 MigrationPlanDtoBuilder (org.camunda.bpm.engine.rest.util.migration.MigrationPlanDtoBuilder)4 Test (org.junit.Test)4 Matchers.anyString (org.mockito.Matchers.anyString)4 MigrationInstructionBuilder (org.camunda.bpm.engine.migration.MigrationInstructionBuilder)1