Search in sources :

Example 21 with ActivityInstance

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

Example 22 with ActivityInstance

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

Example 23 with ActivityInstance

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());
}
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)

Example 24 with ActivityInstance

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());
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) 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)

Example 25 with ActivityInstance

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

Aggregations

ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)427 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)372 Deployment (org.camunda.bpm.engine.test.Deployment)277 Test (org.junit.Test)159 ExecutionTree (org.camunda.bpm.engine.test.util.ExecutionTree)130 ExecutionAssert.describeExecutionTree (org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree)129 Task (org.camunda.bpm.engine.task.Task)108 ScenarioUnderTest (org.camunda.bpm.qa.upgrade.ScenarioUnderTest)80 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)56 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)54 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)47 TransitionInstance (org.camunda.bpm.engine.runtime.TransitionInstance)31 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)22 Job (org.camunda.bpm.engine.runtime.Job)21 Batch (org.camunda.bpm.engine.batch.Batch)15 DeploymentWithDefinitions (org.camunda.bpm.engine.repository.DeploymentWithDefinitions)12 Execution (org.camunda.bpm.engine.runtime.Execution)12 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)10 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)10 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)9