org.camunda.bpm.engine.runtime.ProcessInstance

Here are the examples of the java api class org.camunda.bpm.engine.runtime.ProcessInstance taken from open source projects.

1. ProcessInstanceQueryTest#testQueryBySuperProcessInstanceIdNested()

View license
// Nested subprocess make the query complexer, hence this test
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/superProcessWithNestedSubProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/runtime/nestedSubProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/runtime/subProcess.bpmn20.xml" })
public void testQueryBySuperProcessInstanceIdNested() {
    ProcessInstance superProcessInstance = runtimeService.startProcessInstanceByKey("nestedSubProcessQueryTest");
    ProcessInstance subProcessInstance = runtimeService.createProcessInstanceQuery().superProcessInstanceId(superProcessInstance.getId()).singleResult();
    assertNotNull(subProcessInstance);
    ProcessInstance nestedSubProcessInstance = runtimeService.createProcessInstanceQuery().superProcessInstanceId(subProcessInstance.getId()).singleResult();
    assertNotNull(nestedSubProcessInstance);
}

2. ProcessInstanceQueryTest#testQueryBySubProcessInstanceIdNested()

View license
//Nested subprocess make the query complexer, hence this test
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/superProcessWithNestedSubProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/runtime/nestedSubProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/runtime/subProcess.bpmn20.xml" })
public void testQueryBySubProcessInstanceIdNested() {
    ProcessInstance superProcessInstance = runtimeService.startProcessInstanceByKey("nestedSubProcessQueryTest");
    ProcessInstance subProcessInstance = runtimeService.createProcessInstanceQuery().superProcessInstanceId(superProcessInstance.getId()).singleResult();
    assertEquals(superProcessInstance.getId(), runtimeService.createProcessInstanceQuery().subProcessInstanceId(subProcessInstance.getId()).singleResult().getId());
    ProcessInstance nestedSubProcessInstance = runtimeService.createProcessInstanceQuery().superProcessInstanceId(subProcessInstance.getId()).singleResult();
    assertEquals(subProcessInstance.getId(), runtimeService.createProcessInstanceQuery().subProcessInstanceId(nestedSubProcessInstance.getId()).singleResult().getId());
}

3. TaskQueryTest#testQueryResultOrderingByStringVariableWithMixedCase()

View license
@Deployment(resources = "org/camunda/bpm/engine/test/api/task/TaskQueryTest.testProcessDefinition.bpmn20.xml")
public void testQueryResultOrderingByStringVariableWithMixedCase() {
    // given three tasks with String and Integer process instance variables
    ProcessInstance instance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Collections.<String, Object>singletonMap("var", "a"));
    ProcessInstance instance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Collections.<String, Object>singletonMap("var", "B"));
    ProcessInstance instance3 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Collections.<String, Object>singletonMap("var", "c"));
    // when I make a task query with variable ordering by String values
    List<Task> tasks = taskService.createTaskQuery().processDefinitionKey("oneTaskProcess").orderByProcessVariable("var", ValueType.STRING).asc().list();
    // then the tasks are ordered correctly
    assertEquals(3, tasks.size());
    // first the numeric valued task (since it is treated like null-valued)
    assertEquals(instance1.getId(), tasks.get(0).getProcessInstanceId());
    // then the others in alphabetical order
    assertEquals(instance2.getId(), tasks.get(1).getProcessInstanceId());
    assertEquals(instance3.getId(), tasks.get(2).getProcessInstanceId());
}

4. ProcessInstanceModificationTest#FAILING_testCancelCallActivityInstance()

View license
@Deployment(resources = { CALL_ACTIVITY_PARENT_PROCESS, CALL_ACTIVITY_CHILD_PROCESS })
public void FAILING_testCancelCallActivityInstance() {
    // given
    ProcessInstance parentprocess = runtimeService.startProcessInstanceByKey("parentprocess");
    ProcessInstance subProcess = runtimeService.createProcessInstanceQuery().processDefinitionKey("subprocess").singleResult();
    ActivityInstance subProcessActivityInst = runtimeService.getActivityInstance(subProcess.getId());
    // when
    runtimeService.createProcessInstanceModification(subProcess.getId()).startBeforeActivity("childEnd", subProcess.getId()).cancelActivityInstance(getInstanceIdForActivity(subProcessActivityInst, "innerTask")).execute();
    // then
    assertProcessEnded(parentprocess.getId());
}

5. ProcessInstanceQueryTest#testQueryBySuperProcessInstanceId()

View license
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/superProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/runtime/subProcess.bpmn20.xml" })
public void testQueryBySuperProcessInstanceId() {
    ProcessInstance superProcessInstance = runtimeService.startProcessInstanceByKey("subProcessQueryTest");
    ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().superProcessInstanceId(superProcessInstance.getId());
    ProcessInstance subProcessInstance = query.singleResult();
    assertNotNull(subProcessInstance);
    assertEquals(1, query.list().size());
    assertEquals(1, query.count());
}

6. ProcessInstanceQueryTest#testClashingValues()

View license
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testClashingValues() throws Exception {
    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("var", 1234L);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
    Map<String, Object> vars2 = new HashMap<String, Object>();
    vars2.put("var", 1234);
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars2);
    List<ProcessInstance> foundInstances = runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").variableValueEquals("var", 1234L).list();
    assertEquals(1, foundInstances.size());
    assertEquals(processInstance.getId(), foundInstances.get(0).getId());
    runtimeService.deleteProcessInstance(processInstance.getId(), "test");
    runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
}

7. CallActivityTest#testOrderProcessWithCallActivity()

View license
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/orderProcess.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/checkCreditProcess.bpmn20.xml" })
public void testOrderProcessWithCallActivity() {
    // After the process has started, the 'verify credit history' task should be active
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("orderProcess");
    TaskQuery taskQuery = taskService.createTaskQuery();
    Task verifyCreditTask = taskQuery.singleResult();
    assertEquals("Verify credit history", verifyCreditTask.getName());
    // Verify with Query API
    ProcessInstance subProcessInstance = runtimeService.createProcessInstanceQuery().superProcessInstanceId(pi.getId()).singleResult();
    assertNotNull(subProcessInstance);
    assertEquals(pi.getId(), runtimeService.createProcessInstanceQuery().subProcessInstanceId(subProcessInstance.getId()).singleResult().getId());
    // Completing the task with approval, will end the subprocess and continue the original process
    taskService.complete(verifyCreditTask.getId(), CollectionUtil.singletonMap("creditApproved", true));
    Task prepareAndShipTask = taskQuery.singleResult();
    assertEquals("Prepare and Ship", prepareAndShipTask.getName());
}

8. TaskQueryTest#testQueryByMultipleActivityInstanceIds()

View license
@Deployment(resources = { "org/camunda/bpm/engine/test/api/task/TaskQueryTest.testProcessDefinition.bpmn20.xml" })
public void testQueryByMultipleActivityInstanceIds() throws Exception {
    ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    String activityInstanceId1 = runtimeService.getActivityInstance(processInstance1.getId()).getChildActivityInstances()[0].getId();
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    String activityInstanceId2 = runtimeService.getActivityInstance(processInstance2.getId()).getChildActivityInstances()[0].getId();
    List<Task> result1 = taskService.createTaskQuery().activityInstanceIdIn(activityInstanceId1).list();
    assertEquals(1, result1.size());
    assertEquals(processInstance1.getId(), result1.get(0).getProcessInstanceId());
    List<Task> result2 = taskService.createTaskQuery().activityInstanceIdIn(activityInstanceId2).list();
    assertEquals(1, result2.size());
    assertEquals(processInstance2.getId(), result2.get(0).getProcessInstanceId());
    assertEquals(2, taskService.createTaskQuery().activityInstanceIdIn(activityInstanceId1, activityInstanceId2).list().size());
}

9. CallActivityDelegateMappingTest#testCallSubProcessWithDelegatedVariableMappingAndAsyncServiceTask()

View license
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivityDelegateMappingTest.testCallSubProcessWithDelegatedVariableMappingAndAsyncServiceTask.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/simpleSubProcessWithAsyncService.bpmn20.xml" })
public void testCallSubProcessWithDelegatedVariableMappingAndAsyncServiceTask() {
    //given starting process instance with call activity which has asyn service task
    ProcessInstance superProcInst = engineRule.getRuntimeService().startProcessInstanceByKey("callSimpleSubProcess");
    ProcessInstance subProcInst = engineRule.getRuntimeService().createProcessInstanceQuery().processDefinitionKey("simpleSubProcessWithAsyncService").singleResult();
    //then delegation variable mapping class should also been resolved
    //input mapping should be executed
    Object inVar = engineRule.getRuntimeService().getVariable(subProcInst.getId(), "TestInputVar");
    assertEquals("inValue", inVar);
    //and after finish call activity the ouput mapping is executed
    testHelper.executeAvailableJobs();
    Object outputVar = engineRule.getRuntimeService().getVariable(superProcInst.getId(), "TestOutputVar");
    assertEquals("outValue", outputVar);
}

10. HistoricDecisionInstanceTest#testQueryByDecisionInstanceId()

View license
@Deployment(resources = { DECISION_PROCESS, DECISION_SINGLE_OUTPUT_DMN })
public void testQueryByDecisionInstanceId() {
    ProcessInstance pi1 = startProcessInstanceAndEvaluateDecision();
    ProcessInstance pi2 = startProcessInstanceAndEvaluateDecision();
    String decisionInstanceId1 = historyService.createHistoricDecisionInstanceQuery().processInstanceId(pi1.getId()).singleResult().getId();
    String decisionInstanceId2 = historyService.createHistoricDecisionInstanceQuery().processInstanceId(pi2.getId()).singleResult().getId();
    HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();
    assertThat(query.decisionInstanceId(decisionInstanceId1).count(), is(1L));
    assertThat(query.decisionInstanceId(decisionInstanceId2).count(), is(1L));
    assertThat(query.decisionInstanceId("unknown").count(), is(0L));
}

