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