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