11. HistoricDecisionInstanceTest#testQueryByDecisionInstanceIds()

View license
@Deployment(resources = { DECISION_PROCESS, DECISION_SINGLE_OUTPUT_DMN })
public void testQueryByDecisionInstanceIds() {
    ProcessInstance pi1 = startProcessInstanceAndEvaluateDecision();
    ProcessInstance pi2 = startProcessInstanceAndEvaluateDecision();
    String decisionInstanceId1 = historyService.createHistoricDecisionInstanceQuery().processInstanceId(pi1.getId()).singleResult().getId();
    String decisionInstanceId2 = historyService.createHistoricDecisionInstanceQuery().processInstanceId(pi2.getId()).singleResult().getId();
    HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();
    assertThat(query.decisionInstanceIdIn(decisionInstanceId1).count(), is(1L));
    assertThat(query.decisionInstanceIdIn(decisionInstanceId2).count(), is(1L));
    assertThat(query.decisionInstanceIdIn(decisionInstanceId1, decisionInstanceId2).count(), is(2L));
}

12. HistoricTaskInstanceTest#testHistoricTaskInstanceQueryByActivityInstanceIds()

View license
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricTaskInstanceTest.testHistoricTaskInstance.bpmn20.xml" })
public void testHistoricTaskInstanceQueryByActivityInstanceIds() throws Exception {
    ProcessInstance pi1 = runtimeService.startProcessInstanceByKey("HistoricTaskInstanceTest");
    ProcessInstance pi2 = runtimeService.startProcessInstanceByKey("HistoricTaskInstanceTest");
    String activityInstanceId1 = historyService.createHistoricActivityInstanceQuery().processInstanceId(pi1.getId()).activityId("task").singleResult().getId();
    String activityInstanceId2 = historyService.createHistoricActivityInstanceQuery().processInstanceId(pi2.getId()).activityId("task").singleResult().getId();
    HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery().activityInstanceIdIn(activityInstanceId1, activityInstanceId2);
    assertEquals(2, query.count());
    assertEquals(2, query.list().size());
}

13. HistoricVariableInstanceTest#testOrderProcessWithCallActivity()

View license
@Deployment(resources = { "org/camunda/bpm/engine/test/history/orderProcess.bpmn20.xml", "org/camunda/bpm/engine/test/history/checkCreditProcess.bpmn20.xml" })
public void testOrderProcessWithCallActivity() {
    // After the process has started, the 'verify credit history' task should be active
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("orderProcess");
    TaskQuery taskQuery = taskService.createTaskQuery();
    Task verifyCreditTask = taskQuery.singleResult();
    assertEquals("Verify credit history", verifyCreditTask.getName());
    // Verify with Query API
    ProcessInstance subProcessInstance = runtimeService.createProcessInstanceQuery().superProcessInstanceId(pi.getId()).singleResult();
    assertNotNull(subProcessInstance);
    assertEquals(pi.getId(), runtimeService.createProcessInstanceQuery().subProcessInstanceId(subProcessInstance.getId()).singleResult().getId());
    // Completing the task with approval, will end the subprocess and continue the original process
    taskService.complete(verifyCreditTask.getId(), CollectionUtil.singletonMap("creditApproved", true));
    Task prepareAndShipTask = taskQuery.singleResult();
    assertEquals("Prepare and Ship", prepareAndShipTask.getName());
}

14. HistoricVariableInstanceTest#testHistoricVariableInstanceQueryByInvalidProcessIdIn()

View license
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricVariableInstanceTest.testParallel.bpmn20.xml" })
public void testHistoricVariableInstanceQueryByInvalidProcessIdIn() {
    // given
    Map<String, Object> vars = new HashMap<String, Object>();
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProc", vars);
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("myProc", vars);
    // check existing variables for task ID
    try {
        historyService.createHistoricVariableInstanceQuery().processInstanceIdIn(processInstance.getProcessInstanceId(), null);
        fail("Search by process instance ID was finished");
    } catch (ProcessEngineException e) {
    }
}

15. HistoricVariableInstanceTest#testHistoricVariableInstanceQueryByExecutionIds()

View license
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testHistoricVariableInstanceQueryByExecutionIds() {
    // given
    Map<String, Object> variables1 = new HashMap<String, Object>();
    variables1.put("stringVar", "test");
    variables1.put("myVar", "test123");
    ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables1);
    HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery().executionIdIn(processInstance1.getId());
    assertEquals(2, query.count());
    List<HistoricVariableInstance> variableInstances = query.list();
    assertEquals(2, variableInstances.size());
    for (HistoricVariableInstance variableInstance : variableInstances) {
        assertEquals(processInstance1.getId(), variableInstance.getExecutionId());
    }
    Map<String, Object> variables2 = new HashMap<String, Object>();
    variables2.put("myVar", "test123");
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables2);
    query = historyService.createHistoricVariableInstanceQuery().executionIdIn(processInstance1.getId(), processInstance2.getId());
    assertEquals(3, query.list().size());
    assertEquals(3, query.count());
}

16. HistoricVariableInstanceTest#testQueryByActivityInstanceIdIn()

View license
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testQueryByActivityInstanceIdIn() {
    // given
    Map<String, Object> variables1 = new HashMap<String, Object>();
    variables1.put("stringVar", "test");
    variables1.put("myVar", "test123");
    ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables1);
    HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery();
    query.activityInstanceIdIn(processInstance1.getId());
    assertEquals(2, query.list().size());
    assertEquals(2, query.count());
    Map<String, Object> variables2 = new HashMap<String, Object>();
    variables2.put("myVar", "test123");
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables2);
    query.activityInstanceIdIn(processInstance1.getId(), processInstance2.getId());
    assertEquals(3, query.list().size());
    assertEquals(3, query.count());
}

17. SignalEventTest#testSignalCatchBoundaryWithVariables()

View license
@Test
@Deployment(resources = { "org/camunda/bpm/engine/cdi/test/bpmn/SignalEventTests.catchAlertSignalBoundaryWithReceiveTask.bpmn20.xml", "org/camunda/bpm/engine/cdi/test/bpmn/SignalEventTests.throwAlertSignalWithDelegate.bpmn20.xml" })
public void testSignalCatchBoundaryWithVariables() {
    HashMap<String, Object> variables1 = new HashMap<String, Object>();
    variables1.put("processName", "catchSignal");
    ProcessInstance piCatchSignal = runtimeService.startProcessInstanceByKey("catchSignal", variables1);
    HashMap<String, Object> variables2 = new HashMap<String, Object>();
    variables2.put("processName", "throwSignal");
    variables2.put("signalProcessInstanceId", piCatchSignal.getProcessInstanceId());
    ProcessInstance piThrowSignal = runtimeService.startProcessInstanceByKey("throwSignal", variables2);
    assertEquals(1, runtimeService.createExecutionQuery().processInstanceId(piCatchSignal.getProcessInstanceId()).activityId("receiveTask").count());
    assertEquals(1, runtimeService.createExecutionQuery().processInstanceId(piThrowSignal.getProcessInstanceId()).activityId("receiveTask").count());
    assertEquals("catchSignal-visited (was catchSignal)", runtimeService.getVariable(piCatchSignal.getId(), "processName"));
    assertEquals("throwSignal-visited (was throwSignal)", runtimeService.getVariable(piThrowSignal.getId(), "processName"));
    // clean up
    runtimeService.signal(piCatchSignal.getId());
    runtimeService.signal(piThrowSignal.getId());
}

18. CallActivityContextSwitchTest#testMainSyncCalledSync()

View license
@Test
@OperateOnDeployment("mainDeployment")
public void testMainSyncCalledSync() {
    Map<String, Object> processVariables = new HashMap<String, Object>();
    processVariables.put("calledElement", "calledProcessSync");
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("mainProcessSync", processVariables);
    Assert.assertEquals(true, runtimeService.getVariable(pi.getId(), DelegateBefore.class.getName()));
    ProcessInstance calledPi = runtimeService.createProcessInstanceQuery().processDefinitionKey("calledProcessSync").singleResult();
    Assert.assertEquals(true, runtimeService.getVariable(calledPi.getId(), "calledDelegate"));
    taskService.complete(taskService.createTaskQuery().processInstanceId(calledPi.getId()).singleResult().getId());
    Assert.assertEquals(true, runtimeService.getVariable(pi.getId(), DelegateAfter.class.getName()));
    taskService.complete(taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult().getId());
    Assert.assertNull(runtimeService.createProcessInstanceQuery().processDefinitionId(pi.getId()).singleResult());
    Assert.assertNull(runtimeService.createProcessInstanceQuery().processDefinitionId(calledPi.getId()).singleResult());
}

19. AsyncIntermediateThrowSignalEventTest#testAsyncSignalEvent()

View license
@Test
public void testAsyncSignalEvent() throws InterruptedException {
    ProcessInstance piCatchSignal = runtimeService.startProcessInstanceByKey("catchSignal");
    ProcessInstance piThrowSignal = runtimeService.startProcessInstanceByKey("throwSignal");
    waitForJobExecutorToProcessAllJobs();
    assertEquals(1, runtimeService.createExecutionQuery().processInstanceId(piCatchSignal.getProcessInstanceId()).activityId("receiveTask").count());
    assertEquals(1, runtimeService.createExecutionQuery().processInstanceId(piThrowSignal.getProcessInstanceId()).activityId("receiveTask").count());
    // clean up
    runtimeService.signal(piCatchSignal.getId());
    runtimeService.signal(piThrowSignal.getId());
    assertEquals(0, runtimeService.createExecutionQuery().processInstanceId(piCatchSignal.getProcessInstanceId()).count());
    assertEquals(0, runtimeService.createExecutionQuery().processInstanceId(piThrowSignal.getProcessInstanceId()).count());
}

