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());
}
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());
}
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());
}
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());
}
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);
}
Aggregations