use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class MultiInstanceTest method testSequentialServiceTaskWithClassAndCollection.
@Deployment
public void testSequentialServiceTaskWithClassAndCollection() {
Collection<Integer> items = Arrays.asList(1, 2, 3, 4, 5, 6);
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("result", 1);
vars.put("items", items);
ProcessInstance procInst = runtimeService.startProcessInstanceByKey("multiInstanceServiceTask", vars);
Integer result = (Integer) runtimeService.getVariable(procInst.getId(), "result");
assertEquals(720, result.intValue());
runtimeService.signal(procInst.getId());
assertProcessEnded(procInst.getId());
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class MultiInstanceTest method testEndTimeOnMiSubprocess.
@Deployment
public void testEndTimeOnMiSubprocess() {
if (!processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
return;
}
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("multiInstanceSubProcessParallelTasks");
List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
assertEquals(2, tasks.size());
assertEquals("User Task 1", tasks.get(0).getName());
assertEquals("User Task 1", tasks.get(1).getName());
// End time should not be set for the subprocess
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityId("subprocess1").list();
assertEquals(2, historicActivityInstances.size());
for (HistoricActivityInstance historicActivityInstance : historicActivityInstances) {
assertNotNull(historicActivityInstance.getStartTime());
assertNull(historicActivityInstance.getEndTime());
}
// Complete one of the user tasks. This should not trigger setting of end time of the subprocess, but due to a bug it did exactly that
taskService.complete(tasks.get(0).getId());
historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityId("subprocess1").list();
assertEquals(2, historicActivityInstances.size());
for (HistoricActivityInstance historicActivityInstance : historicActivityInstances) {
assertNull(historicActivityInstance.getEndTime());
}
taskService.complete(tasks.get(1).getId());
historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityId("subprocess1").list();
assertEquals(2, historicActivityInstances.size());
for (HistoricActivityInstance historicActivityInstance : historicActivityInstances) {
assertNull(historicActivityInstance.getEndTime());
}
tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).taskName("User Task 3").list();
assertEquals(2, tasks.size());
for (Task task : tasks) {
taskService.complete(task.getId());
historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityId("subprocess1").list();
assertEquals(2, historicActivityInstances.size());
for (HistoricActivityInstance historicActivityInstance : historicActivityInstances) {
assertNull(historicActivityInstance.getEndTime());
}
}
// Finishing the tasks should also set the end time
tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
assertEquals(2, tasks.size());
for (Task task : tasks) {
taskService.complete(task.getId());
}
historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityId("subprocess1").list();
assertEquals(2, historicActivityInstances.size());
for (HistoricActivityInstance historicActivityInstance : historicActivityInstances) {
assertNotNull(historicActivityInstance.getEndTime());
}
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class ConditionalSequenceFlowTest method testSkipExpression.
@Deployment
public void testSkipExpression() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("input", "right");
variables.put("_ACTIVITI_SKIP_EXPRESSION_ENABLED", true);
variables.put("skipLeft", true);
variables.put("skipRight", false);
ProcessInstance pi = runtimeService.startProcessInstanceByKey("testSkipExpression", variables);
Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
assertEquals("task left", task.getName());
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class ConditionalSequenceFlowTest method testUelExpression.
@Deployment
public void testUelExpression() {
Map<String, Object> variables = CollectionUtil.singletonMap("input", "right");
ProcessInstance pi = runtimeService.startProcessInstanceByKey("condSeqFlowUelExpr", variables);
Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
assertEquals("task right", task.getName());
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class CallServiceInServiceTaskTest method testStartProcessFromDelegate.
@Deployment
public void testStartProcessFromDelegate() {
runtimeService.startProcessInstanceByKey("startProcessFromDelegate");
// Starting the process should lead to two processes being started,
// The other one started from the java delegate in the service task
List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().list();
assertEquals(2, processInstances.size());
boolean startProcessFromDelegateFound = false;
boolean oneTaskProcessFound = false;
for (ProcessInstance processInstance : processInstances) {
ProcessDefinition processDefinition = repositoryService.getProcessDefinition(processInstance.getProcessDefinitionId());
if (processDefinition.getKey().equals("startProcessFromDelegate")) {
startProcessFromDelegateFound = true;
} else if (processDefinition.getKey().equals("oneTaskProcess")) {
oneTaskProcessFound = true;
}
}
assertTrue(startProcessFromDelegateFound);
assertTrue(oneTaskProcessFound);
}
Aggregations