Search in sources :

Example 66 with ExecutionEntity

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

the class MessageNonInterruptingBoundaryEventTest method testNonInterruptingEventInCombinationWithReceiveTaskInsideSubProcess.

@Deployment
public void testNonInterruptingEventInCombinationWithReceiveTaskInsideSubProcess() {
    // given
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("process");
    String processInstanceId = instance.getId();
    // when (1)
    runtimeService.correlateMessage("firstMessage");
    // then (1)
    ActivityInstance activityInstance = runtimeService.getActivityInstance(instance.getId());
    assertThat(activityInstance).hasStructure(describeActivityInstanceTree(instance.getProcessDefinitionId()).beginScope("subProcess").activity("task1").beginScope("innerSubProcess").activity("receiveTask").done());
    assertEquals(1, taskService.createTaskQuery().count());
    Task task1 = taskService.createTaskQuery().taskDefinitionKey("task1").singleResult();
    assertNotNull(task1);
    Execution task1Execution = runtimeService.createExecutionQuery().activityId("task1").singleResult();
    assertFalse(processInstanceId.equals(((ExecutionEntity) task1Execution).getParentId()));
    // when (2)
    runtimeService.correlateMessage("secondMessage");
    // then (2)
    assertEquals(2, taskService.createTaskQuery().count());
    task1 = taskService.createTaskQuery().taskDefinitionKey("task1").singleResult();
    assertNotNull(task1);
    task1Execution = runtimeService.createExecutionQuery().activityId("task1").singleResult();
    assertFalse(processInstanceId.equals(((ExecutionEntity) task1Execution).getParentId()));
    Task task2 = taskService.createTaskQuery().taskDefinitionKey("task2").singleResult();
    assertNotNull(task2);
    Execution task2Execution = runtimeService.createExecutionQuery().activityId("task1").singleResult();
    assertFalse(processInstanceId.equals(((ExecutionEntity) task2Execution).getParentId()));
    assertTrue(((ExecutionEntity) task1Execution).getParentId().equals(((ExecutionEntity) task2Execution).getParentId()));
    assertEquals(0, runtimeService.createEventSubscriptionQuery().count());
    taskService.complete(task1.getId());
    taskService.complete(task2.getId());
    assertProcessEnded(processInstanceId);
}
Also used : Task(org.camunda.bpm.engine.task.Task) Execution(org.camunda.bpm.engine.runtime.Execution) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 67 with ExecutionEntity

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

the class MessageNonInterruptingBoundaryEventTest method testNestedEventsAnotherExecutionOrder.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/message/MessageNonInterruptingBoundaryEventTest.testNestedEvents.bpmn20.xml" })
public void testNestedEventsAnotherExecutionOrder() {
    // given
    String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
    // when (1)
    runtimeService.correlateMessage("secondMessage");
    // then (1)
    assertEquals(1, taskService.createTaskQuery().count());
    Task task1 = taskService.createTaskQuery().taskDefinitionKey("task1").singleResult();
    assertNotNull(task1);
    Execution task1Execution = runtimeService.createExecutionQuery().activityId("task1").singleResult();
    assertNotNull(task1Execution);
    assertEquals(processInstanceId, ((ExecutionEntity) task1Execution).getParentId());
    // when (2)
    runtimeService.correlateMessage("firstMessage");
    // then (2)
    assertEquals(2, taskService.createTaskQuery().count());
    Task innerTask = taskService.createTaskQuery().taskDefinitionKey("innerTask").singleResult();
    assertNotNull(innerTask);
    Execution innerTaskExecution = runtimeService.createExecutionQuery().activityId("innerTask").singleResult();
    assertFalse(processInstanceId.equals(((ExecutionEntity) innerTaskExecution).getParentId()));
    task1 = taskService.createTaskQuery().taskDefinitionKey("task1").singleResult();
    assertNotNull(task1);
    task1Execution = runtimeService.createExecutionQuery().activityId("task1").singleResult();
    assertNotNull(task1Execution);
    assertEquals(processInstanceId, ((ExecutionEntity) task1Execution).getParentId());
    // when (3)
    runtimeService.correlateMessage("thirdMessage");
    // then (3)
    assertEquals(2, taskService.createTaskQuery().count());
    task1 = taskService.createTaskQuery().taskDefinitionKey("task1").singleResult();
    assertNotNull(task1);
    task1Execution = runtimeService.createExecutionQuery().activityId("task1").singleResult();
    assertNotNull(task1Execution);
    assertEquals(processInstanceId, ((ExecutionEntity) task1Execution).getParentId());
    Task task2 = taskService.createTaskQuery().taskDefinitionKey("task2").singleResult();
    assertNotNull(task2);
    Execution task2Execution = runtimeService.createExecutionQuery().activityId("task2").singleResult();
    assertNotNull(task2Execution);
    assertEquals(processInstanceId, ((ExecutionEntity) task2Execution).getParentId());
    assertEquals(0, runtimeService.createEventSubscriptionQuery().count());
    taskService.complete(task1.getId());
    taskService.complete(task2.getId());
    assertProcessEnded(processInstanceId);
}
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) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 68 with ExecutionEntity

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

