Search in sources :

Example 71 with Execution

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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) Execution(org.camunda.bpm.engine.runtime.Execution) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test) AbstractFoxPlatformIntegrationTest(org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)

Example 72 with Execution

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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) Execution(org.camunda.bpm.engine.runtime.Execution) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test) AbstractFoxPlatformIntegrationTest(org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)

Example 73 with Execution

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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) Execution(org.camunda.bpm.engine.runtime.Execution) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test) AbstractFoxPlatformIntegrationTest(org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)

Example 74 with Execution

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"));
}
Also used : Task(org.camunda.bpm.engine.task.Task) Execution(org.camunda.bpm.engine.runtime.Execution) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test) AbstractFoxPlatformIntegrationTest(org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)

Example 75 with Execution

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()));
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) InvocationContext(org.camunda.bpm.application.InvocationContext) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test) AbstractFoxPlatformIntegrationTest(org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)

Aggregations

Execution (org.camunda.bpm.engine.runtime.Execution)279 Deployment (org.camunda.bpm.engine.test.Deployment)188 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)143 Task (org.camunda.bpm.engine.task.Task)99 Test (org.junit.Test)95 HashMap (java.util.HashMap)45 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)33 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)23 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)22 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)20 ThrowErrorDelegate.leaveExecution (org.camunda.bpm.engine.test.bpmn.event.error.ThrowErrorDelegate.leaveExecution)18 ExecutionQuery (org.camunda.bpm.engine.runtime.ExecutionQuery)17 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)15 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)14 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)14 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)14 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)14 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)13 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)12 ArrayList (java.util.ArrayList)11