20. IndependentJobExecutionTest#testDeploymentAwareJobAcquisition()

View license
@OperateOnDeployment("pa1")
@Test
public void testDeploymentAwareJobAcquisition() {
    JobExecutor jobExecutor1 = engine1Configuration.getJobExecutor();
    ProcessInstance instance1 = engine1.getRuntimeService().startProcessInstanceByKey("archive1Process");
    ProcessInstance instance2 = processEngine.getRuntimeService().startProcessInstanceByKey("archive2Process");
    Job job1 = managementService.createJobQuery().processInstanceId(instance1.getId()).singleResult();
    Job job2 = managementService.createJobQuery().processInstanceId(instance2.getId()).singleResult();
    // the deployment aware configuration should only return the jobs of the registered deployments
    CommandExecutor commandExecutor = engine1Configuration.getCommandExecutorTxRequired();
    AcquiredJobs acquiredJobs = commandExecutor.execute(new AcquireJobsCmd(jobExecutor1));
    Assert.assertEquals(1, acquiredJobs.size());
    Assert.assertTrue(acquiredJobs.contains(job1.getId()));
    Assert.assertFalse(acquiredJobs.contains(job2.getId()));
}

21. IndependentJobExecutionTest#testDeploymentUnawareJobAcquisition()

View license
@OperateOnDeployment("pa1")
@Test
public void testDeploymentUnawareJobAcquisition() {
    JobExecutor defaultJobExecutor = processEngineConfiguration.getJobExecutor();
    ProcessInstance instance1 = engine1.getRuntimeService().startProcessInstanceByKey("archive1Process");
    ProcessInstance instance2 = processEngine.getRuntimeService().startProcessInstanceByKey("archive2Process");
    Job job1 = managementService.createJobQuery().processInstanceId(instance1.getId()).singleResult();
    Job job2 = managementService.createJobQuery().processInstanceId(instance2.getId()).singleResult();
    // the deployment unaware configuration should return both jobs
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    processEngineConfiguration.setJobExecutorDeploymentAware(false);
    try {
        AcquiredJobs acquiredJobs = commandExecutor.execute(new AcquireJobsCmd(defaultJobExecutor));
        Assert.assertEquals(2, acquiredJobs.size());
        Assert.assertTrue(acquiredJobs.contains(job1.getId()));
        Assert.assertTrue(acquiredJobs.contains(job2.getId()));
    } finally {
        processEngineConfiguration.setJobExecutorDeploymentAware(true);
    }
}

22. MigrationProcessInstanceTest#testMigrateWithIdVarargsArray()

View license
@Test
public void testMigrateWithIdVarargsArray() {
    ProcessDefinition sourceDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceDefinition.getId(), targetDefinition.getId()).mapEqualActivities().build();
    ProcessInstance processInstance1 = runtimeService.startProcessInstanceById(sourceDefinition.getId());
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceById(sourceDefinition.getId());
    // when
    runtimeService.newMigration(migrationPlan).processInstanceIds(processInstance1.getId(), processInstance2.getId()).execute();
    // then
    Assert.assertEquals(2, runtimeService.createProcessInstanceQuery().processDefinitionId(targetDefinition.getId()).count());
}

23. MigrationProcessInstanceTest#testProcessInstanceIdsAndQuery()

View license
@Test
public void testProcessInstanceIdsAndQuery() {
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
    ProcessInstance processInstance1 = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
    ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance2.getId());
    ProcessInstanceQuery targetProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(targetProcessDefinition.getId());
    assertEquals(0, targetProcessInstanceQuery.count());
    runtimeService.newMigration(migrationPlan).processInstanceIds(Collections.singletonList(processInstance1.getId())).processInstanceQuery(sourceProcessInstanceQuery).execute();
    assertEquals(2, targetProcessInstanceQuery.count());
}

24. MigrationProcessInstanceTest#testOverlappingProcessInstanceIdsAndQuery()

View license
@Test
public void testOverlappingProcessInstanceIdsAndQuery() {
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
    ProcessInstance processInstance1 = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
    ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.getId());
    ProcessInstanceQuery targetProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(targetProcessDefinition.getId());
    assertEquals(0, targetProcessInstanceQuery.count());
    runtimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance1.getId(), processInstance2.getId())).processInstanceQuery(sourceProcessInstanceQuery).execute();
    assertEquals(2, targetProcessInstanceQuery.count());
}

25. ExecutionQueryTest#testQueryForExecutionsWithMessageEventSubscriptions()

View license
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/runtime/oneMessageCatchProcess.bpmn20.xml" })
public void testQueryForExecutionsWithMessageEventSubscriptions() {
    runtimeService.startProcessInstanceByKey("oneTaskProcess");
    runtimeService.startProcessInstanceByKey("oneTaskProcess");
    ProcessInstance instance1 = runtimeService.startProcessInstanceByKey("oneMessageCatchProcess");
    ProcessInstance instance2 = runtimeService.startProcessInstanceByKey("oneMessageCatchProcess");
    List<Execution> executions = runtimeService.createExecutionQuery().messageEventSubscription().orderByProcessInstanceId().asc().list();
    assertEquals(2, executions.size());
    if (instance1.getId().compareTo(instance2.getId()) < 0) {
        assertEquals(instance1.getId(), executions.get(0).getProcessInstanceId());
        assertEquals(instance2.getId(), executions.get(1).getProcessInstanceId());
    } else {
        assertEquals(instance2.getId(), executions.get(0).getProcessInstanceId());
        assertEquals(instance1.getId(), executions.get(1).getProcessInstanceId());
    }
}

26. IncidentQueryTest#testQueryByCauseIncidentId()

View license
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/IncidentQueryTest.testQueryByCauseIncidentId.bpmn" })
public void testQueryByCauseIncidentId() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callFailingProcess");
    testHelper.executeAvailableJobs();
    ProcessInstance subProcessInstance = runtimeService.createProcessInstanceQuery().superProcessInstanceId(processInstance.getId()).singleResult();
    assertNotNull(subProcessInstance);
    Incident causeIncident = runtimeService.createIncidentQuery().processInstanceId(subProcessInstance.getId()).singleResult();
    assertNotNull(causeIncident);
    IncidentQuery query = runtimeService.createIncidentQuery().causeIncidentId(causeIncident.getId());
    assertEquals(2, query.count());
    List<Incident> incidents = query.list();
    assertFalse(incidents.isEmpty());
    assertEquals(2, incidents.size());
}

27. MessageCorrelationTest#testMessageCorrelateAllResultListWithResultTypeExecution()

View license
@Deployment(resources = "org/camunda/bpm/engine/test/api/runtime/MessageCorrelationTest.testCatchingMessageEventCorrelation.bpmn20.xml")
public void testMessageCorrelateAllResultListWithResultTypeExecution() {
    //given
    ProcessInstance procInstance1 = runtimeService.startProcessInstanceByKey("process");
    ProcessInstance procInstance2 = runtimeService.startProcessInstanceByKey("process");
    //when correlated all with result
    List<MessageCorrelationResult> resultList = runtimeService.createMessageCorrelation("newInvoiceMessage").correlateAllWithResult();
    assertEquals(2, resultList.size());
    //then result should contains executions on which messages was correlated
    for (MessageCorrelationResult result : resultList) {
        assertNotNull(result);
        assertEquals(MessageCorrelationResultType.Execution, result.getResultType());
        assertTrue(procInstance1.getId().equalsIgnoreCase(result.getExecution().getProcessInstanceId()) || procInstance2.getId().equalsIgnoreCase(result.getExecution().getProcessInstanceId()));
        ExecutionEntity entity = (ExecutionEntity) result.getExecution();
        assertEquals("messageCatch", entity.getActivityId());
    }
}

28. BatchMigrationTest#testMigrateWithVarargsArray()

View license
@Test
public void testMigrateWithVarargsArray() {
    ProcessDefinition sourceDefinition = migrationRule.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    ProcessDefinition targetDefinition = migrationRule.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceDefinition.getId(), targetDefinition.getId()).mapEqualActivities().build();
    ProcessInstance processInstance1 = runtimeService.startProcessInstanceById(sourceDefinition.getId());
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceById(sourceDefinition.getId());
    // when
    Batch batch = runtimeService.newMigration(migrationPlan).processInstanceIds(processInstance1.getId(), processInstance2.getId()).executeAsync();
    helper.executeSeedJob(batch);
    helper.executeMigrationJobs(batch);
    helper.executeMonitorJob(batch);
    // then
    Assert.assertEquals(2, runtimeService.createProcessInstanceQuery().processDefinitionId(targetDefinition.getId()).count());
}

29. MultiTenancyHistoricDetailFormPropertyQueryTest#setUp()

View license
@Override
protected void setUp() throws IOException {
    BpmnModelInstance oneTaskProcess = Bpmn.createExecutableProcess("testProcess").startEvent().userTask("userTask").camundaFormField().camundaId("myFormField").camundaType("string").camundaFormFieldDone().endEvent().done();
    deploymentForTenant(TENANT_ONE, oneTaskProcess);
    deploymentForTenant(TENANT_TWO, oneTaskProcess);
    ProcessInstance processInstanceOne = startProcessInstanceForTenant(TENANT_ONE);
    ProcessInstance processInstanceTwo = startProcessInstanceForTenant(TENANT_TWO);
    completeUserTask(processInstanceOne);
    completeUserTask(processInstanceTwo);
}

