use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationTest method testCancelCompensatingTaskAndStartActivity.
@Deployment(resources = TRANSACTION_WITH_COMPENSATION_PROCESS)
public void testCancelCompensatingTaskAndStartActivity() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
completeTasksInOrder("userTask");
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(getInstanceIdForActivity(tree, "undoTask")).startBeforeActivity("userTask").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 testCancelCompensatingTask.
@Deployment(resources = TRANSACTION_WITH_COMPENSATION_PROCESS)
public void testCancelCompensatingTask() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
completeTasksInOrder("userTask");
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(getInstanceIdForActivity(tree, "undoTask")).execute();
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationTest method testStartAdditionalCompensatingTaskAndCompleteNewCompensatingTask.
@Deployment(resources = TRANSACTION_WITH_COMPENSATION_PROCESS)
public void testStartAdditionalCompensatingTaskAndCompleteNewCompensatingTask() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
completeTasksInOrder("userTask");
Task firstUndoTask = taskService.createTaskQuery().taskDefinitionKey("undoTask").singleResult();
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("undoTask").setVariableLocal("new", true).execute();
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginScope("tx").activity("txEnd").activity("undoTask").activity("undoTask").done());
String taskExecutionId = runtimeService.createExecutionQuery().variableValueEquals("new", true).singleResult().getId();
Task secondUndoTask = taskService.createTaskQuery().executionId(taskExecutionId).singleResult();
assertNotNull(secondUndoTask);
assertNotSame(firstUndoTask.getId(), secondUndoTask.getId());
taskService.complete(secondUndoTask.getId());
tree = runtimeService.getActivityInstance(processInstance.getId());
assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginScope("tx").activity("txEnd").activity("undoTask").done());
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 testStartTransitionWithInvalidAncestorInstanceId.
@Deployment(resources = DOUBLE_NESTED_SUB_PROCESS)
public void testStartTransitionWithInvalidAncestorInstanceId() {
// given two instances of the outer subprocess
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("doubleNestedSubprocess");
String processInstanceId = processInstance.getId();
try {
runtimeService.createProcessInstanceModification(processInstance.getId()).startTransition("flow5", "noValidActivityInstanceId").execute();
fail();
} catch (NotValidException e) {
// happy path
assertTextPresent("Cannot perform instruction: " + "Start transition 'flow5' with ancestor activity instance 'noValidActivityInstanceId'; " + "Ancestor activity instance 'noValidActivityInstanceId' does not exist", e.getMessage());
}
try {
runtimeService.createProcessInstanceModification(processInstance.getId()).startTransition("flow5", null).execute();
fail();
} catch (NotValidException e) {
// happy path
assertTextPresent("ancestorActivityInstanceId is null", e.getMessage());
}
ActivityInstance tree = runtimeService.getActivityInstance(processInstanceId);
String subProcessTaskId = getInstanceIdForActivity(tree, "subProcessTask");
try {
runtimeService.createProcessInstanceModification(processInstance.getId()).startTransition("flow5", subProcessTaskId).execute();
fail("should not succeed because subProcessTask is a child of subProcess");
} catch (NotValidException e) {
// happy path
assertTextPresent("Cannot perform instruction: " + "Start transition 'flow5' with ancestor activity instance '" + subProcessTaskId + "'; " + "Scope execution for '" + subProcessTaskId + "' cannot be found in parent hierarchy of flow element 'flow5'", e.getMessage());
}
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationTest method testCancelCompensatingTaskAndStartActivityWithAncestor.
@Deployment(resources = TRANSACTION_WITH_COMPENSATION_PROCESS)
public void testCancelCompensatingTaskAndStartActivityWithAncestor() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
completeTasksInOrder("userTask");
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(getInstanceIdForActivity(tree, "undoTask")).startBeforeActivity("userTask", processInstance.getId()).execute();
tree = runtimeService.getActivityInstance(processInstance.getId());
assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginScope("tx").activity("userTask").done());
completeTasksInOrder("userTask", "undoTask", "afterCancel");
assertProcessEnded(processInstance.getId());
}
Aggregations