public void testUnbalancedForkJoin() {
RuntimeService runtimeService = activitiRule.getRuntimeService();
ProcessInstance pi = runtimeService.startProcessInstanceByKey("UnbalancedForkJoin");
TaskService taskService = activitiRule.getTaskService();
TaskQuery query = taskService.createTaskQuery()
.processInstanceId(pi.getId())
.orderByTaskName()
.asc();
List<Task> tasks = query.list();
assertEquals(3, tasks.size());
// the tasks are ordered by name (see above)
Task task1 = tasks.get(0);
assertEquals("Task 1", task1.getName());
Task task2 = tasks.get(1);
assertEquals("Task 2", task2.getName());
// Completing the first task should *not* trigger the join
taskService.complete(task1.getId());
// Completing the second task should trigger the first join
taskService.complete(task2.getId());
tasks = query.list();
Task task3 = tasks.get(0);
assertEquals(2, tasks.size());
assertEquals("Task 3", task3.getName());
Task task4 = tasks.get(1);
assertEquals("Task 4", task4.getName());