use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class MultiInstanceTest method testCatchExceptionThrownBySignalOfSequentialDelegateExpression.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.testCatchErrorThrownBySequentialDelegateExpression.bpmn20.xml" })
public void testCatchExceptionThrownBySignalOfSequentialDelegateExpression() {
VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate());
String pi = runtimeService.startProcessInstanceByKey("testProcess", variables).getId();
assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
assertNull(runtimeService.getVariable(pi, "signaled"));
// signal 2 times to execute first sequential behaviors
runtimeService.setVariables(pi, leaveExecution());
runtimeService.signal(runtimeService.createExecutionQuery().processInstanceId(pi).activityId("serviceTask").singleResult().getId());
runtimeService.setVariables(pi, leaveExecution());
runtimeService.signal(runtimeService.createExecutionQuery().processInstanceId(pi).activityId("serviceTask").singleResult().getId());
Execution serviceTask = runtimeService.createExecutionQuery().processInstanceId(pi).activityId("serviceTask").singleResult();
assertNotNull(serviceTask);
runtimeService.setVariables(pi, throwException());
runtimeService.signal(serviceTask.getId());
assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
assertTrue((Boolean) runtimeService.getVariable(pi, "signaled"));
Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult();
assertNotNull(userTask);
assertEquals("userTaskException", userTask.getTaskDefinitionKey());
taskService.complete(userTask.getId());
}
use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class MultiInstanceTest method testActiveExecutionsInParallelTasks.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.testParallelUserTasks.bpmn20.xml" })
public void testActiveExecutionsInParallelTasks() {
runtimeService.startProcessInstanceByKey("miParallelUserTasks").getId();
ProcessInstance instance = runtimeService.createProcessInstanceQuery().singleResult();
List<Execution> executions = runtimeService.createExecutionQuery().list();
assertEquals(5, executions.size());
for (Execution execution : executions) {
ExecutionEntity entity = (ExecutionEntity) execution;
if (!entity.getId().equals(instance.getId()) && !entity.getParentId().equals(instance.getId())) {
// child executions
assertTrue(entity.isActive());
} else {
// process instance and scope execution
assertFalse(entity.isActive());
}
}
}
use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class SignalEventReceivedBuilderTest method testSendSignalToIntermediateCatchEventWithVariables.
public void testSendSignalToIntermediateCatchEventWithVariables() {
deployment(signalCatchProcess("signalCatch"));
runtimeService.startProcessInstanceByKey("signalCatch");
Map<String, Object> variables = Variables.createVariables().putValue("var1", "a").putValue("var2", "b");
runtimeService.createSignalEvent("signal").setVariables(variables).send();
Execution execution = runtimeService.createExecutionQuery().singleResult();
assertThat(runtimeService.getVariables(execution.getId()), is(variables));
}
use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class MessageBoundaryEventTest method testSingleBoundaryMessageEvent.
@Deployment
public void testSingleBoundaryMessageEvent() {
runtimeService.startProcessInstanceByKey("process");
assertEquals(2, runtimeService.createExecutionQuery().count());
Task userTask = taskService.createTaskQuery().singleResult();
assertNotNull(userTask);
Execution execution = runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName").singleResult();
assertNotNull(execution);
// 1. case: message received cancels the task
runtimeService.messageEventReceived("messageName", execution.getId());
userTask = taskService.createTaskQuery().singleResult();
assertNotNull(userTask);
assertEquals("taskAfterMessage", userTask.getTaskDefinitionKey());
taskService.complete(userTask.getId());
assertEquals(0, runtimeService.createProcessInstanceQuery().count());
// 2nd. case: complete the user task cancels the message subscription
runtimeService.startProcessInstanceByKey("process");
userTask = taskService.createTaskQuery().singleResult();
assertNotNull(userTask);
taskService.complete(userTask.getId());
execution = runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName").singleResult();
assertNull(execution);
userTask = taskService.createTaskQuery().singleResult();
assertNotNull(userTask);
assertEquals("taskAfterTask", userTask.getTaskDefinitionKey());
taskService.complete(userTask.getId());
assertEquals(0, runtimeService.createProcessInstanceQuery().count());
}
use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class MessageBoundaryEventTest method testExpressionInBoundaryMessageEventName.
@Deployment
public void testExpressionInBoundaryMessageEventName() {
// given a process instance with its variables
HashMap<String, Object> variables = new HashMap<String, Object>();
variables.put("foo", "bar");
runtimeService.startProcessInstanceByKey("process", variables);
// when message is received
Execution execution = runtimeService.createExecutionQuery().messageEventSubscriptionName("messageName-bar").singleResult();
assertNotNull(execution);
runtimeService.messageEventReceived("messageName-bar", execution.getId());
// then then a task should be completed
Task userTask = taskService.createTaskQuery().singleResult();
assertNotNull(userTask);
assertEquals("taskAfterMessage", userTask.getTaskDefinitionKey());
taskService.complete(userTask.getId());
assertEquals(0, runtimeService.createProcessInstanceQuery().count());
}
Aggregations