30. MultiTenancyHistoricDetailVariableUpdateQueryTest#setUp()

View license
@Override
protected void setUp() {
    BpmnModelInstance oneTaskProcess = Bpmn.createExecutableProcess("testProcess").startEvent().userTask().endEvent().done();
    deploymentForTenant(TENANT_ONE, oneTaskProcess);
    deploymentForTenant(TENANT_TWO, oneTaskProcess);
    ProcessInstance processInstanceOne = startProcessInstanceForTenant(TENANT_ONE, TENANT_ONE_VAR);
    ProcessInstance processInstanceTwo = startProcessInstanceForTenant(TENANT_TWO, TENANT_TWO_VAR);
    completeUserTask(processInstanceOne, TENANT_ONE_VAR + "_updated");
    completeUserTask(processInstanceTwo, TENANT_TWO_VAR + "_updated");
}

31. MultiTenancyHistoricTaskInstanceQueryTest#setUp()

View license
@Override
protected void setUp() {
    BpmnModelInstance oneTaskProcess = Bpmn.createExecutableProcess("testProcess").startEvent().userTask().endEvent().done();
    deploymentForTenant(TENANT_ONE, oneTaskProcess);
    deploymentForTenant(TENANT_TWO, oneTaskProcess);
    ProcessInstance processInstanceOne = startProcessInstanceForTenant(TENANT_ONE);
    ProcessInstance processInstanceTwo = startProcessInstanceForTenant(TENANT_TWO);
    completeUserTask(processInstanceOne);
    completeUserTask(processInstanceTwo);
}

32. TenantIdProviderTest#setsTenantId_SubProcessInstance()

View license
@Test
public void setsTenantId_SubProcessInstance() {
    String tenantId = TENANT_ID;
    SetValueOnSubProcessInstanceTenantIdProvider tenantIdProvider = new SetValueOnSubProcessInstanceTenantIdProvider(tenantId);
    TestTenantIdProvider.delegate = tenantIdProvider;
    testRule.deploy(Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY).startEvent().userTask().done(), Bpmn.createExecutableProcess("superProcess").startEvent().callActivity().calledElement(PROCESS_DEFINITION_KEY).done());
    // if a process instance is started
    engineRule.getRuntimeService().startProcessInstanceByKey("superProcess");
    // then the tenant id provider can set the tenant id to a value
    ProcessInstance subProcessInstance = engineRule.getRuntimeService().createProcessInstanceQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).singleResult();
    assertThat(subProcessInstance.getTenantId(), is(tenantId));
    // and the super process instance is not assigned a tenant id
    ProcessInstance superProcessInstance = engineRule.getRuntimeService().createProcessInstanceQuery().processDefinitionKey("superProcess").singleResult();
    assertThat(superProcessInstance.getTenantId(), is(nullValue()));
}

33. ExecutionQueryTest#testClashingValues()

View license
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testClashingValues() throws Exception {
    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("var", 1234L);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
    Map<String, Object> vars2 = new HashMap<String, Object>();
    vars2.put("var", 1234);
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars2);
    List<Execution> executions = runtimeService.createExecutionQuery().processDefinitionKey("oneTaskProcess").variableValueEquals("var", 1234L).list();
    assertEquals(1, executions.size());
    assertEquals(processInstance.getId(), executions.get(0).getProcessInstanceId());
    runtimeService.deleteProcessInstance(processInstance.getId(), "test");
    runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
}

34. ProcessDefinitionAuthorizationTest#testActivateProcessDefinitionByIdIncludingInstancesWithUpdateInstancePermissionOnProcessDefinition()

View license
public void testActivateProcessDefinitionByIdIncludingInstancesWithUpdateInstancePermissionOnProcessDefinition() {
    // given
    startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
    String processDefinitionId = selectProcessDefinitionByKey(ONE_TASK_PROCESS_KEY).getId();
    suspendProcessDefinitionById(processDefinitionId);
    createGrantAuthorization(PROCESS_DEFINITION, ONE_TASK_PROCESS_KEY, userId, UPDATE, UPDATE_INSTANCE);
    // when
    repositoryService.activateProcessDefinitionById(processDefinitionId, true, null);
    // then
    ProcessDefinition definition = selectProcessDefinitionByKey(ONE_TASK_PROCESS_KEY);
    assertFalse(definition.isSuspended());
    ProcessInstance instance = selectSingleProcessInstance();
    assertFalse(instance.isSuspended());
}

35. MigrationEventBasedGatewayTest#testMigrateGatewayWithSignalEventChangeId()

View license
@Test
public void testMigrateGatewayWithSignalEventChangeId() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.SIGNAL_EVENT_BASED_GW_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(EventBasedGatewayModels.SIGNAL_EVENT_BASED_GW_PROCESS).changeElementId("signalCatch", "newSignalCatch"));
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("eventBasedGateway", "eventBasedGateway").mapActivities("signalCatch", "newSignalCatch").build();
    // when
    ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
    // then
    testHelper.assertEventSubscriptionMigrated("signalCatch", "newSignalCatch", EventBasedGatewayModels.SIGNAL_NAME);
    rule.getRuntimeService().signalEventReceived(EventBasedGatewayModels.SIGNAL_NAME);
    testHelper.completeTask("afterSignalCatch");
    testHelper.assertProcessEnded(processInstance.getId());
}

36. ProcessDefinitionAuthorizationTest#testSuspendProcessDefinitionByKeyIncludingInstancesWithUpdatePermissionOnAnyProcessInstance()

View license
public void testSuspendProcessDefinitionByKeyIncludingInstancesWithUpdatePermissionOnAnyProcessInstance() {
    // given
    createGrantAuthorization(PROCESS_DEFINITION, ONE_TASK_PROCESS_KEY, userId, UPDATE);
    startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
    createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, UPDATE);
    // when
    repositoryService.suspendProcessDefinitionByKey(ONE_TASK_PROCESS_KEY, true, null);
    // then
    ProcessDefinition definition = selectProcessDefinitionByKey(ONE_TASK_PROCESS_KEY);
    assertTrue(definition.isSuspended());
    ProcessInstance instance = selectSingleProcessInstance();
    assertTrue(instance.isSuspended());
}

37. ProcessDefinitionAuthorizationTest#testSuspendProcessDefinitionByKeyIncludingInstancesWithUpdateInstancePermissionOnProcessDefinition()

View license
public void testSuspendProcessDefinitionByKeyIncludingInstancesWithUpdateInstancePermissionOnProcessDefinition() {
    // given
    createGrantAuthorization(PROCESS_DEFINITION, ONE_TASK_PROCESS_KEY, userId, UPDATE, UPDATE_INSTANCE);
    startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
    // when
    repositoryService.suspendProcessDefinitionByKey(ONE_TASK_PROCESS_KEY, true, null);
    // then
    ProcessDefinition definition = selectProcessDefinitionByKey(ONE_TASK_PROCESS_KEY);
    assertTrue(definition.isSuspended());
    ProcessInstance instance = selectSingleProcessInstance();
    assertTrue(instance.isSuspended());
}

38. ProcessDefinitionAuthorizationTest#testActivateProcessDefinitionByKeyIncludingInstancesWithUpdatePermissionOnAnyProcessInstance()

View license
public void testActivateProcessDefinitionByKeyIncludingInstancesWithUpdatePermissionOnAnyProcessInstance() {
    // given
    startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
    createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, UPDATE);
    suspendProcessDefinitionByKey(ONE_TASK_PROCESS_KEY);
    createGrantAuthorization(PROCESS_DEFINITION, ONE_TASK_PROCESS_KEY, userId, UPDATE);
    // when
    repositoryService.activateProcessDefinitionByKey(ONE_TASK_PROCESS_KEY, true, null);
    // then
    ProcessDefinition definition = selectProcessDefinitionByKey(ONE_TASK_PROCESS_KEY);
    assertFalse(definition.isSuspended());
    ProcessInstance instance = selectSingleProcessInstance();
    assertFalse(instance.isSuspended());
}

39. ProcessDefinitionAuthorizationTest#testActivateProcessDefinitionByKeyIncludingInstancesWithUpdateInstancePermissionOnProcessDefinition()

View license
public void testActivateProcessDefinitionByKeyIncludingInstancesWithUpdateInstancePermissionOnProcessDefinition() {
    // given
    startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
    suspendProcessDefinitionByKey(ONE_TASK_PROCESS_KEY);
    createGrantAuthorization(PROCESS_DEFINITION, ONE_TASK_PROCESS_KEY, userId, UPDATE, UPDATE_INSTANCE);
    // when
    repositoryService.activateProcessDefinitionByKey(ONE_TASK_PROCESS_KEY, true, null);
    // then
    ProcessDefinition definition = selectProcessDefinitionByKey(ONE_TASK_PROCESS_KEY);
    assertFalse(definition.isSuspended());
    ProcessInstance instance = selectSingleProcessInstance();
    assertFalse(instance.isSuspended());
}

40. ProcessInstanceAuthorizationTest#testSimpleQueryWithReadPermissionOnProcessInstance()

View license
public void testSimpleQueryWithReadPermissionOnProcessInstance() {
    // given
    String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, READ);
    // when
    ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
    // then
    verifyQueryResults(query, 1);
    ProcessInstance instance = query.singleResult();
    assertNotNull(instance);
    assertEquals(processInstanceId, instance.getId());
}

