use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class EventSubProcessStartConditionalEventTest method testVariableCondition.
@Test
@Deployment
public void testVariableCondition() {
// given process with event sub process conditional start event
ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
Task task = taskQuery.singleResult();
assertNotNull(task);
assertEquals(TASK_BEFORE_CONDITION, task.getName());
// when variable is set on task with condition
taskService.setVariable(task.getId(), VARIABLE_NAME, 1);
// then execution is at user task after conditional start event
tasksAfterVariableIsSet = taskQuery.list();
assertEquals(TASK_AFTER_CONDITION, tasksAfterVariableIsSet.get(0).getName());
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class EventSubProcessStartConditionalEventTest method testNonInterruptingVariableCondition.
@Test
@Deployment
public void testNonInterruptingVariableCondition() {
// given process with event sub process conditional start event
ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
Task task = taskQuery.singleResult();
assertNotNull(task);
assertEquals(TASK_BEFORE_CONDITION, task.getName());
assertEquals(1, conditionEventSubscriptionQuery.list().size());
// when variable is set on task with condition
taskService.setVariable(task.getId(), VARIABLE_NAME, 1);
// then execution is at user task after conditional start event
tasksAfterVariableIsSet = taskQuery.list();
assertEquals(2, tasksAfterVariableIsSet.size());
assertEquals(1, conditionEventSubscriptionQuery.list().size());
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class CallActivityTest method testTimerOnCallActivity.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivity.testTimerOnCallActivity.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml" })
public void testTimerOnCallActivity() {
// After process start, the task in the subprocess should be active
runtimeService.startProcessInstanceByKey("timerOnCallActivity");
TaskQuery taskQuery = taskService.createTaskQuery();
Task taskInSubProcess = taskQuery.singleResult();
assertEquals("Task in subprocess", taskInSubProcess.getName());
Job timer = managementService.createJobQuery().singleResult();
assertNotNull(timer);
managementService.executeJob(timer.getId());
Task escalatedTask = taskQuery.singleResult();
assertEquals("Escalated Task", escalatedTask.getName());
// Completing the task ends the complete process
taskService.complete(escalatedTask.getId());
assertEquals(0, runtimeService.createExecutionQuery().list().size());
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class CallActivityTest method testInterruptingMessageEventSubProcessEventSubscriptionsInsideCallActivity.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivity.testInterruptingEventSubProcessEventSubscriptions.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/interruptingEventSubProcessEventSubscriptions.bpmn20.xml" })
public void testInterruptingMessageEventSubProcessEventSubscriptionsInsideCallActivity() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callInterruptingEventSubProcess");
// one task in the call activity subprocess should be active after starting the process instance
TaskQuery taskQuery = taskService.createTaskQuery();
Task taskInsideCallActivity = taskQuery.singleResult();
assertEquals("taskBeforeInterruptingEventSubprocess", taskInsideCallActivity.getTaskDefinitionKey());
// we should have no event subscriptions for the parent process
assertEquals(0, runtimeService.createEventSubscriptionQuery().processInstanceId(processInstance.getId()).count());
// we should have two event subscriptions for the called process instance, one for message and one for signal
String calledProcessInstanceId = taskInsideCallActivity.getProcessInstanceId();
EventSubscriptionQuery eventSubscriptionQuery = runtimeService.createEventSubscriptionQuery().processInstanceId(calledProcessInstanceId);
List<EventSubscription> subscriptions = eventSubscriptionQuery.list();
assertEquals(2, subscriptions.size());
// start the message interrupting event sub process
runtimeService.correlateMessage("newMessage");
Task taskAfterMessageStartEvent = taskQuery.processInstanceId(calledProcessInstanceId).singleResult();
assertEquals("taskAfterMessageStartEvent", taskAfterMessageStartEvent.getTaskDefinitionKey());
// no subscriptions left
assertEquals(0, eventSubscriptionQuery.count());
// Complete the task inside the called process instance
taskService.complete(taskAfterMessageStartEvent.getId());
assertProcessEnded(calledProcessInstanceId);
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class CallActivityTest method testAccessSuperInstanceVariablesFromConcurrentExecution.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivity.testCallSimpleSubProcess.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/concurrentSubProcessParentVariableAccess.bpmn20.xml" })
public void testAccessSuperInstanceVariablesFromConcurrentExecution() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callSimpleSubProcess");
// one task in the subprocess should be active after starting the process instance
TaskQuery taskQuery = taskService.createTaskQuery();
Task taskBeforeSubProcess = taskQuery.singleResult();
assertEquals("Task before subprocess", taskBeforeSubProcess.getName());
// the variable does not yet exist
assertNull(runtimeService.getVariable(processInstance.getId(), "greeting"));
// completing the task executed the sub process
taskService.complete(taskBeforeSubProcess.getId());
// now the variable exists
assertEquals("hello", runtimeService.getVariable(processInstance.getId(), "greeting"));
}
Aggregations