use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationTest method testStartActivityAndCancelCompensatingTask.
@Deployment(resources = TRANSACTION_WITH_COMPENSATION_PROCESS)
public void testStartActivityAndCancelCompensatingTask() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
completeTasksInOrder("userTask");
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("userTask").cancelActivityInstance(getInstanceIdForActivity(tree, "undoTask")).execute();
tree = runtimeService.getActivityInstance(processInstance.getId());
assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginScope("tx").activity("userTask").done());
completeTasksInOrder("userTask", "undoTask", "afterCancel");
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationTest method testCancellationWithWrongProcessInstanceId.
@Deployment(resources = PARALLEL_GATEWAY_PROCESS)
public void testCancellationWithWrongProcessInstanceId() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("parallelGateway");
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
try {
runtimeService.createProcessInstanceModification("foo").cancelActivityInstance(getInstanceIdForActivity(tree, "task1")).cancelActivityInstance(getInstanceIdForActivity(tree, "task2")).execute();
assertProcessEnded(processInstance.getId());
} catch (ProcessEngineException e) {
assertThat(e.getMessage(), startsWith("ENGINE-13036"));
assertThat(e.getMessage(), containsString("Process instance '" + "foo" + "' cannot be modified"));
}
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationTest method testStartAdditionalCompensatingTaskAndCompleteOldCompensationTask.
@Deployment(resources = TRANSACTION_WITH_COMPENSATION_PROCESS)
public void testStartAdditionalCompensatingTaskAndCompleteOldCompensationTask() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
completeTasksInOrder("userTask");
Task firstUndoTask = taskService.createTaskQuery().singleResult();
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("undoTask").execute();
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginScope("tx").activity("txEnd").activity("undoTask").activity("undoTask").done());
taskService.complete(firstUndoTask.getId());
Task secondUndoTask = taskService.createTaskQuery().taskDefinitionKey("undoTask").singleResult();
assertNull(secondUndoTask);
completeTasksInOrder("afterCancel");
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationTest method testStartActivityInTransactionWithCompensation.
@Deployment(resources = TRANSACTION_WITH_COMPENSATION_PROCESS)
public void testStartActivityInTransactionWithCompensation() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
completeTasksInOrder("userTask");
Task task = taskService.createTaskQuery().singleResult();
assertEquals("undoTask", task.getTaskDefinitionKey());
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginScope("tx").activity("txEnd").activity("undoTask").done());
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("userTask").execute();
tree = runtimeService.getActivityInstance(processInstance.getId());
assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginScope("tx").activity("txEnd").activity("undoTask").activity("userTask").done());
completeTasksInOrder("userTask");
tree = runtimeService.getActivityInstance(processInstance.getId());
assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginScope("tx").activity("txEnd").activity("undoTask").done());
Task newTask = taskService.createTaskQuery().singleResult();
assertNotSame(task.getId(), newTask.getId());
completeTasksInOrder("undoTask", "afterCancel");
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationTest method testNoCompensationCreatedOnCancellation.
@Deployment
public void testNoCompensationCreatedOnCancellation() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("compensationProcess");
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
// one on outerTask, one on innerTask
assertEquals(2, taskService.createTaskQuery().count());
// when inner task is cancelled
runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(getInstanceIdForActivity(tree, "innerTask")).execute();
// then no compensation event subscription exists
assertEquals(0, runtimeService.createEventSubscriptionQuery().count());
// and the compensation throw event does not trigger compensation handlers
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
assertEquals("outerTask", task.getTaskDefinitionKey());
taskService.complete(task.getId());
assertProcessEnded(processInstance.getId());
}
Aggregations