Search in sources :

Example 51 with MigrationPlan

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

the class MigrationExternalTaskTest method testProperties.

@Test
public void testProperties() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS).changeElementId(ProcessModels.PROCESS_KEY, "new" + ProcessModels.PROCESS_KEY).changeElementId("externalTask", "newExternalTask"));
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("externalTask", "newExternalTask").build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    ExternalTask externalTaskBeforeMigration = rule.getExternalTaskService().createExternalTaskQuery().singleResult();
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then all properties are the same apart from the process reference
    ExternalTask externalTaskAfterMigration = rule.getExternalTaskService().createExternalTaskQuery().singleResult();
    Assert.assertEquals("newExternalTask", externalTaskAfterMigration.getActivityId());
    Assert.assertEquals(targetProcessDefinition.getId(), externalTaskAfterMigration.getProcessDefinitionId());
    Assert.assertEquals("new" + ProcessModels.PROCESS_KEY, externalTaskAfterMigration.getProcessDefinitionKey());
    Assert.assertEquals(externalTaskBeforeMigration.getPriority(), externalTaskAfterMigration.getPriority());
    Assert.assertEquals(externalTaskBeforeMigration.getActivityInstanceId(), externalTaskAfterMigration.getActivityInstanceId());
    Assert.assertEquals(externalTaskBeforeMigration.getErrorMessage(), externalTaskAfterMigration.getErrorMessage());
    Assert.assertEquals(externalTaskBeforeMigration.getExecutionId(), externalTaskAfterMigration.getExecutionId());
    Assert.assertEquals(externalTaskBeforeMigration.getId(), externalTaskAfterMigration.getId());
    Assert.assertEquals(externalTaskBeforeMigration.getLockExpirationTime(), externalTaskAfterMigration.getLockExpirationTime());
    Assert.assertEquals(processInstance.getId(), externalTaskAfterMigration.getProcessInstanceId());
    Assert.assertEquals(externalTaskBeforeMigration.getRetries(), externalTaskAfterMigration.getRetries());
    Assert.assertEquals(externalTaskBeforeMigration.getTenantId(), externalTaskAfterMigration.getTenantId());
    Assert.assertEquals(externalTaskBeforeMigration.getTopicName(), externalTaskAfterMigration.getTopicName());
    Assert.assertEquals(externalTaskBeforeMigration.getWorkerId(), externalTaskAfterMigration.getWorkerId());
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) Test(org.junit.Test)

Example 52 with MigrationPlan

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

the class MigrationGatewayTest method testInclusiveGatewayAssertTrees.

@Test
public void testInclusiveGatewayAssertTrees() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(GatewayModels.INCLUSIVE_GW);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(GatewayModels.INCLUSIVE_GW);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("parallel1", "parallel1").mapActivities("join", "join").build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    testHelper.completeTask("parallel2");
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then
    testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree(null).scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).child("parallel1").noScope().concurrent().id(testHelper.getSingleExecutionIdForActivityBeforeMigration("parallel1")).up().child("join").noScope().concurrent().id(testHelper.getSingleExecutionIdForActivityBeforeMigration("join")).done());
    testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).activity("parallel1", testHelper.getSingleActivityInstanceBeforeMigration("parallel1").getId()).activity("join", testHelper.getSingleActivityInstanceBeforeMigration("join").getId()).done());
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test)

Example 53 with MigrationPlan

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

the class MigrationGatewayTest method testInclusiveGatewayContinueExecution.

@Test
public void testInclusiveGatewayContinueExecution() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(GatewayModels.INCLUSIVE_GW);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(GatewayModels.INCLUSIVE_GW);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("parallel1", "parallel1").mapActivities("join", "join").build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    testHelper.completeTask("parallel2");
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then
    Assert.assertEquals(1, rule.getTaskService().createTaskQuery().count());
    Assert.assertEquals(0, rule.getTaskService().createTaskQuery().taskDefinitionKey("afterJoin").count());
    testHelper.completeTask("parallel1");
    testHelper.completeTask("afterJoin");
    testHelper.assertProcessEnded(processInstance.getId());
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test)

Example 54 with MigrationPlan

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

the class MigrationGatewayTest method testParallelGatewayAssertTrees.

@Test
public void testParallelGatewayAssertTrees() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(GatewayModels.PARALLEL_GW);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(GatewayModels.PARALLEL_GW);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("parallel1", "parallel1").mapActivities("join", "join").build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    testHelper.completeTask("parallel2");
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then
    testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree(null).scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).child("parallel1").noScope().concurrent().id(testHelper.getSingleExecutionIdForActivityBeforeMigration("parallel1")).up().child("join").noScope().concurrent().id(testHelper.getSingleExecutionIdForActivityBeforeMigration("join")).done());
    testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).activity("parallel1", testHelper.getSingleActivityInstanceBeforeMigration("parallel1").getId()).activity("join", testHelper.getSingleActivityInstanceBeforeMigration("join").getId()).done());
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test)

Example 55 with MigrationPlan

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

the class MigrationIncidentTest method testCustomIncidentMigration.

@Test
public void testCustomIncidentMigration() {
    // given
    RuntimeService runtimeService = engineRule.getRuntimeService();
    BpmnModelInstance instance1 = Bpmn.createExecutableProcess("process1").startEvent().userTask("u1").endEvent().done();
    BpmnModelInstance instance2 = Bpmn.createExecutableProcess("process2").startEvent().userTask("u2").endEvent().done();
    testHelper.deploy(instance1, instance2);
    ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("process1");
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("process2");
    MigrationPlan migrationPlan = runtimeService.createMigrationPlan(processInstance1.getProcessDefinitionId(), processInstance2.getProcessDefinitionId()).mapActivities("u1", "u2").build();
    runtimeService.createIncident("custom", processInstance1.getId(), "foo");
    // when
    runtimeService.newMigration(migrationPlan).processInstanceIds(processInstance1.getId()).execute();
    // then
    Incident incident = runtimeService.createIncidentQuery().singleResult();
    assertEquals(processInstance2.getProcessDefinitionId(), incident.getProcessDefinitionId());
    assertEquals("custom", incident.getIncidentType());
    assertEquals(processInstance1.getId(), incident.getExecutionId());
}
Also used : RuntimeService(org.camunda.bpm.engine.RuntimeService) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) Incident(org.camunda.bpm.engine.runtime.Incident) Test(org.junit.Test)

Aggregations

MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)485 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)474 Test (org.junit.Test)474 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)272 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)67 Job (org.camunda.bpm.engine.runtime.Job)48 Task (org.camunda.bpm.engine.task.Task)45 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)26 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)22 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)22 MigratingProcessInstanceValidationException (org.camunda.bpm.engine.migration.MigratingProcessInstanceValidationException)21 UserTask (org.camunda.bpm.model.bpmn.instance.UserTask)21 ExecutionTree (org.camunda.bpm.engine.test.util.ExecutionTree)20 Incident (org.camunda.bpm.engine.runtime.Incident)14 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)14 MigratingBpmnEventTrigger (org.camunda.bpm.engine.test.api.runtime.migration.util.MigratingBpmnEventTrigger)14 Batch (org.camunda.bpm.engine.batch.Batch)13 LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)13 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)13 Execution (org.camunda.bpm.engine.runtime.Execution)11