use of org.camunda.bpm.engine.task.Task 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.task.Task 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.task.Task 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());
}
use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationTest method testStartBeforeEventSubscription.
@Deployment(resources = SUBPROCESS_BOUNDARY_EVENTS_PROCESS)
public void testStartBeforeEventSubscription() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("subprocess");
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("innerTask").execute();
// then two timer jobs should have been created
assertEquals(2, managementService.createJobQuery().count());
Job innerJob = managementService.createJobQuery().activityId("innerTimer").singleResult();
assertNotNull(innerJob);
assertEquals(runtimeService.createExecutionQuery().activityId("innerTask").singleResult().getId(), innerJob.getExecutionId());
Job outerJob = managementService.createJobQuery().activityId("outerTimer").singleResult();
assertNotNull(outerJob);
// when executing the jobs
managementService.executeJob(innerJob.getId());
Task innerBoundaryTask = taskService.createTaskQuery().taskDefinitionKey("innerAfterBoundaryTask").singleResult();
assertNotNull(innerBoundaryTask);
managementService.executeJob(outerJob.getId());
Task outerBoundaryTask = taskService.createTaskQuery().taskDefinitionKey("outerAfterBoundaryTask").singleResult();
assertNotNull(outerBoundaryTask);
}
use of org.camunda.bpm.engine.task.Task 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());
}
Aggregations