use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class TaskVariablesTest method testGetVariablesLocalByTaskIdsForScope.
@Deployment(resources = { "org/activiti/engine/test/api/runtime/variableScope.bpmn20.xml" })
public void testGetVariablesLocalByTaskIdsForScope() {
Map<String, Object> processVars = new HashMap<String, Object>();
processVars.put("processVar", "processVar");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("variableScopeProcess", processVars);
Set<String> executionIds = new HashSet<String>();
List<Execution> executions = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).list();
for (Execution execution : executions) {
if (!processInstance.getId().equals(execution.getId())) {
executionIds.add(execution.getId());
runtimeService.setVariableLocal(execution.getId(), "executionVar", "executionVar");
}
}
List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
Set<String> taskIds = new HashSet<String>();
for (Task task : tasks) {
taskService.setVariableLocal(task.getId(), "taskVar", "taskVar");
taskIds.add(task.getId());
}
List<VariableInstance> variableInstances = taskService.getVariableInstancesLocalByTaskIds(taskIds);
assertEquals(variableInstances.size(), 2);
assertEquals(variableInstances.get(0).getName(), "taskVar");
assertEquals(variableInstances.get(0).getValue(), "taskVar");
assertEquals(variableInstances.get(1).getName(), "taskVar");
assertEquals(variableInstances.get(1).getValue(), "taskVar");
}
use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class TerminateEndEventTest method testThreeExecutionsArrivingInTerminateEndEvent.
// Unit test for ACT-4101 : NPE when there are multiple routes to terminateEndEvent, and both are reached
@Deployment
public void testThreeExecutionsArrivingInTerminateEndEvent() {
Map<String, Object> variableMap = new HashMap<String, Object>();
variableMap.put("passed_QC", false);
variableMap.put("has_bad_pixel_pattern", true);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("skybox_image_pull_request", variableMap);
String processInstanceId = processInstance.getId();
assertNotNull(processInstance);
while (processInstance != null) {
List<Execution> executionList = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).list();
String activityId = "";
for (Execution execution : executionList) {
activityId = execution.getActivityId();
if (activityId == null || activityId.equalsIgnoreCase("quality_control_passed_gateway") || activityId.equalsIgnoreCase("parallelgateway1") || activityId.equalsIgnoreCase("catch_bad_pixel_signal") || activityId.equalsIgnoreCase("throw_bad_pixel_signal") || activityId.equalsIgnoreCase("has_bad_pixel_pattern") || activityId.equalsIgnoreCase("")) {
continue;
}
System.out.println("Current Activity:" + activityId);
runtimeService.signal(execution.getId());
}
processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
}
assertProcessEnded(processInstanceId);
assertHistoricProcessInstanceDetails(processInstanceId);
}
use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class Photo method launchPhotoProcess.
public void launchPhotoProcess(String... photoLabels) {
List<Photo> photos = new ArrayList<Photo>();
for (String l : photoLabels) {
Photo x = this.photoRepository.save(new Photo(l));
photos.add(x);
}
Map<String, Object> procVars = new HashMap<String, Object>();
procVars.put("photos", photos);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dogeProcess", procVars);
List<Execution> waitingExecutions = runtimeService.createExecutionQuery().activityId("wait").list();
System.out.println("--> # executions = " + waitingExecutions.size());
for (Execution execution : waitingExecutions) {
runtimeService.signal(execution.getId());
}
Task reviewTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.complete(reviewTask.getId(), Collections.singletonMap("approved", (Object) true));
long count = runtimeService.createProcessInstanceQuery().count();
System.out.println("Proc count " + count);
}
use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class HistoricVariableInstanceTest method testHistoricVariableQueryByExecutionIdsForScope.
@Deployment(resources = { "org/activiti/engine/test/api/runtime/variableScope.bpmn20.xml" })
public void testHistoricVariableQueryByExecutionIdsForScope() {
Map<String, Object> processVars = new HashMap<String, Object>();
processVars.put("processVar", "processVar");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("variableScopeProcess", processVars);
Set<String> executionIds = new HashSet<String>();
List<Execution> executions = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).list();
for (Execution execution : executions) {
if (!processInstance.getId().equals(execution.getId())) {
executionIds.add(execution.getId());
runtimeService.setVariableLocal(execution.getId(), "executionVar", "executionVar");
}
}
List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
for (Task task : tasks) {
taskService.setVariableLocal(task.getId(), "taskVar", "taskVar");
}
Set<String> processInstanceIds = new HashSet<String>();
processInstanceIds.add(processInstance.getId());
List<HistoricVariableInstance> historicVariableInstances = historyService.createHistoricVariableInstanceQuery().executionIds(processInstanceIds).list();
assertEquals(historicVariableInstances.size(), 1);
assertEquals(historicVariableInstances.get(0).getVariableName(), "processVar");
assertEquals(historicVariableInstances.get(0).getValue(), "processVar");
historicVariableInstances = historyService.createHistoricVariableInstanceQuery().executionIds(executionIds).excludeTaskVariables().list();
assertEquals(historicVariableInstances.size(), 2);
assertEquals(historicVariableInstances.get(0).getVariableName(), "executionVar");
assertEquals(historicVariableInstances.get(0).getValue(), "executionVar");
assertEquals(historicVariableInstances.get(1).getVariableName(), "executionVar");
assertEquals(historicVariableInstances.get(1).getValue(), "executionVar");
}
use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class HistoricActivityInstanceTest method testEventBasedGateway.
/**
* Test to validate fix for ACT-1399: Boundary-event and event-based auditing
*/
@Deployment
public void testEventBasedGateway() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("catchSignal");
Execution waitingExecution = runtimeService.createExecutionQuery().signalEventSubscriptionName("alert").singleResult();
assertNotNull(waitingExecution);
runtimeService.signalEventReceived("alert", waitingExecution.getId());
assertEquals(0L, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count());
HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("eventBasedgateway").processInstanceId(processInstance.getId()).singleResult();
assertNotNull(historicActivityInstance);
}
Aggregations