Search in sources :

Example 61 with ExecutionEntity

use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.

the class ExecutionVariablesTest method testTreeCompactionWithLocalVariableOnConcurrentExecution.

@Deployment
public void testTreeCompactionWithLocalVariableOnConcurrentExecution() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
    Execution innerTaskExecution = runtimeService.createExecutionQuery().activityId("innerTask").singleResult();
    Execution subProcessConcurrentExecution = runtimeService.createExecutionQuery().executionId(((ExecutionEntity) innerTaskExecution).getParentId()).singleResult();
    Task task = taskService.createTaskQuery().taskDefinitionKey("task").singleResult();
    // when
    runtimeService.setVariableLocal(subProcessConcurrentExecution.getId(), "foo", "bar");
    // and completing the concurrent task, thereby pruning the sub process concurrent execution
    taskService.complete(task.getId());
    // then the variable still exists
    VariableInstance variable = runtimeService.createVariableInstanceQuery().singleResult();
    assertNotNull(variable);
    assertEquals("foo", variable.getName());
    assertEquals(processInstance.getId(), variable.getExecutionId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) Execution(org.camunda.bpm.engine.runtime.Execution) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 62 with ExecutionEntity

use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.

the class ExecutionVariablesTest method testStableVariableInstanceIdsOnCompaction.

@Deployment(resources = "org/camunda/bpm/engine/test/api/variables/ExecutionVariablesTest.testTreeCompactionWithLocalVariableOnConcurrentExecution.bpmn20.xml")
public void testStableVariableInstanceIdsOnCompaction() {
    runtimeService.startProcessInstanceByKey("process");
    Execution innerTaskExecution = runtimeService.createExecutionQuery().activityId("innerTask").singleResult();
    Execution subProcessConcurrentExecution = runtimeService.createExecutionQuery().executionId(((ExecutionEntity) innerTaskExecution).getParentId()).singleResult();
    Task task = taskService.createTaskQuery().taskDefinitionKey("task").singleResult();
    // when
    runtimeService.setVariableLocal(subProcessConcurrentExecution.getId(), "foo", "bar");
    VariableInstance variableBeforeCompaction = runtimeService.createVariableInstanceQuery().singleResult();
    // and completing the concurrent task, thereby pruning the sub process concurrent execution
    taskService.complete(task.getId());
    // then the variable still exists
    VariableInstance variableAfterCompaction = runtimeService.createVariableInstanceQuery().singleResult();
    assertEquals(variableBeforeCompaction.getId(), variableAfterCompaction.getId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) Execution(org.camunda.bpm.engine.runtime.Execution) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 63 with ExecutionEntity

use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.

the class ExecutionVariablesTest method testTreeCompactionNestedForkParallelGateway.

@Deployment
public void testTreeCompactionNestedForkParallelGateway() {
    // given
    runtimeService.startProcessInstanceByKey("process");
    Task task1 = taskService.createTaskQuery().taskDefinitionKey("task1").singleResult();
    Execution task2Execution = runtimeService.createExecutionQuery().activityId("task2").singleResult();
    String subProcessScopeExecutionId = ((ExecutionEntity) task2Execution).getParentId();
    // when
    runtimeService.setVariableLocal(task2Execution.getId(), "foo", "bar");
    // and completing the other task, thereby pruning the concurrent execution
    taskService.complete(task1.getId());
    // then the variable still exists on the subprocess scope execution
    VariableInstance variable = runtimeService.createVariableInstanceQuery().singleResult();
    assertNotNull(variable);
    assertEquals("foo", variable.getName());
    assertEquals(subProcessScopeExecutionId, variable.getExecutionId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) Execution(org.camunda.bpm.engine.runtime.Execution) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 64 with ExecutionEntity

use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity 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 65 with ExecutionEntity

use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.

the class MessageEventSubprocessTest method testNonInterruptingWithUserTaskAndBoundaryEventInsideEmbeddedSubProcess.

@Deployment
public void testNonInterruptingWithUserTaskAndBoundaryEventInsideEmbeddedSubProcess() {
    String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
    // when
    runtimeService.correlateMessage("newMessage");
    // then
    assertEquals(2, taskService.createTaskQuery().count());
    Task task1 = taskService.createTaskQuery().taskDefinitionKey("eventSubProcessTask").singleResult();
    assertNotNull(task1);
    Execution task1Execution = runtimeService.createExecutionQuery().activityId("eventSubProcessTask").singleResult();
    assertFalse(processInstanceId.equals(((ExecutionEntity) task1Execution).getParentId()));
    Task task2 = taskService.createTaskQuery().taskDefinitionKey("task").singleResult();
    assertNotNull(task2);
    Execution task2Execution = runtimeService.createExecutionQuery().activityId("eventSubProcessTask").singleResult();
    assertFalse(processInstanceId.equals(((ExecutionEntity) task2Execution).getParentId()));
    // both have the same parent (but it is not the process instance)
    assertTrue(((ExecutionEntity) task1Execution).getParentId().equals(((ExecutionEntity) task2Execution).getParentId()));
    assertEquals(1, runtimeService.createEventSubscriptionQuery().count());
    taskService.complete(task1.getId());
    taskService.complete(task2.getId());
    assertProcessEnded(processInstanceId);
}
Also used : Task(org.camunda.bpm.engine.task.Task) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)170 Deployment (org.camunda.bpm.engine.test.Deployment)42 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)18 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)17 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)16 Execution (org.camunda.bpm.engine.runtime.Execution)14 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)13 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)12 Task (org.camunda.bpm.engine.task.Task)12 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)10 ArrayList (java.util.ArrayList)9 VariableInstanceEntity (org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity)9 Test (org.junit.Test)9 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)7 EventSubscriptionEntity (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)7 PvmExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)7 ProcessDefinitionImpl (org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl)6 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)6 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)5