Search in sources :

Example 86 with Execution

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());
}
Also used : ThrowErrorDelegate(org.camunda.bpm.engine.test.bpmn.event.error.ThrowErrorDelegate) Task(org.camunda.bpm.engine.task.Task) ThrowErrorDelegate.leaveExecution(org.camunda.bpm.engine.test.bpmn.event.error.ThrowErrorDelegate.leaveExecution) Execution(org.camunda.bpm.engine.runtime.Execution) VariableMap(org.camunda.bpm.engine.variable.VariableMap) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 87 with Execution

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());
        }
    }
}
Also used : ThrowErrorDelegate.leaveExecution(org.camunda.bpm.engine.test.bpmn.event.error.ThrowErrorDelegate.leaveExecution) Execution(org.camunda.bpm.engine.runtime.Execution) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 88 with Execution

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));
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString)

Example 89 with Execution

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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) Execution(org.camunda.bpm.engine.runtime.Execution) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 90 with Execution

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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) Execution(org.camunda.bpm.engine.runtime.Execution) HashMap(java.util.HashMap) Deployment(org.camunda.bpm.engine.test.Deployment)

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