use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class BoundaryConditionalEventTest method testParallelSetVariableOnExecutionCondition.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/conditional/BoundaryConditionalEventTest.testParallelVariableCondition.bpmn20.xml" })
public void testParallelSetVariableOnExecutionCondition() {
// given process with parallel user tasks and boundary conditional event
ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
List<Task> tasks = taskQuery.list();
assertEquals(2, tasks.size());
// when variable is set on execution
// taskService.setVariable(task.getId(), VARIABLE_NAME, 1);
runtimeService.setVariable(procInst.getId(), VARIABLE_NAME, 1);
// then both boundary events are triggered and process instance ends
List<Execution> executions = runtimeService.createExecutionQuery().processInstanceId(procInst.getId()).list();
assertEquals(0, executions.size());
tasksAfterVariableIsSet = taskQuery.list();
assertEquals(0, tasksAfterVariableIsSet.size());
}
use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class BoundaryConditionalEventTest method testVariableSetOnExecutionCondition.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/conditional/BoundaryConditionalEventTest.testVariableCondition.bpmn20.xml" })
public void testVariableSetOnExecutionCondition() {
// given process with boundary conditional event
ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
Task task = taskQuery.singleResult();
assertNotNull(task);
assertEquals(TASK_WITH_CONDITION, task.getName());
// when variable is set on task execution
taskService.setVariable(task.getId(), VARIABLE_NAME, 1);
// then execution ends
Execution execution = runtimeService.createExecutionQuery().processInstanceId(procInst.getId()).activityId(TASK_WITH_CONDITION_ID).singleResult();
assertNull(execution);
// and execution is at user task after boundary event
tasksAfterVariableIsSet = taskQuery.list();
assertEquals(TASK_AFTER_CONDITION, tasksAfterVariableIsSet.get(0).getName());
}
use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class CaseCallActivityTest method testCompleteCase.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testCompleteCase.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCompleteCase() {
// given
String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY).getId();
String subCaseInstanceId = queryOneTaskCaseInstance().getId();
String humanTaskId = queryCaseExecutionByActivityId(HUMAN_TASK_ID).getId();
// when
complete(humanTaskId);
// then
Task userTask = queryTaskByActivityId(USER_TASK_ID);
assertNotNull(userTask);
Execution callActivity = queryExecutionByActivityId(CALL_ACTIVITY_ID);
assertNull(callActivity);
// complete ////////////////////////////////////////////////////////
close(subCaseInstanceId);
assertCaseEnded(subCaseInstanceId);
taskService.complete(userTask.getId());
assertCaseEnded(superProcessInstanceId);
}
use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class CaseCallActivityTest method testSuspendSubCaseInstance.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testCallCaseAsConstant.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn" })
public void testSuspendSubCaseInstance() {
// given
String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY).getId();
String subCaseInstanceId = queryOneTaskCaseInstance().getId();
// when
suspend(subCaseInstanceId);
// then
CmmnExecution subCaseInstance = (CmmnExecution) queryOneTaskCaseInstance();
assertNotNull(subCaseInstance);
assertTrue(subCaseInstance.isSuspended());
Execution callActivity = queryExecutionByActivityId(CALL_ACTIVITY_ID);
assertNotNull(callActivity);
// complete ////////////////////////////////////////////////////////
close(subCaseInstanceId);
assertCaseEnded(subCaseInstanceId);
runtimeService.deleteProcessInstance(superProcessInstanceId, null);
}
use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class CaseCallActivityTest method testTerminateSubCaseInstance.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testCallCaseAsConstant.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testTerminateSubCaseInstance() {
// given
String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY).getId();
String subCaseInstanceId = queryOneTaskCaseInstance().getId();
// when
terminate(subCaseInstanceId);
// then
CmmnExecution subCaseInstance = (CmmnExecution) queryOneTaskCaseInstance();
assertNotNull(subCaseInstance);
assertTrue(subCaseInstance.isTerminated());
Execution callActivity = queryExecutionByActivityId(CALL_ACTIVITY_ID);
assertNotNull(callActivity);
// complete ////////////////////////////////////////////////////////
close(subCaseInstanceId);
assertCaseEnded(subCaseInstanceId);
runtimeService.deleteProcessInstance(superProcessInstanceId, null);
}
Aggregations