use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationEventTest method testStartBeforNoneStartEvent.
@Deployment(resources = ONE_TASK_PROCESS)
public void testStartBeforNoneStartEvent() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
String processInstanceId = processInstance.getId();
// when I start before the none start event
runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("theStart").execute();
// then there are two instances of "task"
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("theTask").activity("theTask").done());
ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child("theTask").concurrent().noScope().up().child("theTask").concurrent().noScope().done());
// and the process can be ended as usual
List<Task> tasks = taskService.createTaskQuery().list();
assertEquals(2, tasks.size());
for (Task task : tasks) {
taskService.complete(task.getId());
}
assertProcessEnded(processInstanceId);
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationEventTest method testStartBeforeCancelEndEvent.
@Deployment(resources = CANCEL_END_EVENT_PROCESS)
public void testStartBeforeCancelEndEvent() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
String processInstanceId = processInstance.getId();
// complete the transaction subprocess once
Task txTask = taskService.createTaskQuery().singleResult();
assertEquals("txTask", txTask.getTaskDefinitionKey());
taskService.complete(txTask.getId(), Variables.createVariables().putValue("success", true));
Task afterSuccessTask = taskService.createTaskQuery().singleResult();
assertEquals("afterSuccess", afterSuccessTask.getTaskDefinitionKey());
// when I start before the cancel end event
runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("cancelEnd").execute();
// then a new subprocess instance is created and immediately cancelled
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("afterCancellation").activity("afterSuccess").done());
ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child("afterCancellation").concurrent().noScope().up().child("afterSuccess").concurrent().noScope().up().child("tx").scope().eventScope().done());
// the compensation for the completed tx has not been triggered
assertEquals(0, taskService.createTaskQuery().taskDefinitionKey("undoTxTask").count());
// complete the process
Task afterCancellationTask = taskService.createTaskQuery().taskDefinitionKey("afterCancellation").singleResult();
assertNotNull(afterCancellationTask);
taskService.complete(afterCancellationTask.getId());
taskService.complete(afterSuccessTask.getId());
assertProcessEnded(processInstanceId);
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationEventTest method testStartBeforeIntermediateCatchEvent.
@Deployment(resources = INTERMEDIATE_TIMER_CATCH_PROCESS)
public void testStartBeforeIntermediateCatchEvent() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
String processInstanceId = processInstance.getId();
runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("intermediateCatchEvent").execute();
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("task").activity("intermediateCatchEvent").done());
ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child("task").concurrent().noScope().up().child(null).concurrent().noScope().child("intermediateCatchEvent").scope().done());
ActivityInstance catchEventInstance = getChildInstanceForActivity(updatedTree, "intermediateCatchEvent");
// and there is a timer job
Job job = managementService.createJobQuery().singleResult();
assertNotNull(job);
assertEquals(catchEventInstance.getExecutionIds()[0], job.getExecutionId());
completeTasksInOrder("task");
executeAvailableJobs();
assertProcessEnded(processInstanceId);
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationEventTest method testStartBeforeMessageStartEvent.
@Deployment(resources = MESSAGE_START_EVENT_PROCESS)
public void testStartBeforeMessageStartEvent() {
runtimeService.correlateMessage("startMessage");
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertNotNull(processInstance);
EventSubscription startEventSubscription = runtimeService.createEventSubscriptionQuery().singleResult();
assertNotNull(startEventSubscription);
String processInstanceId = processInstance.getId();
// when I start before the message start event
runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("theStart").execute();
// then there are two instances of "task"
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("task").activity("task").done());
ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child("task").concurrent().noScope().up().child("task").concurrent().noScope().done());
// and there is only the message start event subscription
EventSubscription subscription = runtimeService.createEventSubscriptionQuery().singleResult();
assertNotNull(subscription);
assertEquals(startEventSubscription.getId(), subscription.getId());
completeTasksInOrder("task", "task");
assertProcessEnded(processInstanceId);
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationMultiInstanceTest method testStartBeforeMultiInstanceBodyParallelTasks.
@Deployment(resources = PARALLEL_MULTI_INSTANCE_TASK_PROCESS)
public void testStartBeforeMultiInstanceBodyParallelTasks() {
// given
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miParallelUserTasks");
completeTasksInOrder("beforeTask");
// when
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("miTasks#multiInstanceBody").execute();
// then
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginMiBody("miTasks").activity("miTasks").activity("miTasks").activity("miTasks").endScope().beginMiBody("miTasks").activity("miTasks").activity("miTasks").activity("miTasks").done());
ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.getId(), processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).concurrent().noScope().child(null).scope().child("miTasks").concurrent().noScope().up().child("miTasks").concurrent().noScope().up().child("miTasks").concurrent().noScope().up().up().up().child(null).concurrent().noScope().child(null).scope().child("miTasks").concurrent().noScope().up().child("miTasks").concurrent().noScope().up().child("miTasks").concurrent().noScope().up().done());
// and the process is able to complete successfully
completeTasksInOrder("miTasks", "miTasks", "miTasks", "miTasks", "miTasks", "miTasks", "afterTask", "afterTask");
assertProcessEnded(processInstance.getId());
}
Aggregations