Search in sources :

Example 86 with Task

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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 87 with Task

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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 88 with Task

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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 89 with Task

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);
}
Also used : Task(org.camunda.bpm.engine.task.Task) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Job(org.camunda.bpm.engine.runtime.Job) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 90 with Task

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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

Task (org.camunda.bpm.engine.task.Task)1654 Deployment (org.camunda.bpm.engine.test.Deployment)788 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)660 Test (org.junit.Test)648 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)230 ScenarioUnderTest (org.camunda.bpm.qa.upgrade.ScenarioUnderTest)190 HashMap (java.util.HashMap)140 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)139 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)108 Execution (org.camunda.bpm.engine.runtime.Execution)99 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)98 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)87 Job (org.camunda.bpm.engine.runtime.Job)71 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)67 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)52 DescribesScenario (org.camunda.bpm.qa.upgrade.DescribesScenario)46 ScenarioSetup (org.camunda.bpm.qa.upgrade.ScenarioSetup)46 Times (org.camunda.bpm.qa.upgrade.Times)46 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)45 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)45