use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class CompensateEventHistoryTest method testBoundaryCompensationHandlerHistoryActivityInstance.
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/compensate/CompensateEventHistoryTest.testBoundaryCompensationHandlerHistory.bpmn20.xml")
public void testBoundaryCompensationHandlerHistoryActivityInstance() {
// given a process instance
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("boundaryHandlerProcess");
// when throwing compensation
Task beforeCompensationTask = taskService.createTaskQuery().singleResult();
taskService.complete(beforeCompensationTask.getId());
String compensationHandlerActivityInstanceId = runtimeService.getActivityInstance(processInstance.getId()).getActivityInstances("compensationHandler")[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(processInstance.getId(), historicCompensationHandlerInstance.getParentActivityInstanceId());
}
use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class CompensateEventOrderTest method testTwoCompensateEventsInReverseOrder.
@Test
public void testTwoCompensateEventsInReverseOrder() {
// given
BpmnModelInstance model = Bpmn.createExecutableProcess("Process_1").startEvent().serviceTask("serviceTask1").camundaClass(IncreaseCurrentTimeServiceTask.class.getName()).boundaryEvent("compensationBoundary1").compensateEventDefinition().compensateEventDefinitionDone().moveToActivity("serviceTask1").serviceTask("serviceTask2").camundaClass(IncreaseCurrentTimeServiceTask.class.getName()).boundaryEvent("compensationBoundary2").compensateEventDefinition().compensateEventDefinitionDone().moveToActivity("serviceTask2").intermediateThrowEvent("compensationEvent").compensateEventDefinition().waitForCompletion(true).compensateEventDefinitionDone().endEvent().done();
addServiceTaskCompensationHandler(model, "compensationBoundary1", "A");
addServiceTaskCompensationHandler(model, "compensationBoundary2", "B");
testHelper.deploy(model);
// when
engineRule.getRuntimeService().startProcessInstanceByKey("Process_1", Variables.createVariables().putValue("currentTime", new Date()));
// then compensation activities are executed in the reverse order
List<HistoricActivityInstance> list = engineRule.getHistoryService().createHistoricActivityInstanceQuery().orderByHistoricActivityInstanceEndTime().asc().list();
long indexA = searchForActivityIndex(list, "A");
long indexB = searchForActivityIndex(list, "B");
assertNotEquals(-1, indexA);
assertNotEquals(-1, indexB);
assertTrue("Compensation activities were executed in wrong order.", indexA > indexB);
}
use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class LinkEventTest method testEventLinkMultipleSources.
@Deployment
public void testEventLinkMultipleSources() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("linkEventValid");
List<String> activeActivities = runtimeService.getActiveActivityIds(pi.getId());
// assert that the link event was triggered and that we are
assertEquals(Arrays.asList(new String[] { "WaitAfterLink", "WaitAfterLink" }), activeActivities);
runtimeService.deleteProcessInstance(pi.getId(), "test done");
// validate history
if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_ACTIVITY) {
List<HistoricActivityInstance> activities = historyService.createHistoricActivityInstanceQuery().processInstanceId(pi.getId()).orderByActivityId().asc().list();
assertEquals(5, activities.size());
assertEquals("ManualTask_1", activities.get(0).getActivityId());
assertEquals("ParallelGateway_1", activities.get(1).getActivityId());
assertEquals("StartEvent_1", activities.get(2).getActivityId());
assertEquals("WaitAfterLink", activities.get(3).getActivityId());
assertEquals("WaitAfterLink", activities.get(4).getActivityId());
}
}
use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class LinkEventTest method testValidEventLink.
@Deployment
public void testValidEventLink() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("linkEventValid");
List<String> activeActivities = runtimeService.getActiveActivityIds(pi.getId());
// assert that now the first receive task is active
assertEquals(Arrays.asList(new String[] { "waitAfterLink1" }), activeActivities);
runtimeService.signal(pi.getId());
activeActivities = runtimeService.getActiveActivityIds(pi.getId());
// assert that now the second receive task is active
assertEquals(Arrays.asList(new String[] { "waitAfterLink2" }), activeActivities);
runtimeService.signal(pi.getId());
assertProcessEnded(pi.getId());
// validate history
if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_ACTIVITY) {
List<HistoricActivityInstance> activities = historyService.createHistoricActivityInstanceQuery().processInstanceId(pi.getId()).orderByActivityId().asc().list();
assertEquals(4, activities.size());
assertEquals("EndEvent_1", activities.get(0).getActivityId());
assertEquals("StartEvent_1", activities.get(1).getActivityId());
assertEquals("waitAfterLink1", activities.get(2).getActivityId());
assertEquals("waitAfterLink2", activities.get(3).getActivityId());
}
}
use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class MultiInstanceTest method testParallelUserTasksHistory.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.testParallelUserTasks.bpmn20.xml" })
public void testParallelUserTasksHistory() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("miParallelUserTasks");
for (Task task : taskService.createTaskQuery().list()) {
taskService.complete(task.getId());
}
// Validate history
if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().orderByTaskAssignee().asc().list();
for (int i = 0; i < historicTaskInstances.size(); i++) {
HistoricTaskInstance hi = historicTaskInstances.get(i);
assertNotNull(hi.getStartTime());
assertNotNull(hi.getEndTime());
assertEquals("kermit_" + i, hi.getAssignee());
}
HistoricActivityInstance multiInstanceBodyInstance = historyService.createHistoricActivityInstanceQuery().activityId("miTasks#multiInstanceBody").singleResult();
assertNotNull(multiInstanceBodyInstance);
assertEquals(pi.getId(), multiInstanceBodyInstance.getParentActivityInstanceId());
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityType("userTask").list();
assertEquals(3, historicActivityInstances.size());
for (HistoricActivityInstance hai : historicActivityInstances) {
assertNotNull(hai.getStartTime());
assertNotNull(hai.getEndTime());
assertNotNull(hai.getAssignee());
assertEquals("userTask", hai.getActivityType());
assertEquals(multiInstanceBodyInstance.getId(), hai.getParentActivityInstanceId());
assertNotNull(hai.getTaskId());
}
}
}
Aggregations