use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class ProcessInstanceSuspensionTest method testChildExecutionsSuspendedAfterProcessInstanceSuspend.
@Deployment
public void testChildExecutionsSuspendedAfterProcessInstanceSuspend() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testChildExecutionsSuspended");
runtimeService.suspendProcessInstanceById(processInstance.getId());
List<Execution> executions = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).list();
for (Execution execution : executions) {
assertTrue(execution.isSuspended());
}
// Activate again
runtimeService.activateProcessInstanceById(processInstance.getId());
executions = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).list();
for (Execution execution : executions) {
assertFalse(execution.isSuspended());
}
// Finish process
while (taskService.createTaskQuery().count() > 0) {
for (Task task : taskService.createTaskQuery().list()) {
taskService.complete(task.getId());
}
}
assertEquals(0, runtimeService.createProcessInstanceQuery().count());
}
use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class ExecutionQueryTest method testExecutionQueryWithProcessVariable.
@Deployment(resources = { "org/activiti/engine/test/api/runtime/concurrentExecution.bpmn20.xml" })
public void testExecutionQueryWithProcessVariable() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("x", "parent");
variables.put("xIgnoreCase", "PaReNt");
ProcessInstance pi = runtimeService.startProcessInstanceByKey("concurrent", variables);
List<Execution> concurrentExecutions = runtimeService.createExecutionQuery().processInstanceId(pi.getId()).list();
assertEquals(3, concurrentExecutions.size());
for (Execution execution : concurrentExecutions) {
if (!((ExecutionEntity) execution).isProcessInstanceType()) {
// only the concurrent executions, not the root one, would be cooler to query that directly, see https://activiti.atlassian.net/browse/ACT-1373
runtimeService.setVariableLocal(execution.getId(), "x", "child");
runtimeService.setVariableLocal(execution.getId(), "xIgnoreCase", "ChILD");
}
}
assertEquals(2, runtimeService.createExecutionQuery().processInstanceId(pi.getId()).variableValueEquals("x", "child").count());
assertEquals(1, runtimeService.createExecutionQuery().processInstanceId(pi.getId()).variableValueEquals("x", "parent").count());
assertEquals(3, runtimeService.createExecutionQuery().processInstanceId(pi.getId()).processVariableValueEquals("x", "parent").count());
assertEquals(3, runtimeService.createExecutionQuery().processInstanceId(pi.getId()).processVariableValueNotEquals("x", "xxx").count());
// Test value-only query
assertEquals(0, runtimeService.createExecutionQuery().processInstanceId(pi.getId()).processVariableValueEquals("child").count());
assertEquals(3, runtimeService.createExecutionQuery().processInstanceId(pi.getId()).processVariableValueEquals("parent").count());
// Test ignore-case queries
assertEquals(0, runtimeService.createExecutionQuery().processInstanceId(pi.getId()).processVariableValueEqualsIgnoreCase("xIgnoreCase", "CHILD").count());
assertEquals(3, runtimeService.createExecutionQuery().processInstanceId(pi.getId()).processVariableValueEqualsIgnoreCase("xIgnoreCase", "PARENT").count());
// Test ignore-case queries
assertEquals(0, runtimeService.createExecutionQuery().processInstanceId(pi.getId()).processVariableValueNotEqualsIgnoreCase("xIgnoreCase", "paRent").count());
assertEquals(3, runtimeService.createExecutionQuery().processInstanceId(pi.getId()).processVariableValueNotEqualsIgnoreCase("xIgnoreCase", "chilD").count());
}
use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class ExecutionQueryTest method testQueryEqualsIgnoreCase.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testQueryEqualsIgnoreCase() {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("mixed", "AbCdEfG");
vars.put("lower", "ABCDEFG");
vars.put("upper", "abcdefg");
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
Execution execution = runtimeService.createExecutionQuery().variableValueEqualsIgnoreCase("mixed", "abcdefg").singleResult();
assertNotNull(execution);
assertEquals(processInstance1.getId(), execution.getId());
execution = runtimeService.createExecutionQuery().variableValueEqualsIgnoreCase("lower", "abcdefg").singleResult();
assertNotNull(execution);
assertEquals(processInstance1.getId(), execution.getId());
execution = runtimeService.createExecutionQuery().variableValueEqualsIgnoreCase("upper", "abcdefg").singleResult();
assertNotNull(execution);
assertEquals(processInstance1.getId(), execution.getId());
// Pass in non-lower-case string
execution = runtimeService.createExecutionQuery().variableValueEqualsIgnoreCase("upper", "ABCdefg").singleResult();
assertNotNull(execution);
assertEquals(processInstance1.getId(), execution.getId());
// Pass in null-value, should cause exception
try {
execution = runtimeService.createExecutionQuery().variableValueEqualsIgnoreCase("upper", null).singleResult();
fail("Exception expected");
} catch (ActivitiIllegalArgumentException ae) {
assertEquals("value is null", ae.getMessage());
}
// Pass in null name, should cause exception
try {
execution = runtimeService.createExecutionQuery().variableValueEqualsIgnoreCase(null, "abcdefg").singleResult();
fail("Exception expected");
} catch (ActivitiIllegalArgumentException ae) {
assertEquals("name is null", ae.getMessage());
}
// Test NOT equals
execution = runtimeService.createExecutionQuery().variableValueNotEqualsIgnoreCase("upper", "UIOP").singleResult();
assertNotNull(execution);
// Should return result when using "ABCdefg" case-insensitive while normal not-equals won't
execution = runtimeService.createExecutionQuery().variableValueNotEqualsIgnoreCase("upper", "ABCdefg").singleResult();
assertNull(execution);
execution = runtimeService.createExecutionQuery().variableValueNotEquals("upper", "ABCdefg").singleResult();
assertNotNull(execution);
// Pass in null-value, should cause exception
try {
execution = runtimeService.createExecutionQuery().variableValueNotEqualsIgnoreCase("upper", null).singleResult();
fail("Exception expected");
} catch (ActivitiIllegalArgumentException ae) {
assertEquals("value is null", ae.getMessage());
}
// Pass in null name, should cause exception
try {
execution = runtimeService.createExecutionQuery().variableValueNotEqualsIgnoreCase(null, "abcdefg").singleResult();
fail("Exception expected");
} catch (ActivitiIllegalArgumentException ae) {
assertEquals("name is null", ae.getMessage());
}
}
use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class RuntimeServiceTest method testFindActiveActivityIdProcessWithErrorEventAndSubProcess.
/**
* Testcase to reproduce ACT-950 (https://activiti.atlassian.net/browse/ACT-950)
*/
@Deployment
public void testFindActiveActivityIdProcessWithErrorEventAndSubProcess() {
ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceByKey("errorEventSubprocess");
List<String> activeActivities = runtimeService.getActiveActivityIds(processInstance.getId());
assertEquals(3, activeActivities.size());
List<Task> tasks = taskService.createTaskQuery().list();
assertEquals(2, tasks.size());
Task parallelUserTask = null;
for (Task task : tasks) {
if (!task.getName().equals("ParallelUserTask") && !task.getName().equals("MainUserTask")) {
fail("Expected: <ParallelUserTask> or <MainUserTask> but was <" + task.getName() + ">.");
}
if (task.getName().equals("ParallelUserTask")) {
parallelUserTask = task;
}
}
assertNotNull(parallelUserTask);
taskService.complete(parallelUserTask.getId());
Execution execution = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).activityId("subprocess1WaitBeforeError").singleResult();
runtimeService.signal(execution.getId());
activeActivities = runtimeService.getActiveActivityIds(processInstance.getId());
assertEquals(2, activeActivities.size());
tasks = taskService.createTaskQuery().list();
assertEquals(2, tasks.size());
Task beforeErrorUserTask = null;
for (Task task : tasks) {
if (!task.getName().equals("BeforeError") && !task.getName().equals("MainUserTask")) {
fail("Expected: <BeforeError> or <MainUserTask> but was <" + task.getName() + ">.");
}
if (task.getName().equals("BeforeError")) {
beforeErrorUserTask = task;
}
}
assertNotNull(beforeErrorUserTask);
taskService.complete(beforeErrorUserTask.getId());
activeActivities = runtimeService.getActiveActivityIds(processInstance.getId());
assertEquals(2, activeActivities.size());
tasks = taskService.createTaskQuery().list();
assertEquals(2, tasks.size());
Task afterErrorUserTask = null;
for (Task task : tasks) {
if (!task.getName().equals("AfterError") && !task.getName().equals("MainUserTask")) {
fail("Expected: <AfterError> or <MainUserTask> but was <" + task.getName() + ">.");
}
if (task.getName().equals("AfterError")) {
afterErrorUserTask = task;
}
}
assertNotNull(afterErrorUserTask);
taskService.complete(afterErrorUserTask.getId());
tasks = taskService.createTaskQuery().list();
assertEquals(1, tasks.size());
assertEquals("MainUserTask", tasks.get(0).getName());
activeActivities = runtimeService.getActiveActivityIds(processInstance.getId());
assertEquals(1, activeActivities.size());
assertEquals("MainUserTask", activeActivities.get(0));
taskService.complete(tasks.get(0).getId());
assertProcessEnded(processInstance.getId());
}
use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class ReceiveTaskTest method testWaitStateBehavior.
@Deployment
public void testWaitStateBehavior() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("receiveTask");
Execution execution = runtimeService.createExecutionQuery().processInstanceId(pi.getId()).activityId("waitState").singleResult();
assertNotNull(execution);
runtimeService.signal(execution.getId());
assertProcessEnded(pi.getId());
}
Aggregations