Search in sources :

Example 61 with Execution

use of org.camunda.bpm.engine.runtime.Execution 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 62 with Execution

use of org.camunda.bpm.engine.runtime.Execution 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 63 with Execution

use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.

the class ExecutionVariablesTest method testForkWithThreeBranchesAndJoinOfTwoBranchesParallelGateway.

@Deployment
public void testForkWithThreeBranchesAndJoinOfTwoBranchesParallelGateway() {
    // given
    runtimeService.startProcessInstanceByKey("process");
    Execution task2Execution = runtimeService.createExecutionQuery().activityId("task2").singleResult();
    // when
    runtimeService.setVariableLocal(task2Execution.getId(), "foo", "bar");
    taskService.complete(taskService.createTaskQuery().taskDefinitionKey("task1").singleResult().getId());
    taskService.complete(taskService.createTaskQuery().taskDefinitionKey("task2").singleResult().getId());
    // then
    assertEquals(0, runtimeService.createVariableInstanceQuery().count());
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 64 with Execution

use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.

the class ExecutionVariablesTest method testStableVariableInstanceIdsOnCompactionAndExpansion.

@Deployment(resources = "org/camunda/bpm/engine/test/api/variables/ExecutionVariablesTest.testTreeCompactionForkParallelGateway.bpmn20.xml")
public void testStableVariableInstanceIdsOnCompactionAndExpansion() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
    Execution task1Execution = runtimeService.createExecutionQuery().activityId("task1").singleResult();
    Task task2 = taskService.createTaskQuery().taskDefinitionKey("task2").singleResult();
    // when
    runtimeService.setVariableLocal(task1Execution.getId(), "foo", "bar");
    VariableInstance variableBeforeCompaction = runtimeService.createVariableInstanceQuery().singleResult();
    // compacting the tree
    taskService.complete(task2.getId());
    // expanding the tree
    runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("task2").execute();
    // 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) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 65 with Execution

use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.

the class SetProcessDefinitionVersionCmdTest method testSetProcessDefinitionVersionActivityMissing.

@Deployment(resources = { TEST_PROCESS })
public void testSetProcessDefinitionVersionActivityMissing() {
    // start process instance
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("receiveTask");
    // check that receive task has been reached
    Execution execution = runtimeService.createExecutionQuery().activityId("waitState1").singleResult();
    assertNotNull(execution);
    // deploy new version of the process definition
    org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource(TEST_PROCESS_ACTIVITY_MISSING).deploy();
    assertEquals(2, repositoryService.createProcessDefinitionQuery().count());
    // migrate process instance to new process definition version
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    SetProcessDefinitionVersionCmd setProcessDefinitionVersionCmd = new SetProcessDefinitionVersionCmd(pi.getId(), 2);
    try {
        commandExecutor.execute(setProcessDefinitionVersionCmd);
        fail("ProcessEngineException expected");
    } catch (ProcessEngineException ae) {
        assertTextPresent("The new process definition (key = 'receiveTask') does not contain the current activity (id = 'waitState1') of the process instance (id = '", ae.getMessage());
    }
    // undeploy "manually" deployed process definition
    repositoryService.deleteDeployment(deployment.getId(), true);
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) SetProcessDefinitionVersionCmd(org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) 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