41. ProcessInstanceAuthorizationTest#testSimpleQueryWithReadPermissionOnAnyProcessInstance()

View license
public void testSimpleQueryWithReadPermissionOnAnyProcessInstance() {
    // given
    String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, READ);
    // when
    ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
    // then
    verifyQueryResults(query, 1);
    ProcessInstance instance = query.singleResult();
    assertNotNull(instance);
    assertEquals(processInstanceId, instance.getId());
}

42. ProcessInstanceAuthorizationTest#testSimpleQueryWithReadInstancesPermissionOnOneTaskProcess()

View license
public void testSimpleQueryWithReadInstancesPermissionOnOneTaskProcess() {
    // given
    String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_INSTANCE);
    // when
    ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
    // then
    verifyQueryResults(query, 1);
    ProcessInstance instance = query.singleResult();
    assertNotNull(instance);
    assertEquals(processInstanceId, instance.getId());
}

43. ProcessInstanceAuthorizationTest#testSimpleQueryWithReadInstancesPermissionOnAnyProcessDefinition()

View license
public void testSimpleQueryWithReadInstancesPermissionOnAnyProcessDefinition() {
    // given
    String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_INSTANCE);
    // when
    ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
    // then
    verifyQueryResults(query, 1);
    ProcessInstance instance = query.singleResult();
    assertNotNull(instance);
    assertEquals(processInstanceId, instance.getId());
}

44. ProcessInstanceAuthorizationTest#testQueryWithReadPermissionOnProcessInstance()

View license
public void testQueryWithReadPermissionOnProcessInstance() {
    // given
    startProcessInstanceByKey(PROCESS_KEY);
    startProcessInstanceByKey(PROCESS_KEY);
    String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
    startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
    startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
    startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
    startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
    createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, READ);
    // when
    ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
    // then
    verifyQueryResults(query, 1);
    ProcessInstance instance = query.singleResult();
    assertNotNull(instance);
    assertEquals(processInstanceId, instance.getId());
}

45. ProcessInstanceAuthorizationTest#testSuspendProcessInstanceByIdWithUpdatePermissionOnProcessInstance()

View license
public void testSuspendProcessInstanceByIdWithUpdatePermissionOnProcessInstance() {
    // given
    String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, UPDATE);
    // when
    runtimeService.suspendProcessInstanceById(processInstanceId);
    // then
    ProcessInstance instance = selectSingleProcessInstance();
    assertTrue(instance.isSuspended());
}

46. ProcessInstanceAuthorizationTest#testSuspendProcessInstanceByIdWithUpdatePermissionOnAnyProcessInstance()

View license
public void testSuspendProcessInstanceByIdWithUpdatePermissionOnAnyProcessInstance() {
    // given
    String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, UPDATE);
    // when
    runtimeService.suspendProcessInstanceById(processInstanceId);
    // then
    ProcessInstance instance = selectSingleProcessInstance();
    assertTrue(instance.isSuspended());
}

47. ProcessInstanceAuthorizationTest#testSuspendProcessInstanceByIdWithUpdateInstancesPermissionOnProcessDefinition()

View license
public void testSuspendProcessInstanceByIdWithUpdateInstancesPermissionOnProcessDefinition() {
    // given
    String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, UPDATE_INSTANCE);
    // when
    runtimeService.suspendProcessInstanceById(processInstanceId);
    // then
    ProcessInstance instance = selectSingleProcessInstance();
    assertTrue(instance.isSuspended());
}

48. ProcessInstanceAuthorizationTest#testSuspendProcessInstanceById()

View license
public void testSuspendProcessInstanceById() {
    // given
    String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, UPDATE);
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, UPDATE_INSTANCE);
    // when
    runtimeService.suspendProcessInstanceById(processInstanceId);
    // then
    ProcessInstance instance = selectSingleProcessInstance();
    assertTrue(instance.isSuspended());
}

49. ProcessInstanceAuthorizationTest#testActivateProcessInstanceByIdWithUpdatePermissionOnProcessInstance()

View license
public void testActivateProcessInstanceByIdWithUpdatePermissionOnProcessInstance() {
    // given
    String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
    suspendProcessInstanceById(processInstanceId);
    createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, UPDATE);
    // when
    runtimeService.activateProcessInstanceById(processInstanceId);
    // then
    ProcessInstance instance = selectSingleProcessInstance();
    assertFalse(instance.isSuspended());
}

50. ProcessInstanceAuthorizationTest#testActivateProcessInstanceByIdWithUpdatePermissionOnAnyProcessInstance()

View license
public void testActivateProcessInstanceByIdWithUpdatePermissionOnAnyProcessInstance() {
    // given
    String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
    suspendProcessInstanceById(processInstanceId);
    createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, UPDATE);
    // when
    runtimeService.activateProcessInstanceById(processInstanceId);
    // then
    ProcessInstance instance = selectSingleProcessInstance();
    assertFalse(instance.isSuspended());
}

51. ProcessInstanceAuthorizationTest#testActivateProcessInstanceByIdWithUpdateInstancesPermissionOnProcessDefinition()

View license
public void testActivateProcessInstanceByIdWithUpdateInstancesPermissionOnProcessDefinition() {
    // given
    String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
    suspendProcessInstanceById(processInstanceId);
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, UPDATE_INSTANCE);
    // when
    runtimeService.activateProcessInstanceById(processInstanceId);
    // then
    ProcessInstance instance = selectSingleProcessInstance();
    assertFalse(instance.isSuspended());
}

52. ProcessInstanceAuthorizationTest#testActivateProcessInstanceById()

View license
public void testActivateProcessInstanceById() {
    // given
    String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
    suspendProcessInstanceById(processInstanceId);
    createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, UPDATE);
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, UPDATE_INSTANCE);
    // when
    runtimeService.activateProcessInstanceById(processInstanceId);
    // then
    ProcessInstance instance = selectSingleProcessInstance();
    assertFalse(instance.isSuspended());
}

53. ProcessInstanceAuthorizationTest#testSuspendProcessInstanceByProcessDefinitionIdWithUpdatePermissionOnProcessInstance()

View license
public void testSuspendProcessInstanceByProcessDefinitionIdWithUpdatePermissionOnProcessInstance() {
    // given
    ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY);
    String processInstanceId = instance.getId();
    String processDefinitionId = instance.getProcessDefinitionId();
    createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, UPDATE);
    try {
        // when
        runtimeService.suspendProcessInstanceByProcessDefinitionId(processDefinitionId);
        fail("Exception expected: It should not be posssible to suspend a process instance.");
    } catch (AuthorizationException e) {
        String message = e.getMessage();
        assertTextPresent(userId, message);
        assertTextPresent(UPDATE_INSTANCE.getName(), message);
        assertTextPresent(PROCESS_KEY, message);
        assertTextPresent(PROCESS_DEFINITION.resourceName(), message);
    }
}

54. ProcessInstanceAuthorizationTest#testSuspendProcessInstanceByProcessDefinitionIdWithUpdatePermissionOnAnyProcessInstance()

View license
public void testSuspendProcessInstanceByProcessDefinitionIdWithUpdatePermissionOnAnyProcessInstance() {
    // given
    ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY);
    String processDefinitionId = instance.getProcessDefinitionId();
    createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, UPDATE);
    // when
    runtimeService.suspendProcessInstanceByProcessDefinitionId(processDefinitionId);
    // then
    instance = selectSingleProcessInstance();
    assertTrue(instance.isSuspended());
}

55. ProcessInstanceAuthorizationTest#testSuspendProcessInstanceByProcessDefinitionIdWithUpdateInstancesPermissionOnProcessDefinition()

View license
public void testSuspendProcessInstanceByProcessDefinitionIdWithUpdateInstancesPermissionOnProcessDefinition() {
    // given
    ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY);
    String processDefinitionId = instance.getProcessDefinitionId();
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, UPDATE_INSTANCE);
    // when
    runtimeService.suspendProcessInstanceByProcessDefinitionId(processDefinitionId);
    // then
    instance = selectSingleProcessInstance();
    assertTrue(instance.isSuspended());
}

56. ProcessInstanceAuthorizationTest#testSuspendProcessInstanceByProcessDefinitionId()

View license
public void testSuspendProcessInstanceByProcessDefinitionId() {
    // given
    ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY);
    String processInstanceId = instance.getId();
    String processDefinitionId = instance.getProcessDefinitionId();
    createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, UPDATE);
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, UPDATE_INSTANCE);
    // when
    runtimeService.suspendProcessInstanceByProcessDefinitionId(processDefinitionId);
    // then
    instance = selectSingleProcessInstance();
    assertTrue(instance.isSuspended());
}

57. ProcessInstanceAuthorizationTest#testActivateProcessInstanceByProcessDefinitionIdWithoutAuthorization()

View license
// activate process instance by process definition id /////////////////////////////
public void testActivateProcessInstanceByProcessDefinitionIdWithoutAuthorization() {
    // given
    ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY);
    String processInstanceId = instance.getId();
    String processDefinitionId = instance.getProcessDefinitionId();
    suspendProcessInstanceById(processInstanceId);
    try {
        // when
        runtimeService.activateProcessInstanceByProcessDefinitionId(processDefinitionId);
        fail("Exception expected: It should not be posssible to suspend a process instance.");
    } catch (AuthorizationException e) {
        String message = e.getMessage();
        assertTextPresent(userId, message);
        assertTextPresent(UPDATE_INSTANCE.getName(), message);
        assertTextPresent(PROCESS_KEY, message);
        assertTextPresent(PROCESS_DEFINITION.resourceName(), message);
    }
}

