use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class ProcessInstantiationAtActivitiesHistoryTest method testSkipCustomListenerEnsureHistoryWritten.
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS)
public void testSkipCustomListenerEnsureHistoryWritten() {
// when creating the task skipping custom listeners
runtimeService.createProcessInstanceByKey("exclusiveGateway").startBeforeActivity("task2").execute(true, false);
// then the task assignment history (which uses a task listener) is written
Task task = taskService.createTaskQuery().taskDefinitionKey("task2").singleResult();
HistoricActivityInstance instance = historyService.createHistoricActivityInstanceQuery().activityId("task2").singleResult();
assertNotNull(instance);
assertEquals(task.getId(), instance.getTaskId());
assertEquals("kermit", instance.getAssignee());
}
use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class ProcessInstantiationAtActivitiesHistoryTest method testHistoricProcessInstanceForSingleActivityInstantiation.
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS)
public void testHistoricProcessInstanceForSingleActivityInstantiation() {
// when
ProcessInstance instance = runtimeService.createProcessInstanceByKey("exclusiveGateway").startBeforeActivity("task1").execute();
// then
HistoricProcessInstance historicInstance = historyService.createHistoricProcessInstanceQuery().singleResult();
assertNotNull(historicInstance);
assertEquals(instance.getId(), historicInstance.getId());
assertNotNull(historicInstance.getStartTime());
assertNull(historicInstance.getEndTime());
// should be the first activity started
assertEquals("task1", historicInstance.getStartActivityId());
HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().singleResult();
assertNotNull(historicActivityInstance);
assertEquals("task1", historicActivityInstance.getActivityId());
assertNotNull(historicActivityInstance.getId());
assertFalse(instance.getId().equals(historicActivityInstance.getId()));
assertNotNull(historicActivityInstance.getStartTime());
assertNull(historicActivityInstance.getEndTime());
}
use of org.camunda.bpm.engine.history.HistoricActivityInstance 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.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class CompensateEventTest method FAILING_testDeleteInstanceWithEventScopeExecution.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
public void FAILING_testDeleteInstanceWithEventScopeExecution() {
// given
BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("foo").startEvent("start").subProcess("subProcess").embeddedSubProcess().startEvent("subProcessStart").endEvent("subProcessEnd").subProcessDone().userTask("userTask").done();
modelInstance = ModifiableBpmnModelInstance.modify(modelInstance).addSubProcessTo("subProcess").id("eventSubProcess").triggerByEvent().embeddedSubProcess().startEvent().compensateEventDefinition().compensateEventDefinitionDone().endEvent().done();
deployment(modelInstance);
long dayInMillis = 1000 * 60 * 60 * 24;
Date date1 = new Date(10 * dayInMillis);
ClockUtil.setCurrentTime(date1);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("foo");
// when
Date date2 = new Date(date1.getTime() + dayInMillis);
ClockUtil.setCurrentTime(date2);
runtimeService.deleteProcessInstance(processInstance.getId(), null);
// then
List<HistoricActivityInstance> historicActivityInstance = historyService.createHistoricActivityInstanceQuery().orderByActivityId().asc().list();
assertEquals(5, historicActivityInstance.size());
assertEquals("start", historicActivityInstance.get(0).getActivityId());
assertEquals(date1, historicActivityInstance.get(0).getEndTime());
assertEquals("subProcess", historicActivityInstance.get(1).getActivityId());
assertEquals(date1, historicActivityInstance.get(1).getEndTime());
assertEquals("subProcessEnd", historicActivityInstance.get(2).getActivityId());
assertEquals(date1, historicActivityInstance.get(2).getEndTime());
assertEquals("subProcessStart", historicActivityInstance.get(3).getActivityId());
assertEquals(date1, historicActivityInstance.get(3).getEndTime());
assertEquals("userTask", historicActivityInstance.get(4).getActivityId());
assertEquals(date2, historicActivityInstance.get(4).getEndTime());
}
use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationHistoryTest method testSkipCustomListenerEnsureHistoryWritten.
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS)
public void testSkipCustomListenerEnsureHistoryWritten() {
// given
String processInstanceId = runtimeService.startProcessInstanceByKey("exclusiveGateway").getId();
// when creating the task skipping custom listeners
runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("task2").execute(true, false);
// then the task assignment history (which uses a task listener) is written
Task task = taskService.createTaskQuery().taskDefinitionKey("task2").singleResult();
HistoricActivityInstance instance = historyService.createHistoricActivityInstanceQuery().activityId("task2").singleResult();
assertNotNull(instance);
assertEquals(task.getId(), instance.getTaskId());
assertEquals("kermit", instance.getAssignee());
}
Aggregations