Search in sources :

Example 66 with ActivityInstance

use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.

the class CompensateEventHistoryTest method testDefaultCompensationHandlerHistoryActivityInstance.

@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/compensate/CompensateEventHistoryTest.testDefaultCompensationHandlerHistory.bpmn20.xml")
public void testDefaultCompensationHandlerHistoryActivityInstance() {
    // given a process instance
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("defaultHandlerProcess");
    // when throwing compensation
    Task beforeCompensationTask = taskService.createTaskQuery().singleResult();
    taskService.complete(beforeCompensationTask.getId());
    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    String compensationHandlerActivityInstanceId = tree.getActivityInstances("compensationHandler")[0].getId();
    String subProcessActivityInstanceId = tree.getActivityInstances("subProcess")[0].getId();
    // .. and completing compensation
    Task compensationHandler = taskService.createTaskQuery().singleResult();
    taskService.complete(compensationHandler.getId());
    // then there is a historic activity instance for the compensation handler
    HistoricActivityInstance historicCompensationHandlerInstance = historyService.createHistoricActivityInstanceQuery().activityId("compensationHandler").singleResult();
    assertNotNull(historicCompensationHandlerInstance);
    assertEquals(compensationHandlerActivityInstanceId, historicCompensationHandlerInstance.getId());
    assertEquals(subProcessActivityInstanceId, historicCompensationHandlerInstance.getParentActivityInstanceId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 67 with ActivityInstance

use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.

the class CompensateEventHistoryTest method FAILING_testDefaultCompensationHandlerHistoryVariableInstance.

/**
 * Fix CAM-4351
 */
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/compensate/CompensateEventHistoryTest.testDefaultCompensationHandlerHistory.bpmn20.xml")
public void FAILING_testDefaultCompensationHandlerHistoryVariableInstance() {
    // given a process instance
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("defaultHandlerProcess");
    // when throwing compensation
    Task beforeCompensationTask = taskService.createTaskQuery().singleResult();
    taskService.complete(beforeCompensationTask.getId());
    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    String compensationHandlerActivityInstanceId = tree.getActivityInstances("compensationHandler")[0].getId();
    // .. setting a variable via task service API
    Task compensationHandler = taskService.createTaskQuery().singleResult();
    runtimeService.setVariableLocal(compensationHandler.getExecutionId(), "apiVariable", "someValue");
    // .. and completing compensation
    taskService.complete(compensationHandler.getId());
    // then there is a historic variable instance for the variable set by API
    HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().singleResult();
    assertNotNull(historicVariableInstance);
    assertEquals(compensationHandlerActivityInstanceId, historicVariableInstance.getActivityInstanceId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 68 with ActivityInstance

use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.

the class CompensateEventTest method testCompensateParallelSubprocessCompHandlerWaitstate.

@Deployment
public void testCompensateParallelSubprocessCompHandlerWaitstate() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("compensateProcess");
    List<Task> compensationHandlerTasks = taskService.createTaskQuery().taskDefinitionKey("undoBookHotel").list();
    assertEquals(5, compensationHandlerTasks.size());
    ActivityInstance rootActivityInstance = runtimeService.getActivityInstance(processInstance.getId());
    List<ActivityInstance> compensationHandlerInstances = getInstancesForActivityId(rootActivityInstance, "undoBookHotel");
    assertEquals(5, compensationHandlerInstances.size());
    for (Task task : compensationHandlerTasks) {
        taskService.complete(task.getId());
    }
    Task singleResult = taskService.createTaskQuery().singleResult();
    taskService.complete(singleResult.getId());
    runtimeService.signal(processInstance.getId());
    assertProcessEnded(processInstance.getId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 69 with ActivityInstance

use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.

the class CompensateEventTest method FAILING_testSubprocessCompensationHandlerWithEventSubprocessActivityInstanceTree.

/**
 * CAM-4387
 */
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/compensate/CompensateEventTest.testSubprocessCompensationHandlerWithEventSubprocess.bpmn20.xml")
public void FAILING_testSubprocessCompensationHandlerWithEventSubprocessActivityInstanceTree() {
    // given a process instance in compensation
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("subProcessCompensationHandlerWithEventSubprocess");
    Task beforeCompensationTask = taskService.createTaskQuery().singleResult();
    taskService.complete(beforeCompensationTask.getId());
    // when the event subprocess is triggered that is defined as part of the compensation handler
    runtimeService.correlateMessage("Message");
    // then the event subprocess has been triggered
    ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
    assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("throwCompensate").beginScope("compensationHandler").beginScope("eventSubProcess").activity("eventSubProcessTask").done());
}
Also used : Task(org.camunda.bpm.engine.task.Task) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 70 with ActivityInstance

use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.

the class CompensateEventTest method testActivityInstanceTreeWithoutEventScope.

@Deployment
public void testActivityInstanceTreeWithoutEventScope() {
    // given
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("process");
    String processInstanceId = instance.getId();
    // when
    String taskId = taskService.createTaskQuery().singleResult().getId();
    taskService.complete(taskId);
    // then
    ActivityInstance tree = runtimeService.getActivityInstance(processInstanceId);
    assertThat(tree).hasStructure(describeActivityInstanceTree(instance.getProcessDefinitionId()).activity("task").done());
}
Also used : ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) 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