58. ProcessInstanceAuthorizationTest#testActivateProcessInstanceByProcessDefinitionIdWithUpdatePermissionOnProcessInstance()

View license
public void testActivateProcessInstanceByProcessDefinitionIdWithUpdatePermissionOnProcessInstance() {
    // given
    ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY);
    String processInstanceId = instance.getId();
    String processDefinitionId = instance.getProcessDefinitionId();
    suspendProcessInstanceById(processInstanceId);
    createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, UPDATE);
    try {
        // when
        runtimeService.activateProcessInstanceByProcessDefinitionId(processDefinitionId);
        fail("Exception expected: It should not be posssible to suspend a process instance.");
    } catch (AuthorizationException e) {
        String message = e.getMessage();
        assertTextPresent(userId, message);
        assertTextPresent(UPDATE_INSTANCE.getName(), message);
        assertTextPresent(PROCESS_KEY, message);
        assertTextPresent(PROCESS_DEFINITION.resourceName(), message);
    }
}

59. ProcessInstanceAuthorizationTest#testActivateProcessInstanceByProcessDefinitionIdWithUpdatePermissionOnAnyProcessInstance()

View license
public void testActivateProcessInstanceByProcessDefinitionIdWithUpdatePermissionOnAnyProcessInstance() {
    // given
    ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY);
    String processInstanceId = instance.getId();
    String processDefinitionId = instance.getProcessDefinitionId();
    suspendProcessInstanceById(processInstanceId);
    createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, UPDATE);
    // when
    runtimeService.activateProcessInstanceByProcessDefinitionId(processDefinitionId);
    // then
    instance = selectSingleProcessInstance();
    assertFalse(instance.isSuspended());
}

60. ProcessInstanceAuthorizationTest#testActivateProcessInstanceByProcessDefinitionIdWithUpdateInstancesPermissionOnProcessDefinition()

View license
public void testActivateProcessInstanceByProcessDefinitionIdWithUpdateInstancesPermissionOnProcessDefinition() {
    // given
    ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY);
    String processInstanceId = instance.getId();
    String processDefinitionId = instance.getProcessDefinitionId();
    suspendProcessInstanceById(processInstanceId);
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, UPDATE_INSTANCE);
    // when
    runtimeService.activateProcessInstanceByProcessDefinitionId(processDefinitionId);
    // then
    instance = selectSingleProcessInstance();
    assertFalse(instance.isSuspended());
}

61. ProcessInstanceAuthorizationTest#testActivateProcessInstanceByProcessDefinitionId()

View license
public void testActivateProcessInstanceByProcessDefinitionId() {
    // given
    ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY);
    String processInstanceId = instance.getId();
    String processDefinitionId = instance.getProcessDefinitionId();
    suspendProcessInstanceById(processInstanceId);
    createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, UPDATE);
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, UPDATE_INSTANCE);
    // when
    runtimeService.activateProcessInstanceByProcessDefinitionId(processDefinitionId);
    // then
    instance = selectSingleProcessInstance();
    assertFalse(instance.isSuspended());
}

62. ProcessInstanceAuthorizationTest#testSuspendProcessInstanceByProcessDefinitionKeyWithUpdatePermissionOnProcessInstance()

View license
public void testSuspendProcessInstanceByProcessDefinitionKeyWithUpdatePermissionOnProcessInstance() {
    // given
    ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY);
    String processInstanceId = instance.getId();
    createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, UPDATE);
    try {
        // when
        runtimeService.suspendProcessInstanceByProcessDefinitionKey(PROCESS_KEY);
        fail("Exception expected: It should not be posssible to suspend a process instance.");
    } catch (AuthorizationException e) {
        String message = e.getMessage();
        assertTextPresent(userId, message);
        assertTextPresent(UPDATE_INSTANCE.getName(), message);
        assertTextPresent(PROCESS_KEY, message);
        assertTextPresent(PROCESS_DEFINITION.resourceName(), message);
    }
}

63. ProcessInstanceAuthorizationTest#testSuspendProcessInstanceByProcessDefinitionKeyWithUpdatePermissionOnAnyProcessInstance()

View license
public void testSuspendProcessInstanceByProcessDefinitionKeyWithUpdatePermissionOnAnyProcessInstance() {
    // given
    startProcessInstanceByKey(PROCESS_KEY);
    createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, UPDATE);
    // when
    runtimeService.suspendProcessInstanceByProcessDefinitionKey(PROCESS_KEY);
    // then
    ProcessInstance instance = selectSingleProcessInstance();
    assertTrue(instance.isSuspended());
}

64. ProcessInstanceAuthorizationTest#testSuspendProcessInstanceByProcessDefinitionKeyWithUpdateInstancesPermissionOnProcessDefinition()

View license
public void testSuspendProcessInstanceByProcessDefinitionKeyWithUpdateInstancesPermissionOnProcessDefinition() {
    // given
    startProcessInstanceByKey(PROCESS_KEY);
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, UPDATE_INSTANCE);
    // when
    runtimeService.suspendProcessInstanceByProcessDefinitionKey(PROCESS_KEY);
    // then
    ProcessInstance instance = selectSingleProcessInstance();
    assertTrue(instance.isSuspended());
}

65. ProcessInstanceAuthorizationTest#testSuspendProcessInstanceByProcessDefinitionKey()

View license
public void testSuspendProcessInstanceByProcessDefinitionKey() {
    // given
    ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY);
    String processInstanceId = instance.getId();
    createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, UPDATE);
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, UPDATE_INSTANCE);
    // when
    runtimeService.suspendProcessInstanceByProcessDefinitionKey(PROCESS_KEY);
    // then
    instance = selectSingleProcessInstance();
    assertTrue(instance.isSuspended());
}

66. ProcessInstanceAuthorizationTest#testActivateProcessInstanceByProcessDefinitionKeyWithoutAuthorization()

View license
// activate process instance by process definition key /////////////////////////////
public void testActivateProcessInstanceByProcessDefinitionKeyWithoutAuthorization() {
    // given
    ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY);
    String processInstanceId = instance.getId();
    suspendProcessInstanceById(processInstanceId);
    try {
        // when
        runtimeService.activateProcessInstanceByProcessDefinitionKey(PROCESS_KEY);
        fail("Exception expected: It should not be posssible to suspend a process instance.");
    } catch (AuthorizationException e) {
        String message = e.getMessage();
        assertTextPresent(userId, message);
        assertTextPresent(UPDATE_INSTANCE.getName(), message);
        assertTextPresent(PROCESS_KEY, message);
        assertTextPresent(PROCESS_DEFINITION.resourceName(), message);
    }
}

67. ProcessInstanceAuthorizationTest#testActivateProcessInstanceByProcessDefinitionKeyWithUpdatePermissionOnProcessInstance()

View license
public void testActivateProcessInstanceByProcessDefinitionKeyWithUpdatePermissionOnProcessInstance() {
    // given
    ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY);
    String processInstanceId = instance.getId();
    suspendProcessInstanceById(processInstanceId);
    createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, UPDATE);
    try {
        // when
        runtimeService.activateProcessInstanceByProcessDefinitionKey(PROCESS_KEY);
        fail("Exception expected: It should not be posssible to suspend a process instance.");
    } catch (AuthorizationException e) {
        String message = e.getMessage();
        assertTextPresent(userId, message);
        assertTextPresent(UPDATE_INSTANCE.getName(), message);
        assertTextPresent(PROCESS_KEY, message);
        assertTextPresent(PROCESS_DEFINITION.resourceName(), message);
    }
}

68. ProcessInstanceAuthorizationTest#testActivateProcessInstanceByProcessDefinitionKeyWithUpdatePermissionOnAnyProcessInstance()

View license
public void testActivateProcessInstanceByProcessDefinitionKeyWithUpdatePermissionOnAnyProcessInstance() {
    // given
    ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY);
    String processInstanceId = instance.getId();
    suspendProcessInstanceById(processInstanceId);
    createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, UPDATE);
    // when
    runtimeService.activateProcessInstanceByProcessDefinitionKey(PROCESS_KEY);
    // then
    instance = selectSingleProcessInstance();
    assertFalse(instance.isSuspended());
}

69. ProcessInstanceAuthorizationTest#testActivateProcessInstanceByProcessDefinitionKeyWithUpdateInstancesPermissionOnProcessDefinition()

View license
public void testActivateProcessInstanceByProcessDefinitionKeyWithUpdateInstancesPermissionOnProcessDefinition() {
    // given
    ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY);
    String processInstanceId = instance.getId();
    suspendProcessInstanceById(processInstanceId);
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, UPDATE_INSTANCE);
    // when
    runtimeService.activateProcessInstanceByProcessDefinitionKey(PROCESS_KEY);
    // then
    instance = selectSingleProcessInstance();
    assertFalse(instance.isSuspended());
}

70. ProcessInstanceAuthorizationTest#testActivateProcessInstanceByProcessDefinitionKey()

View license
public void testActivateProcessInstanceByProcessDefinitionKey() {
    // given
    ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY);
    String processInstanceId = instance.getId();
    suspendProcessInstanceById(processInstanceId);
    createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, UPDATE);
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, UPDATE_INSTANCE);
    // when
    runtimeService.activateProcessInstanceByProcessDefinitionKey(PROCESS_KEY);
    // then
    instance = selectSingleProcessInstance();
    assertFalse(instance.isSuspended());
}

71. MigrationExternalTaskTest#testContinueProcess()

View license
@Test
public void testContinueProcess() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("externalTask", "externalTask").build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then it is possible to complete the task
    LockedExternalTask task = fetchAndLockSingleTask(ExternalTaskModels.TOPIC);
    rule.getExternalTaskService().complete(task.getId(), WORKER_ID);
    testHelper.assertProcessEnded(processInstance.getId());
}

