use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class CatchErrorFromProcessApplicationTest method testThrowExceptionInSignalParallelMultiInstance.
@Test
@OperateOnDeployment("clientDeployment")
public void testThrowExceptionInSignalParallelMultiInstance() {
String pi = runtimeService.startProcessInstanceByKey("testProcessParallelMI").getId();
assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
assertNull(runtimeService.getVariable(pi, "signaled"));
Execution serviceTask = runtimeService.createExecutionQuery().processInstanceId(pi).activityId("serviceTask").list().get(3);
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 CatchErrorFromProcessApplicationTest method testThrowErrorInSignalSequentialMultiInstance.
@Test
@OperateOnDeployment("clientDeployment")
public void testThrowErrorInSignalSequentialMultiInstance() {
String pi = runtimeService.startProcessInstanceByKey("testProcessSequentialMI").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, throwError());
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("userTaskError", userTask.getTaskDefinitionKey());
taskService.complete(userTask.getId());
}
use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class CatchErrorFromProcessApplicationTest method testThrowExceptionInSignalSequentialMultiInstance.
@Test
@OperateOnDeployment("clientDeployment")
public void testThrowExceptionInSignalSequentialMultiInstance() {
String pi = runtimeService.startProcessInstanceByKey("testProcessSequentialMI").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());
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 TaskListenerResolutionTest method testResolveClassOnTaskComplete.
@Test
@OperateOnDeployment("clientDeployment")
public void testResolveClassOnTaskComplete() {
// assert that we cannot load the delegate here:
try {
Class.forName("org.camunda.bpm.integrationtest.functional.classloading.beans.ExampleTaskListener");
Assert.fail("CNFE expected");
} catch (ClassNotFoundException e) {
// expected
}
ProcessInstance pi = runtimeService.startProcessInstanceByKey("testTaskListenerProcess");
// the listener should execute successfully
Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
taskService.setAssignee(task.getId(), "john doe");
Execution execution = runtimeService.createExecutionQuery().processInstanceId(pi.getId()).singleResult();
Assert.assertNotNull(runtimeService.getVariable(execution.getId(), "listener"));
runtimeService.removeVariable(execution.getId(), "listener");
taskService.complete(task.getId());
Assert.assertNotNull(runtimeService.getVariable(execution.getId(), "listener"));
// the delegate expression listener should execute successfully
runtimeService.removeVariable(execution.getId(), "listener");
task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
taskService.setAssignee(task.getId(), "john doe");
Assert.assertNotNull(runtimeService.getVariable(execution.getId(), "listener"));
runtimeService.removeVariable(execution.getId(), "listener");
taskService.complete(task.getId());
Assert.assertNotNull(runtimeService.getVariable(execution.getId(), "listener"));
}
use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class InvocationContextTest method testInvokeProcessApplicationWithContextOnSignalTask.
@Test
@OperateOnDeployment("app")
public void testInvokeProcessApplicationWithContextOnSignalTask() {
runtimeService.startProcessInstanceByKey("signalableProcess");
ProcessApplicationWithInvocationContext.clearInvocationContext();
Execution execution = runtimeService.createExecutionQuery().activityId("waitingTask").singleResult();
assertThat(execution, is(notNullValue()));
runtimeService.signal(execution.getId());
InvocationContext invocationContext = ProcessApplicationWithInvocationContext.getInvocationContext();
assertThat(invocationContext, is(notNullValue()));
assertThat(invocationContext.getExecution(), is(notNullValue()));
assertThat(invocationContext.getExecution().getId(), is(execution.getId()));
}
Aggregations