MigrationManager { public MigrationReport migrate() { return migrate(null); } MigrationManager(MigrationSpec migrationSpec); MigrationReport migrate(); MigrationReport migrate(Map<String, String> nodeMapping);  }
@Test public void testMigrateUserTaskProcessInstance() { createRuntimeManagers("migration/v1/BPMN2-UserTask-v1.bpmn2", "migration/v2/BPMN2-UserTask-v2.bpmn2"); assertNotNull(managerV1); assertNotNull(managerV2); RuntimeEngine runtime = managerV1.getRuntimeEngine(EmptyContext.get()); KieSession ksession = runtime.getKieSession(); assertNotNull(ksession); ProcessInstance pi1 = ksession.startProcess(PROCESS_ID_V1); assertNotNull(pi1); assertEquals(ProcessInstance.STATE_ACTIVE, pi1.getState()); JPAAuditLogService auditService = new JPAAuditLogService(emf); ProcessInstanceLog log = auditService.findProcessInstance(pi1.getId()); assertNotNull(log); assertEquals(PROCESS_ID_V1, log.getProcessId()); assertEquals(PROCESS_NAME_V1, log.getProcessName()); assertEquals(DEPLOYMENT_ID_V1, log.getExternalId()); TaskService taskService = runtime.getTaskService(); List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner(USER_JOHN, "en-UK"); assertNotNull(tasks); assertEquals(1, tasks.size()); TaskSummary task = tasks.get(0); assertNotNull(task); assertEquals(PROCESS_ID_V1, task.getProcessId()); assertEquals(DEPLOYMENT_ID_V1, task.getDeploymentId()); assertEquals(TASK_NAME_V1, task.getName()); managerV1.disposeRuntimeEngine(runtime); MigrationSpec migrationSpec = new MigrationSpec(DEPLOYMENT_ID_V1, pi1.getId(), DEPLOYMENT_ID_V2, PROCESS_ID_V2); MigrationManager migrationManager = new MigrationManager(migrationSpec); MigrationReport report = migrationManager.migrate(); assertNotNull(report); assertTrue(report.isSuccessful()); log = auditService.findProcessInstance(pi1.getId()); assertNotNull(log); assertEquals(PROCESS_ID_V2, log.getProcessId()); assertEquals(PROCESS_NAME_V2, log.getProcessName()); assertEquals(DEPLOYMENT_ID_V2, log.getExternalId()); auditService.dispose(); runtime = managerV2.getRuntimeEngine(EmptyContext.get()); taskService = runtime.getTaskService(); tasks = taskService.getTasksAssignedAsPotentialOwner(USER_JOHN, "en-UK"); assertNotNull(tasks); assertEquals(1, tasks.size()); task = tasks.get(0); assertNotNull(task); assertEquals(PROCESS_ID_V2, task.getProcessId()); assertEquals(DEPLOYMENT_ID_V2, task.getDeploymentId()); assertEquals(TASK_NAME_V2, task.getName()); managerV2.disposeRuntimeEngine(runtime); }
@Test public void testMigrateUserTaskProcessInstanceWithNodeMapping() { createRuntimeManagers("migration/v1/BPMN2-UserTask-v1.bpmn2", "migration/v2/BPMN2-UserTask-v2.bpmn2"); assertNotNull(managerV1); assertNotNull(managerV2); RuntimeEngine runtime = managerV1.getRuntimeEngine(EmptyContext.get()); KieSession ksession = runtime.getKieSession(); assertNotNull(ksession); ProcessInstance pi1 = ksession.startProcess(PROCESS_ID_V1); assertNotNull(pi1); assertEquals(ProcessInstance.STATE_ACTIVE, pi1.getState()); TaskService taskService = runtime.getTaskService(); TaskSummary task = getTask(taskService); managerV1.disposeRuntimeEngine(runtime); assertEquals(PROCESS_ID_V1, task.getProcessId()); assertEquals(DEPLOYMENT_ID_V1, task.getDeploymentId()); assertEquals(TASK_NAME_V1, task.getName()); MigrationSpec migrationSpec = new MigrationSpec(DEPLOYMENT_ID_V1, pi1.getId(), DEPLOYMENT_ID_V2, PROCESS_ID_V2); MigrationManager migrationManager = new MigrationManager(migrationSpec); MigrationReport report = migrationManager.migrate(Collections.singletonMap("_2", "_2")); assertNotNull(report); assertTrue(report.isSuccessful()); assertMigratedProcessInstance(PROCESS_ID_V2, pi1.getId(), ProcessInstance.STATE_ACTIVE); runtime = managerV2.getRuntimeEngine(EmptyContext.get()); taskService = runtime.getTaskService(); assertMigratedTaskAndComplete(taskService, PROCESS_ID_V2, pi1.getId(), TASK_NAME_V2); assertMigratedProcessInstance(PROCESS_ID_V2, pi1.getId(), ProcessInstance.STATE_COMPLETED); managerV2.disposeRuntimeEngine(runtime); }
@SuppressWarnings({"unchecked", "rawtypes"}) @Test public void testMigrateUserTaskProcessInstanceWithRollback() { createRuntimeManagers("migration/v1/BPMN2-UserTask-v1.bpmn2", "migration/v2/BPMN2-UserTask-v2.bpmn2"); assertNotNull(managerV1); assertNotNull(managerV2); RuntimeEngine runtime = managerV1.getRuntimeEngine(EmptyContext.get()); KieSession ksession = runtime.getKieSession(); assertNotNull(ksession); ProcessInstance pi1 = ksession.startProcess(PROCESS_ID_V1); assertNotNull(pi1); assertEquals(ProcessInstance.STATE_ACTIVE, pi1.getState()); managerV1.disposeRuntimeEngine(runtime); MigrationSpec migrationSpec = new MigrationSpec(DEPLOYMENT_ID_V1, pi1.getId(), DEPLOYMENT_ID_V2, PROCESS_ID_V2); MigrationManager migrationManager = new MigrationManager(migrationSpec); MigrationReport report = null; try { Map erronousMapping = Collections.singletonMap("_2", 2); migrationManager.migrate(erronousMapping); } catch (MigrationException e) { report = e.getReport(); } assertNotNull(report); assertFalse(report.isSuccessful()); JPAAuditLogService auditService = new JPAAuditLogService(emf); ProcessInstanceLog log = auditService.findProcessInstance(pi1.getId()); assertNotNull(log); assertEquals(PROCESS_ID_V1, log.getProcessId()); assertEquals(DEPLOYMENT_ID_V1, log.getExternalId()); auditService.dispose(); }
@Test public void testAddTaskAfterActive() { createRuntimeManagers("migration/v1/AddTaskAfterActive-v1.bpmn2", "migration/v2/AddTaskAfterActive-v2.bpmn2"); assertNotNull(managerV1); assertNotNull(managerV2); RuntimeEngine runtime = managerV1.getRuntimeEngine(EmptyContext.get()); KieSession ksession = runtime.getKieSession(); assertNotNull(ksession); ProcessInstance pi1 = ksession.startProcess(ADDTASKAFTERACTIVE_ID_V1); assertNotNull(pi1); assertEquals(ProcessInstance.STATE_ACTIVE, pi1.getState()); managerV1.disposeRuntimeEngine(runtime); MigrationSpec migrationSpec = new MigrationSpec(DEPLOYMENT_ID_V1, pi1.getId(), DEPLOYMENT_ID_V2, ADDTASKAFTERACTIVE_ID_V2); MigrationManager migrationManager = new MigrationManager(migrationSpec); MigrationReport report = migrationManager.migrate(); assertNotNull(report); assertTrue(report.isSuccessful()); assertMigratedProcessInstance(ADDTASKAFTERACTIVE_ID_V2, pi1.getId(), ProcessInstance.STATE_ACTIVE); runtime = managerV2.getRuntimeEngine(EmptyContext.get()); TaskService taskService = runtime.getTaskService(); assertMigratedTaskAndComplete(taskService, ADDTASKAFTERACTIVE_ID_V2, pi1.getId(), "Active Task"); managerV2.disposeRuntimeEngine(runtime); assertMigratedProcessInstance(ADDTASKAFTERACTIVE_ID_V2, pi1.getId(), ProcessInstance.STATE_ACTIVE); runtime = managerV2.getRuntimeEngine(EmptyContext.get()); taskService = runtime.getTaskService(); assertMigratedTaskAndComplete(taskService, ADDTASKAFTERACTIVE_ID_V2, pi1.getId(), "Added Task"); assertMigratedProcessInstance(ADDTASKAFTERACTIVE_ID_V2, pi1.getId(), ProcessInstance.STATE_COMPLETED); managerV2.disposeRuntimeEngine(runtime); }
@Test public void testAddTaskBeforeActive() { String activeNodeId = "_18771A1A-9DB9-4CA1-8C2E-19DEE24A1776"; String addedNodeId = "_94643E69-BD97-4E4A-8B4A-364FEB95CA3C"; createRuntimeManagers("migration/v1/AddTaskBeforeActive-v1.bpmn2", "migration/v2/AddTaskBeforeActive-v2.bpmn2"); assertNotNull(managerV1); assertNotNull(managerV2); RuntimeEngine runtime = managerV1.getRuntimeEngine(EmptyContext.get()); KieSession ksession = runtime.getKieSession(); assertNotNull(ksession); ProcessInstance pi1 = ksession.startProcess(ADDTASKBEFOREACTIVE_ID_V1); assertNotNull(pi1); assertEquals(ProcessInstance.STATE_ACTIVE, pi1.getState()); managerV1.disposeRuntimeEngine(runtime); MigrationSpec migrationSpec = new MigrationSpec(DEPLOYMENT_ID_V1, pi1.getId(), DEPLOYMENT_ID_V2, ADDTASKBEFOREACTIVE_ID_V2); MigrationManager migrationManager = new MigrationManager(migrationSpec); MigrationReport report = migrationManager.migrate(Collections.singletonMap(activeNodeId, addedNodeId)); assertNotNull(report); assertTrue(report.isSuccessful()); assertMigratedProcessInstance(ADDTASKBEFOREACTIVE_ID_V2, pi1.getId(), ProcessInstance.STATE_ACTIVE); runtime = managerV2.getRuntimeEngine(EmptyContext.get()); TaskService taskService = runtime.getTaskService(); assertMigratedTaskAndComplete(taskService, ADDTASKBEFOREACTIVE_ID_V2, pi1.getId(), "Added Task"); managerV2.disposeRuntimeEngine(runtime); assertMigratedProcessInstance(ADDTASKBEFOREACTIVE_ID_V2, pi1.getId(), ProcessInstance.STATE_ACTIVE); runtime = managerV2.getRuntimeEngine(EmptyContext.get()); taskService = runtime.getTaskService(); assertMigratedTaskAndComplete(taskService, ADDTASKBEFOREACTIVE_ID_V2, pi1.getId(), "Active Task"); managerV2.disposeRuntimeEngine(runtime); assertMigratedProcessInstance(ADDTASKBEFOREACTIVE_ID_V2, pi1.getId(), ProcessInstance.STATE_COMPLETED); }
@Test public void testRemoveActiveTask() { String activeNodeId = "_ECEDD1CE-7380-418C-B7A6-AF8ECB90B820"; String nextNodeId = "_9EF3CAE0-D978-4E96-9C00-8A80082EB68E"; createRuntimeManagers("migration/v1/RemoveActiveTask-v1.bpmn2", "migration/v2/RemoveActiveTask-v2.bpmn2"); assertNotNull(managerV1); assertNotNull(managerV2); RuntimeEngine runtime = managerV1.getRuntimeEngine(EmptyContext.get()); KieSession ksession = runtime.getKieSession(); assertNotNull(ksession); ProcessInstance pi1 = ksession.startProcess(REMOVEACTIVETASK_ID_V1); assertNotNull(pi1); assertEquals(ProcessInstance.STATE_ACTIVE, pi1.getState()); managerV1.disposeRuntimeEngine(runtime); MigrationSpec migrationSpec = new MigrationSpec(DEPLOYMENT_ID_V1, pi1.getId(), DEPLOYMENT_ID_V2, REMOVEACTIVETASK_ID_V2); MigrationManager migrationManager = new MigrationManager(migrationSpec); MigrationReport report = migrationManager.migrate(Collections.singletonMap(activeNodeId, nextNodeId)); assertNotNull(report); assertTrue(report.isSuccessful()); assertMigratedProcessInstance(REMOVEACTIVETASK_ID_V2, pi1.getId(), ProcessInstance.STATE_ACTIVE); runtime = managerV2.getRuntimeEngine(EmptyContext.get()); TaskService taskService = runtime.getTaskService(); assertMigratedTaskAndComplete(taskService, REMOVEACTIVETASK_ID_V2, pi1.getId(), "Mapped Task"); assertMigratedProcessInstance(REMOVEACTIVETASK_ID_V2, pi1.getId(), ProcessInstance.STATE_COMPLETED); managerV2.disposeRuntimeEngine(runtime); }
@Test public void testRemoveNonActiveTask() { createRuntimeManagers("migration/v1/RemoveNonActiveTask-v1.bpmn2", "migration/v2/RemoveNonActiveTask-v2.bpmn2"); assertNotNull(managerV1); assertNotNull(managerV2); RuntimeEngine runtime = managerV1.getRuntimeEngine(EmptyContext.get()); KieSession ksession = runtime.getKieSession(); assertNotNull(ksession); ProcessInstance pi1 = ksession.startProcess(REMOVENONACTIVETASK_ID_V1); assertNotNull(pi1); assertEquals(ProcessInstance.STATE_ACTIVE, pi1.getState()); managerV1.disposeRuntimeEngine(runtime); MigrationSpec migrationSpec = new MigrationSpec(DEPLOYMENT_ID_V1, pi1.getId(), DEPLOYMENT_ID_V2, REMOVENONACTIVETASK_ID_V2); MigrationManager migrationManager = new MigrationManager(migrationSpec); MigrationReport report = migrationManager.migrate(); assertNotNull(report); assertTrue(report.isSuccessful()); assertMigratedProcessInstance(REMOVENONACTIVETASK_ID_V2, pi1.getId(), ProcessInstance.STATE_ACTIVE); runtime = managerV2.getRuntimeEngine(EmptyContext.get()); TaskService taskService = runtime.getTaskService(); assertMigratedTaskAndComplete(taskService, REMOVENONACTIVETASK_ID_V2, pi1.getId(), "Active Task"); assertMigratedProcessInstance(REMOVENONACTIVETASK_ID_V2, pi1.getId(), ProcessInstance.STATE_COMPLETED); managerV2.disposeRuntimeEngine(runtime); }
@Test public void testReplaceActiveTask() { String activeNodeId = "_E9140EE9-1B5A-46B1-871E-A735402B69F4"; String replaceNodeId = "_9B25FCC5-C718-4941-A4AE-DD8D6E368F48"; createRuntimeManagers("migration/v1/ReplaceActiveTask-v1.bpmn2", "migration/v2/ReplaceActiveTask-v2.bpmn2"); assertNotNull(managerV1); assertNotNull(managerV2); RuntimeEngine runtime = managerV1.getRuntimeEngine(EmptyContext.get()); KieSession ksession = runtime.getKieSession(); assertNotNull(ksession); ProcessInstance pi1 = ksession.startProcess(REPLACEACTIVETASK_ID_V1); assertNotNull(pi1); assertEquals(ProcessInstance.STATE_ACTIVE, pi1.getState()); managerV1.disposeRuntimeEngine(runtime); MigrationSpec migrationSpec = new MigrationSpec(DEPLOYMENT_ID_V1, pi1.getId(), DEPLOYMENT_ID_V2, REPLACEACTIVETASK_ID_V2); MigrationManager migrationManager = new MigrationManager(migrationSpec); MigrationReport report = migrationManager.migrate(Collections.singletonMap(activeNodeId, replaceNodeId)); assertNotNull(report); assertTrue(report.isSuccessful()); assertMigratedProcessInstance(REPLACEACTIVETASK_ID_V2, pi1.getId(), ProcessInstance.STATE_ACTIVE); runtime = managerV2.getRuntimeEngine(EmptyContext.get()); TaskService taskService = runtime.getTaskService(); assertMigratedTaskAndComplete(taskService, REPLACEACTIVETASK_ID_V2, pi1.getId(), "Mapped Task"); assertMigratedProcessInstance(REPLACEACTIVETASK_ID_V2, pi1.getId(), ProcessInstance.STATE_COMPLETED); managerV2.disposeRuntimeEngine(runtime); }
@Test public void testRemoveNonActiveBeforeActiveTask() { createRuntimeManagers("migration/v1/RemoveNonActiveBeforeTask-v1.bpmn2", "migration/v2/RemoveNonActiveBeforeTask-v2.bpmn2"); assertNotNull(managerV1); assertNotNull(managerV2); RuntimeEngine runtime = managerV1.getRuntimeEngine(EmptyContext.get()); KieSession ksession = runtime.getKieSession(); assertNotNull(ksession); ProcessInstance pi1 = ksession.startProcess(REMOVENONACTIVEBEFORETASK_ID_V1); assertNotNull(pi1); assertEquals(ProcessInstance.STATE_ACTIVE, pi1.getState()); assertTaskAndComplete(runtime.getTaskService(), REMOVENONACTIVEBEFORETASK_ID_V1, pi1.getId(), "Active Task"); managerV1.disposeRuntimeEngine(runtime); MigrationSpec migrationSpec = new MigrationSpec(DEPLOYMENT_ID_V1, pi1.getId(), DEPLOYMENT_ID_V2, REMOVENONACTIVEBEFORETASK_ID_V2); MigrationManager migrationManager = new MigrationManager(migrationSpec); MigrationReport report = migrationManager.migrate(); assertNotNull(report); assertTrue(report.isSuccessful()); assertMigratedProcessInstance(REMOVENONACTIVEBEFORETASK_ID_V2, pi1.getId(), ProcessInstance.STATE_ACTIVE); runtime = managerV2.getRuntimeEngine(EmptyContext.get()); TaskService taskService = runtime.getTaskService(); assertMigratedTaskAndComplete(taskService, REMOVENONACTIVEBEFORETASK_ID_V2, pi1.getId(), "Non-active Task"); assertMigratedProcessInstance(REMOVENONACTIVEBEFORETASK_ID_V2, pi1.getId(), ProcessInstance.STATE_COMPLETED); managerV2.disposeRuntimeEngine(runtime); }
@Test public void testMigrateUserTaskProcessInstanceDifferentRuntimeManagers() { RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get() .newDefaultBuilder() .entityManagerFactory(emf) .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("migration/v1/BPMN2-UserTask-v1.bpmn2"), ResourceType.BPMN2) .get(); managerV1 = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment, DEPLOYMENT_ID_V1); RuntimeEnvironment environment2 = RuntimeEnvironmentBuilder.Factory.get() .newDefaultBuilder() .entityManagerFactory(emf) .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("migration/v2/BPMN2-UserTask-v2.bpmn2"), ResourceType.BPMN2) .get(); managerV2 = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment2, DEPLOYMENT_ID_V2); assertNotNull(managerV1); assertNotNull(managerV2); RuntimeEngine runtime = managerV1.getRuntimeEngine(EmptyContext.get()); KieSession ksession = runtime.getKieSession(); assertNotNull(ksession); ProcessInstance pi1 = ksession.startProcess(PROCESS_ID_V1); assertNotNull(pi1); assertEquals(ProcessInstance.STATE_ACTIVE, pi1.getState()); JPAAuditLogService auditService = new JPAAuditLogService(emf); ProcessInstanceLog log = auditService.findProcessInstance(pi1.getId()); assertNotNull(log); assertEquals(PROCESS_ID_V1, log.getProcessId()); assertEquals(PROCESS_NAME_V1, log.getProcessName()); assertEquals(DEPLOYMENT_ID_V1, log.getExternalId()); TaskService taskService = runtime.getTaskService(); List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner(USER_JOHN, "en-UK"); assertNotNull(tasks); assertEquals(1, tasks.size()); TaskSummary task = tasks.get(0); assertNotNull(task); assertEquals(PROCESS_ID_V1, task.getProcessId()); assertEquals(DEPLOYMENT_ID_V1, task.getDeploymentId()); assertEquals(TASK_NAME_V1, task.getName()); managerV1.disposeRuntimeEngine(runtime); MigrationSpec migrationSpec = new MigrationSpec(DEPLOYMENT_ID_V1, pi1.getId(), DEPLOYMENT_ID_V2, PROCESS_ID_V2); MigrationManager migrationManager = new MigrationManager(migrationSpec); try { migrationManager.migrate(); } catch (MigrationException e) { assertEquals("Source (org.jbpm.runtime.manager.impl.SingletonRuntimeManager) and target (org.jbpm.runtime.manager.impl.PerProcessInstanceRuntimeManager) deployments are of different type (they represent different runtime strategies)", e.getMessage()); } runtime = managerV1.getRuntimeEngine(EmptyContext.get()); ksession = runtime.getKieSession(); assertNotNull(ksession); auditService = new JPAAuditLogService(emf); log = auditService.findProcessInstance(pi1.getId()); assertNotNull(log); assertEquals(PROCESS_ID_V1, log.getProcessId()); assertEquals(PROCESS_NAME_V1, log.getProcessName()); assertEquals(DEPLOYMENT_ID_V1, log.getExternalId()); taskService = runtime.getTaskService(); tasks = taskService.getTasksAssignedAsPotentialOwner(USER_JOHN, "en-UK"); assertNotNull(tasks); assertEquals(1, tasks.size()); task = tasks.get(0); assertNotNull(task); assertEquals(PROCESS_ID_V1, task.getProcessId()); assertEquals(DEPLOYMENT_ID_V1, task.getDeploymentId()); assertEquals(TASK_NAME_V1, task.getName()); managerV1.disposeRuntimeEngine(runtime); }
@Test public void testMigrateMultiInstance() { createRuntimeManagers("migration/v1/BPMN2-MultiInstance-v1.bpmn2", "migration/v2/BPMN2-MultiInstance-v2.bpmn2"); assertNotNull(managerV1); assertNotNull(managerV2); RuntimeEngine runtime = managerV1.getRuntimeEngine(EmptyContext.get()); KieSession ksession = runtime.getKieSession(); assertNotNull(ksession); List<String> processVar1 = new ArrayList<String>(); processVar1.add("one"); processVar1.add("two"); Map<String, Object> params = new HashMap<String, Object>(); params.put("processVar1", processVar1); ProcessInstance pi1 = ksession.startProcess(MULTIINSTANCE_ID_V1, params); assertNotNull(pi1); assertEquals(ProcessInstance.STATE_ACTIVE, pi1.getState()); JPAAuditLogService auditService = new JPAAuditLogService(emf); ProcessInstanceLog log = auditService.findProcessInstance(pi1.getId()); assertNotNull(log); assertEquals(MULTIINSTANCE_ID_V1, log.getProcessId()); assertEquals(DEPLOYMENT_ID_V1, log.getExternalId()); TaskService taskService = runtime.getTaskService(); List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner(USER_JOHN, "en-UK"); assertNotNull(tasks); assertEquals(2, tasks.size()); TaskSummary task = tasks.get(0); assertNotNull(task); assertEquals(MULTIINSTANCE_ID_V1, task.getProcessId()); assertEquals(DEPLOYMENT_ID_V1, task.getDeploymentId()); managerV1.disposeRuntimeEngine(runtime); MigrationSpec migrationSpec = new MigrationSpec(DEPLOYMENT_ID_V1, pi1.getId(), DEPLOYMENT_ID_V2, MULTIINSTANCE_ID_V2); MigrationManager migrationManager = new MigrationManager(migrationSpec); Map<String, String> nodeMapping = new HashMap<>(); nodeMapping.put("_2", "UserTask_1"); MigrationReport report = migrationManager.migrate(nodeMapping); assertNotNull(report); assertTrue(report.isSuccessful()); log = auditService.findProcessInstance(pi1.getId()); assertNotNull(log); assertEquals(MULTIINSTANCE_ID_V2, log.getProcessId()); assertEquals(DEPLOYMENT_ID_V2, log.getExternalId()); auditService.dispose(); runtime = managerV2.getRuntimeEngine(EmptyContext.get()); taskService = runtime.getTaskService(); tasks = taskService.getTasksAssignedAsPotentialOwner(USER_JOHN, "en-UK"); assertNotNull(tasks); assertEquals(2, tasks.size()); task = tasks.get(0); assertNotNull(task); assertEquals(MULTIINSTANCE_ID_V2, task.getProcessId()); assertEquals(DEPLOYMENT_ID_V2, task.getDeploymentId()); managerV2.disposeRuntimeEngine(runtime); }
@Test public void testAddTaskAfterActiveTaskNameExpression() { createRuntimeManagers("migration/v1/AddTaskAfterActiveExpression-v1.bpmn2", "migration/v2/AddTaskAfterActiveExpression-v2.bpmn2"); assertNotNull(managerV1); assertNotNull(managerV2); RuntimeEngine runtime = managerV1.getRuntimeEngine(EmptyContext.get()); KieSession ksession = runtime.getKieSession(); assertNotNull(ksession); Map<String, Object> params = new HashMap<>(); params.put("s", "test"); ProcessInstance pi1 = ksession.startProcess(ADDTASKAFTERACTIVE_EXPR_ID_V1, params); assertNotNull(pi1); assertEquals(ProcessInstance.STATE_ACTIVE, pi1.getState()); TaskService taskService = runtime.getTaskService(); List<TaskSummary> tasks = taskService.getTasksByStatusByProcessInstanceId(pi1.getId(), Arrays.asList(Status.Reserved), "en-UK"); assertNotNull(tasks); assertEquals(1, tasks.size()); TaskSummary task = tasks.get(0); assertNotNull(task); assertEquals(ADDTASKAFTERACTIVE_EXPR_ID_V1, task.getProcessId()); assertEquals(DEPLOYMENT_ID_V1, task.getDeploymentId()); assertEquals("Active Task test", task.getName()); managerV1.disposeRuntimeEngine(runtime); MigrationSpec migrationSpec = new MigrationSpec(DEPLOYMENT_ID_V1, pi1.getId(), DEPLOYMENT_ID_V2, ADDTASKAFTERACTIVE_EXPR_ID_V2); MigrationManager migrationManager = new MigrationManager(migrationSpec); MigrationReport report = migrationManager.migrate(); assertNotNull(report); assertTrue(report.isSuccessful()); assertMigratedProcessInstance(ADDTASKAFTERACTIVE_EXPR_ID_V2, pi1.getId(), ProcessInstance.STATE_ACTIVE); runtime = managerV2.getRuntimeEngine(EmptyContext.get()); taskService = runtime.getTaskService(); assertMigratedTaskAndComplete(taskService, ADDTASKAFTERACTIVE_EXPR_ID_V2, pi1.getId(), "Active Task test"); managerV2.disposeRuntimeEngine(runtime); }