72. MigrationExternalTaskTest#testLockedTaskContinueProcess()

View license
@Test
public void testLockedTaskContinueProcess() {
    // 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());
    LockedExternalTask externalTask = fetchAndLockSingleTask(ExternalTaskModels.TOPIC);
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then it is possible to complete the task and the process
    rule.getExternalTaskService().complete(externalTask.getId(), WORKER_ID);
    testHelper.assertProcessEnded(processInstance.getId());
}

73. MigrationExternalTaskTest#testAddParentScope()

View license
@Test
public void testAddParentScope() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ExternalTaskModels.SUBPROCESS_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("externalTask", "externalTask").build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then it is possible to complete the task
    LockedExternalTask task = fetchAndLockSingleTask(ExternalTaskModels.TOPIC);
    rule.getExternalTaskService().complete(task.getId(), WORKER_ID);
    testHelper.assertProcessEnded(processInstance.getId());
}

74. MigrationExternalTaskTest#testRemoveParentScope()

View license
@Test
public void testRemoveParentScope() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ExternalTaskModels.SUBPROCESS_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("externalTask", "externalTask").build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then it is possible to complete the task
    LockedExternalTask task = fetchAndLockSingleTask(ExternalTaskModels.TOPIC);
    rule.getExternalTaskService().complete(task.getId(), WORKER_ID);
    testHelper.assertProcessEnded(processInstance.getId());
}

75. MigrationMessageCatchEventTest#testMigrateEventSubscription()

View license
@Test
public void testMigrateEventSubscription() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(MessageReceiveModels.ONE_MESSAGE_CATCH_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(MessageReceiveModels.ONE_MESSAGE_CATCH_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("messageCatch", "messageCatch").build();
    // when
    ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
    testHelper.assertEventSubscriptionMigrated("messageCatch", "messageCatch", MessageReceiveModels.MESSAGE_NAME);
    // and it is possible to trigger the receive task
    rule.getRuntimeService().correlateMessage(MessageReceiveModels.MESSAGE_NAME);
    testHelper.completeTask("userTask");
    testHelper.assertProcessEnded(processInstance.getId());
}

76. MigrationMessageCatchEventTest#testMigrateEventSubscriptionChangeActivityId()

View license
@Test
public void testMigrateEventSubscriptionChangeActivityId() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(MessageReceiveModels.ONE_MESSAGE_CATCH_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(MessageReceiveModels.ONE_MESSAGE_CATCH_PROCESS).changeElementId("messageCatch", "newMessageCatch"));
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("messageCatch", "newMessageCatch").build();
    // when
    ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
    testHelper.assertEventSubscriptionMigrated("messageCatch", "newMessageCatch", MessageReceiveModels.MESSAGE_NAME);
    // and it is possible to trigger the receive task
    rule.getRuntimeService().correlateMessage(MessageReceiveModels.MESSAGE_NAME);
    testHelper.completeTask("userTask");
    testHelper.assertProcessEnded(processInstance.getId());
}

77. MigrationProcessInstanceTest#testNotMigrateProcessInstanceOfWrongProcessDefinition()

View license
@Test
public void testNotMigrateProcessInstanceOfWrongProcessDefinition() {
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    ProcessDefinition wrongProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.SUBPROCESS_PROCESS);
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(wrongProcessDefinition.getId());
    MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
    try {
        runtimeService.newMigration(migrationPlan).processInstanceIds(Collections.singletonList(processInstance.getId())).execute();
        fail("Should not be able to migrate");
    } catch (ProcessEngineException e) {
        assertThat(e.getMessage(), CoreMatchers.startsWith("ENGINE-23002"));
    }
}

78. MigrationReceiveTaskTest#testCannotMigrateActivityInstance()

View license
@Test
public void testCannotMigrateActivityInstance() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(MessageReceiveModels.ONE_RECEIVE_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(MessageReceiveModels.ONE_RECEIVE_TASK_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("receiveTask", "receiveTask").build();
    // when
    ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
    testHelper.assertEventSubscriptionMigrated("receiveTask", "receiveTask", MessageReceiveModels.MESSAGE_NAME);
    // and it is possible to trigger the receive task
    rule.getRuntimeService().correlateMessage(MessageReceiveModels.MESSAGE_NAME);
    testHelper.completeTask("userTask");
    testHelper.assertProcessEnded(processInstance.getId());
}

79. MigrationReceiveTaskTest#testMigrateEventSubscriptionChangeActivityId()

View license
@Test
public void testMigrateEventSubscriptionChangeActivityId() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(MessageReceiveModels.ONE_RECEIVE_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(MessageReceiveModels.ONE_RECEIVE_TASK_PROCESS).changeElementId("receiveTask", "newReceiveTask"));
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("receiveTask", "newReceiveTask").build();
    // when
    ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
    testHelper.assertEventSubscriptionMigrated("receiveTask", "newReceiveTask", MessageReceiveModels.MESSAGE_NAME);
    // and it is possible to trigger the receive task
    rule.getRuntimeService().correlateMessage(MessageReceiveModels.MESSAGE_NAME);
    testHelper.completeTask("userTask");
    testHelper.assertProcessEnded(processInstance.getId());
}

80. MigrationReceiveTaskTest#testMigrateEventSubscriptionPreserveMessageName()

View license
@Test
public void testMigrateEventSubscriptionPreserveMessageName() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(MessageReceiveModels.ONE_RECEIVE_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(MessageReceiveModels.ONE_RECEIVE_TASK_PROCESS).renameMessage(MessageReceiveModels.MESSAGE_NAME, "new" + MessageReceiveModels.MESSAGE_NAME));
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("receiveTask", "receiveTask").build();
    // when
    ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
    // then the message event subscription's event name has not changed
    testHelper.assertEventSubscriptionMigrated("receiveTask", "receiveTask", MessageReceiveModels.MESSAGE_NAME);
    // and it is possible to trigger the receive task
    rule.getRuntimeService().correlateMessage(MessageReceiveModels.MESSAGE_NAME);
    testHelper.completeTask("userTask");
    testHelper.assertProcessEnded(processInstance.getId());
}

81. MigrationReceiveTaskTest#testMigrateEventSubscriptionAddParentScope()

View license
@Test
public void testMigrateEventSubscriptionAddParentScope() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(MessageReceiveModels.ONE_RECEIVE_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(MessageReceiveModels.SUBPROCESS_RECEIVE_TASK_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("receiveTask", "receiveTask").build();
    // when
    ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
    testHelper.assertEventSubscriptionMigrated("receiveTask", "receiveTask", MessageReceiveModels.MESSAGE_NAME);
    // and it is possible to trigger the receive task
    rule.getRuntimeService().correlateMessage(MessageReceiveModels.MESSAGE_NAME);
    testHelper.completeTask("userTask");
    testHelper.assertProcessEnded(processInstance.getId());
}

82. MigrationSignalCatchEventTest#testMigrateEventSubscriptionChangeActivityId()

View license
@Test
public void testMigrateEventSubscriptionChangeActivityId() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(SignalCatchModels.ONE_SIGNAL_CATCH_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(SignalCatchModels.ONE_SIGNAL_CATCH_PROCESS).changeElementId("signalCatch", "newSignalCatch"));
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("signalCatch", "newSignalCatch").build();
    // when
    ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
    // then
    testHelper.assertEventSubscriptionMigrated("signalCatch", "newSignalCatch", SignalCatchModels.SIGNAL_NAME);
    // and it is possible to trigger the event
    rule.getRuntimeService().signalEventReceived(SignalCatchModels.SIGNAL_NAME);
    testHelper.completeTask("userTask");
    testHelper.assertProcessEnded(processInstance.getId());
}

83. MigrationCompensationTest#testCanRemoveCompensationBoundaryWithoutEventSubscriptions()

View license
@Test
public void testCanRemoveCompensationBoundaryWithoutEventSubscriptions() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask1", "userTask1").build();
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    testHelper.completeTask("userTask1");
    // then
    Assert.assertEquals(0, testHelper.snapshotAfterMigration.getEventSubscriptions().size());
    testHelper.completeTask("userTask2");
    testHelper.assertProcessEnded(processInstance.getId());
}

84. MessageCorrelationTest#testCorrelationByVariablesOnly()

View license
@Deployment(resources = "org/camunda/bpm/engine/test/api/runtime/MessageCorrelationTest.testCatchingMessageEventCorrelation.bpmn20.xml")
public void testCorrelationByVariablesOnly() {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("variable", "value1");
    runtimeService.startProcessInstanceByKey("process", variables);
    variables.put("variable", "value2");
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("process", variables);
    runtimeService.correlateMessage(null, variables);
    List<Execution> correlatedExecutions = runtimeService.createExecutionQuery().activityId("task").list();
    assertEquals(1, correlatedExecutions.size());
    assertEquals(instance.getId(), correlatedExecutions.get(0).getId());
}

85. MessageCorrelationTest#testCorrelationByBusinessKey()

View license
@Deployment(resources = "org/camunda/bpm/engine/test/api/runtime/MessageCorrelationTest.testCatchingMessageEventCorrelation.bpmn20.xml")
public void testCorrelationByBusinessKey() {
    runtimeService.startProcessInstanceByKey("process", "businessKey1");
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("process", "businessKey2");
    runtimeService.correlateMessage(null, "businessKey2");
    List<Execution> correlatedExecutions = runtimeService.createExecutionQuery().activityId("task").list();
    assertEquals(1, correlatedExecutions.size());
    assertEquals(instance.getId(), correlatedExecutions.get(0).getId());
}