the class ExecutionTreeProcessDefinitionIdAssertion method matches.

/**
 * returns umatched executions in the tree
 */
protected List<Execution> matches(ExecutionTree tree) {
    ExecutionEntity executionEntity = (ExecutionEntity) tree.getExecution();
    List<Execution> unmatchedExecutions = new ArrayList<Execution>();
    if (!expectedProcessDefinitionId.equals(executionEntity.getProcessDefinitionId())) {
        unmatchedExecutions.add(tree.getExecution());
    }
    for (ExecutionTree child : tree.getExecutions()) {
        unmatchedExecutions.addAll(matches(child));
    }
    return unmatchedExecutions;
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ArrayList(java.util.ArrayList)

Example 69 with ExecutionEntity

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

the class ExecutionTree method forExecution.

public static ExecutionTree forExecution(final String executionId, ProcessEngine processEngine) {
    ProcessEngineConfigurationImpl configuration = (ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration();
    CommandExecutor commandExecutor = configuration.getCommandExecutorTxRequired();
    ExecutionTree executionTree = commandExecutor.execute(new Command<ExecutionTree>() {

        public ExecutionTree execute(CommandContext commandContext) {
            ExecutionEntity execution = commandContext.getExecutionManager().findExecutionById(executionId);
            return ExecutionTree.forExecution(execution);
        }
    });
    return executionTree;
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 70 with ExecutionEntity

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

the class ProcessTaskTest method testCallProcessAsConstant.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCase.cmmn", "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testCallProcessAsConstant() {
    // given
    String caseInstanceId = createCaseInstanceByKey(ONE_PROCESS_TASK_CASE).getId();
    String processTaskId = queryCaseExecutionByActivityId(PROCESS_TASK).getId();
    // then
    // there exists a process instance
    ExecutionEntity processInstance = (ExecutionEntity) queryProcessInstance();
    assertNotNull(processInstance);
    // the case instance id is set on called process instance
    assertEquals(caseInstanceId, processInstance.getCaseInstanceId());
    // the super case execution id is equals the processTaskId
    assertEquals(processTaskId, processInstance.getSuperCaseExecutionId());
    TaskEntity task = (TaskEntity) queryTask();
    // the case instance id has been also set on the task
    assertEquals(caseInstanceId, task.getCaseInstanceId());
    // the case execution id should be null
    assertNull(task.getCaseExecutionId());
    // complete ////////////////////////////////////////////////////////
    taskService.complete(task.getId());
    assertProcessEnded(processInstance.getId());
    close(caseInstanceId);
    assertCaseEnded(caseInstanceId);
}
Also used : TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) 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