use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class SubProcessTest method testTwoSubProcessInParallel.
@Deployment
public void testTwoSubProcessInParallel() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("twoSubProcessInParallel");
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(pi.getId()).orderByTaskName().asc();
List<Task> tasks = taskQuery.list();
// After process start, both tasks in the subprocesses should be active
assertEquals("Task in subprocess A", tasks.get(0).getName());
assertEquals("Task in subprocess B", tasks.get(1).getName());
// Completing both tasks should active the tasks outside the subprocesses
taskService.complete(tasks.get(0).getId());
tasks = taskQuery.list();
assertEquals("Task after subprocess A", tasks.get(0).getName());
assertEquals("Task in subprocess B", tasks.get(1).getName());
taskService.complete(tasks.get(1).getId());
tasks = taskQuery.list();
assertEquals("Task after subprocess A", tasks.get(0).getName());
assertEquals("Task after subprocess B", tasks.get(1).getName());
// Completing these tasks should end the process
taskService.complete(tasks.get(0).getId());
taskService.complete(tasks.get(1).getId());
assertProcessEnded(pi.getId());
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class MultiInstanceTest method testSequentialSubProcess.
@Deployment
public void testSequentialSubProcess() {
String procId = runtimeService.startProcessInstanceByKey("miSequentialSubprocess").getId();
TaskQuery query = taskService.createTaskQuery().orderByTaskName().asc();
for (int i = 0; i < 4; i++) {
List<Task> tasks = query.list();
assertEquals(2, tasks.size());
assertEquals("task one", tasks.get(0).getName());
assertEquals("task two", tasks.get(1).getName());
taskService.complete(tasks.get(0).getId());
taskService.complete(tasks.get(1).getId());
if (i != 3) {
List<String> activities = runtimeService.getActiveActivityIds(procId);
assertNotNull(activities);
assertEquals(2, activities.size());
}
}
assertProcessEnded(procId);
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class CallActivityAdvancedTest method testCallParallelSubProcess.
@Deployment(resources = { "org/activiti/engine/test/bpmn/callactivity/CallActivity.testCallParallelSubProcess.bpmn20.xml", "org/activiti/engine/test/bpmn/callactivity/simpleParallelSubProcess.bpmn20.xml" })
public void testCallParallelSubProcess() {
runtimeService.startProcessInstanceByKey("callParallelSubProcess");
// The two tasks in the parallel subprocess should be active
TaskQuery taskQuery = taskService.createTaskQuery().orderByTaskName().asc();
List<Task> tasks = taskQuery.list();
assertEquals(2, tasks.size());
Task taskA = tasks.get(0);
Task taskB = tasks.get(1);
assertEquals("Task A", taskA.getName());
assertEquals("Task B", taskB.getName());
// Completing the first task should not end the subprocess
taskService.complete(taskA.getId());
assertEquals(1, taskQuery.list().size());
// Completing the second task should end the subprocess and end the whole process instance
taskService.complete(taskB.getId());
assertEquals(0, runtimeService.createExecutionQuery().count());
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class CallActivityAdvancedTest method testSubProcessEndsSuperProcess.
/**
* Test case for a possible tricky case: reaching the end event
* of the subprocess leads to an end event in the super process instance.
*/
@Deployment(resources = { "org/activiti/engine/test/bpmn/callactivity/CallActivity.testSubProcessEndsSuperProcess.bpmn20.xml", "org/activiti/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml" })
public void testSubProcessEndsSuperProcess() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("subProcessEndsSuperProcess");
// one task in the subprocess should be active after starting the process instance
TaskQuery taskQuery = taskService.createTaskQuery();
Task taskBeforeSubProcess = taskQuery.singleResult();
assertEquals("Task in subprocess", taskBeforeSubProcess.getName());
// Completing this task ends the subprocess which leads to the end of the whole process instance
taskService.complete(taskBeforeSubProcess.getId());
assertProcessEnded(processInstance.getId());
assertEquals(0, runtimeService.createExecutionQuery().list().size());
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class HistoricVariableInstanceTest method testRestrictByExecutionId.
@Deployment
public void testRestrictByExecutionId() {
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.FULL)) {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProc");
TaskQuery taskQuery = taskService.createTaskQuery();
Task userTask = taskQuery.singleResult();
assertEquals("userTask1", userTask.getName());
taskService.complete(userTask.getId(), CollectionUtil.singletonMap("myVar", "test789"));
assertProcessEnded(processInstance.getId());
List<HistoricVariableInstance> variables = historyService.createHistoricVariableInstanceQuery().executionId(processInstance.getId()).list();
assertEquals(1, variables.size());
HistoricVariableInstanceEntity historicVariable = (HistoricVariableInstanceEntity) variables.get(0);
assertEquals("test456", historicVariable.getTextValue());
assertEquals(5, historyService.createHistoricActivityInstanceQuery().count());
assertEquals(3, historyService.createHistoricDetailQuery().count());
}
}
Aggregations