86. MessageCorrelationTest#testCorrelationByProcessInstanceIdOnly()

View license
@Deployment(resources = "org/camunda/bpm/engine/test/api/runtime/MessageCorrelationTest.testCatchingMessageEventCorrelation.bpmn20.xml")
public void testCorrelationByProcessInstanceIdOnly() {
    runtimeService.startProcessInstanceByKey("process");
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("process");
    runtimeService.createMessageCorrelation(null).processInstanceId(instance.getId()).correlate();
    List<Execution> correlatedExecutions = runtimeService.createExecutionQuery().activityId("task").list();
    assertEquals(1, correlatedExecutions.size());
    assertEquals(instance.getId(), correlatedExecutions.get(0).getId());
}

87. MessageCorrelationTest#testCorrelationWithoutMessageNameFluent()

View license
@Deployment(resources = "org/camunda/bpm/engine/test/api/runtime/MessageCorrelationTest.testCatchingMessageEventCorrelation.bpmn20.xml")
public void testCorrelationWithoutMessageNameFluent() {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("variable", "value1");
    runtimeService.startProcessInstanceByKey("process", variables);
    variables.put("variable", "value2");
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("process", variables);
    runtimeService.createMessageCorrelation(null).processInstanceVariableEquals("variable", "value2").correlate();
    List<Execution> correlatedExecutions = runtimeService.createExecutionQuery().activityId("task").list();
    assertEquals(1, correlatedExecutions.size());
    assertEquals(instance.getId(), correlatedExecutions.get(0).getId());
}

88. MessageCorrelationTest#testCorrelationToExecutionWithMultipleSubscriptionsFails()

View license
@Deployment(resources = "org/camunda/bpm/engine/test/api/runtime/twoBoundaryEventSubscriptions.bpmn20.xml")
public void testCorrelationToExecutionWithMultipleSubscriptionsFails() {
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("process");
    try {
        runtimeService.createMessageCorrelation(null).processInstanceId(instance.getId()).correlate();
        fail("expected exception");
    } catch (ProcessEngineException e) {
    }
}

89. BatchMigrationUserOperationLogTest#testNoCreationOnJobExecutorBatchJobExecution()

View license
@Test
public void testNoCreationOnJobExecutorBatchJobExecution() {
    // given
    ProcessDefinition sourceProcessDefinition = migrationRule.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = migrationRule.deployAndGetDefinition(modify(ProcessModels.ONE_TASK_PROCESS).changeElementId(ProcessModels.PROCESS_KEY, "new" + ProcessModels.PROCESS_KEY));
    MigrationPlan migrationPlan = engineRule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
    ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    engineRule.getRuntimeService().newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.getId())).executeAsync();
    // when
    migrationRule.waitForJobExecutorToProcessAllJobs(5000L);
    // then
    Assert.assertEquals(0, engineRule.getHistoryService().createUserOperationLogQuery().count());
}

90. MigrationCompensationAddSubProcessTest#testCase2AssertExecutionTree()

View license
@Test
public void testCase2AssertExecutionTree() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask2", "userTask2").mapActivities("compensationBoundary", "compensationBoundary").build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    testHelper.completeTask("userTask1");
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then
    testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree("userTask2").scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).child("subProcess").scope().eventScope().done());
}

91. MigrationCompensationAddSubProcessTest#testNoListenersCalled()

View license
@Test
public void testNoListenersCalled() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL).activityBuilder("subProcess").camundaExecutionListenerExpression(ExecutionListener.EVENTNAME_START, "${execution.setVariable('foo', 'bar')}").done());
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask2", "userTask2").mapActivities("compensationBoundary", "compensationBoundary").build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    testHelper.completeTask("userTask1");
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then
    Assert.assertEquals(0, testHelper.snapshotAfterMigration.getVariables().size());
}

92. MigrationCompensationAddSubProcessTest#testNoInputMappingExecuted()

View license
@Ignore("CAM-6035")
@Test
public void testNoInputMappingExecuted() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL).activityBuilder("subProcess").camundaInputParameter("foo", "bar").done());
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask2", "userTask2").mapActivities("compensationBoundary", "compensationBoundary").build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    testHelper.completeTask("userTask1");
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then
    Assert.assertEquals(0, testHelper.snapshotAfterMigration.getVariables().size());
}

93. MigrationCompensationRemoveSubProcessTest#testCase1AssertExecutionTree()

View license
@Test
public void testCase1AssertExecutionTree() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_TWO_TASKS_SUBPROCESS_MODEL);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask2", "userTask2").mapActivities("compensationBoundary", "compensationBoundary").build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    testHelper.completeTask("userTask1");
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then
    testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree("userTask2").scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).done());
}

94. MigrationCompensationRemoveSubProcessTest#testCase2AssertExecutionTree()

View license
@Test
public void testCase2AssertExecutionTree() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask2", "userTask2").mapActivities("compensationBoundary", "compensationBoundary").build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    testHelper.completeTask("userTask1");
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then
    testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree("userTask2").scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).done());
}

95. MigrationEventBasedGatewayTest#testMigrateGatewayWithSignalEventMapEvent()

View license
@Test
public void testMigrateGatewayWithSignalEventMapEvent() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.SIGNAL_EVENT_BASED_GW_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.SIGNAL_EVENT_BASED_GW_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("eventBasedGateway", "eventBasedGateway").mapActivities("signalCatch", "signalCatch").build();
    // when
    ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
    // then
    testHelper.assertEventSubscriptionMigrated("signalCatch", "signalCatch", EventBasedGatewayModels.SIGNAL_NAME);
    rule.getRuntimeService().signalEventReceived(EventBasedGatewayModels.SIGNAL_NAME);
    testHelper.completeTask("afterSignalCatch");
    testHelper.assertProcessEnded(processInstance.getId());
}

96. MigrationEventBasedGatewayTest#testMigrateGatewayWithTimerEventMapEvent()

View license
@Test
public void testMigrateGatewayWithTimerEventMapEvent() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("eventBasedGateway", "eventBasedGateway").mapActivities("timerCatch", "timerCatch").build();
    // when
    ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
    // then
    testHelper.assertIntermediateTimerJobMigrated("timerCatch", "timerCatch");
    Job timerJob = testHelper.snapshotAfterMigration.getJobs().get(0);
    rule.getManagementService().executeJob(timerJob.getId());
    testHelper.completeTask("afterTimerCatch");
    testHelper.assertProcessEnded(processInstance.getId());
}

97. MigrationEventBasedGatewayTest#testMigrateGatewayWithMessageEventMapEvent()

View license
@Test
public void testMigrateGatewayWithMessageEventMapEvent() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.MESSAGE_EVENT_BASED_GW_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.MESSAGE_EVENT_BASED_GW_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("eventBasedGateway", "eventBasedGateway").mapActivities("messageCatch", "messageCatch").build();
    // when
    ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
    // then
    testHelper.assertEventSubscriptionMigrated("messageCatch", "messageCatch", EventBasedGatewayModels.MESSAGE_NAME);
    rule.getRuntimeService().correlateMessage(EventBasedGatewayModels.MESSAGE_NAME);
    testHelper.completeTask("afterMessageCatch");
    testHelper.assertProcessEnded(processInstance.getId());
}

98. MigrationEventBasedGatewayTest#testMigrateGatewayWithSignalEvent()

View license
@Test
public void testMigrateGatewayWithSignalEvent() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.SIGNAL_EVENT_BASED_GW_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.SIGNAL_EVENT_BASED_GW_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("eventBasedGateway", "eventBasedGateway").build();
    // when
    ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
    // then
    testHelper.assertEventSubscriptionRemoved("signalCatch", EventBasedGatewayModels.SIGNAL_NAME);
    testHelper.assertEventSubscriptionCreated("signalCatch", EventBasedGatewayModels.SIGNAL_NAME);
    rule.getRuntimeService().signalEventReceived(EventBasedGatewayModels.SIGNAL_NAME);
    testHelper.completeTask("afterSignalCatch");
    testHelper.assertProcessEnded(processInstance.getId());
}

99. MigrationEventBasedGatewayTest#testMigrateGatewayWithTimerEventChangeId()

View license
@Test
public void testMigrateGatewayWithTimerEventChangeId() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS).changeElementId("timerCatch", "newTimerCatch"));
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("eventBasedGateway", "eventBasedGateway").mapActivities("timerCatch", "newTimerCatch").build();
    // when
    ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
    // then
    testHelper.assertIntermediateTimerJobMigrated("timerCatch", "newTimerCatch");
    Job timerJob = testHelper.snapshotAfterMigration.getJobs().get(0);
    rule.getManagementService().executeJob(timerJob.getId());
    testHelper.completeTask("afterTimerCatch");
    testHelper.assertProcessEnded(processInstance.getId());
}

100. MigrationEventBasedGatewayTest#testMigrateGatewayWithMessageEventChangeId()

View license
@Test
public void testMigrateGatewayWithMessageEventChangeId() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.MESSAGE_EVENT_BASED_GW_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(EventBasedGatewayModels.MESSAGE_EVENT_BASED_GW_PROCESS).changeElementId("messageCatch", "newMessageCatch"));
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("eventBasedGateway", "eventBasedGateway").mapActivities("messageCatch", "newMessageCatch").build();
    // when
    ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
    // then
    testHelper.assertEventSubscriptionMigrated("messageCatch", "newMessageCatch", EventBasedGatewayModels.MESSAGE_NAME);
    rule.getRuntimeService().correlateMessage(EventBasedGatewayModels.MESSAGE_NAME);
    testHelper.completeTask("afterMessageCatch");
    testHelper.assertProcessEnded(processInstance.getId());
}