use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class MultiInstanceTest method testSequentialSubProcessHistory.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.testSequentialSubProcess.bpmn20.xml" })
public void testSequentialSubProcessHistory() {
runtimeService.startProcessInstanceByKey("miSequentialSubprocess");
for (int i = 0; i < 4; i++) {
List<Task> tasks = taskService.createTaskQuery().list();
taskService.complete(tasks.get(0).getId());
taskService.complete(tasks.get(1).getId());
}
// Validate history
if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
List<HistoricActivityInstance> onlySubProcessInstances = historyService.createHistoricActivityInstanceQuery().activityType("subProcess").list();
assertEquals(4, onlySubProcessInstances.size());
List<HistoricActivityInstance> historicInstances = historyService.createHistoricActivityInstanceQuery().activityType("subProcess").list();
assertEquals(4, historicInstances.size());
for (HistoricActivityInstance hai : historicInstances) {
assertNotNull(hai.getStartTime());
assertNotNull(hai.getEndTime());
}
historicInstances = historyService.createHistoricActivityInstanceQuery().activityType("userTask").list();
assertEquals(8, historicInstances.size());
for (HistoricActivityInstance hai : historicInstances) {
assertNotNull(hai.getStartTime());
assertNotNull(hai.getEndTime());
}
}
}
use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class MultiInstanceTest method testSequentialUserTasksHistory.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.sequentialUserTasks.bpmn20.xml" })
public void testSequentialUserTasksHistory() {
runtimeService.startProcessInstanceByKey("miSequentialUserTasks", CollectionUtil.singletonMap("nrOfLoops", 4)).getId();
for (int i = 0; i < 4; i++) {
taskService.complete(taskService.createTaskQuery().singleResult().getId());
}
if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityType("userTask").list();
assertEquals(4, historicActivityInstances.size());
for (HistoricActivityInstance hai : historicActivityInstances) {
assertNotNull(hai.getActivityId());
assertNotNull(hai.getActivityName());
assertNotNull(hai.getStartTime());
assertNotNull(hai.getEndTime());
assertNotNull(hai.getAssignee());
}
}
if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_ACTIVITY) {
List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().list();
assertEquals(4, historicTaskInstances.size());
for (HistoricTaskInstance ht : historicTaskInstances) {
assertNotNull(ht.getAssignee());
assertNotNull(ht.getStartTime());
assertNotNull(ht.getEndTime());
}
}
}
use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class ProcessInstantiationAtActivitiesHistoryTest method testHistoricActivityInstancesForSubprocess.
@Deployment(resources = SUBPROCESS_PROCESS)
public void testHistoricActivityInstancesForSubprocess() {
// when
ProcessInstance instance = runtimeService.createProcessInstanceByKey("subprocess").startBeforeActivity("innerTask").startBeforeActivity("theSubProcessStart").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("innerTask", historicInstance.getStartActivityId());
// subprocess, subprocess start event, two innerTasks
assertEquals(4, historyService.createHistoricActivityInstanceQuery().count());
HistoricActivityInstance subProcessInstance = historyService.createHistoricActivityInstanceQuery().activityId("subProcess").singleResult();
assertNotNull(subProcessInstance);
assertEquals("subProcess", subProcessInstance.getActivityId());
assertNotNull(subProcessInstance.getId());
assertFalse(instance.getId().equals(subProcessInstance.getId()));
assertNotNull(subProcessInstance.getStartTime());
assertNull(subProcessInstance.getEndTime());
HistoricActivityInstance startEventInstance = historyService.createHistoricActivityInstanceQuery().activityId("theSubProcessStart").singleResult();
assertNotNull(startEventInstance);
assertEquals("theSubProcessStart", startEventInstance.getActivityId());
assertNotNull(startEventInstance.getId());
assertFalse(instance.getId().equals(startEventInstance.getId()));
assertNotNull(startEventInstance.getStartTime());
assertNotNull(startEventInstance.getEndTime());
List<HistoricActivityInstance> innerTaskInstances = historyService.createHistoricActivityInstanceQuery().activityId("innerTask").list();
assertEquals(2, innerTaskInstances.size());
for (HistoricActivityInstance innerTaskInstance : innerTaskInstances) {
assertNotNull(innerTaskInstance);
assertEquals("innerTask", innerTaskInstance.getActivityId());
assertNotNull(innerTaskInstance.getId());
assertFalse(instance.getId().equals(innerTaskInstance.getId()));
assertNotNull(innerTaskInstance.getStartTime());
assertNull(innerTaskInstance.getEndTime());
}
}
use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class RuntimeServiceTest method testDeleteProcessInstanceSkipCustomListenersEnsureHistoryWritten.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
@Test
public void testDeleteProcessInstanceSkipCustomListenersEnsureHistoryWritten() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
// if we skip the custom listeners,
runtimeService.deleteProcessInstance(processInstance.getId(), null, true);
// buit-in listeners are still invoked and thus history is written
if (!ProcessEngineConfiguration.HISTORY_NONE.equals(processEngineConfiguration.getHistory())) {
// verify that all historic activity instances are ended
List<HistoricActivityInstance> hais = historyService.createHistoricActivityInstanceQuery().list();
for (HistoricActivityInstance hai : hais) {
assertNotNull(hai.getEndTime());
}
}
}
use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class HistoricActivityInstanceTest method testHistoricActivityInstanceReceive.
@Deployment
public void testHistoricActivityInstanceReceive() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("receiveProcess");
HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("receive").singleResult();
assertEquals("receive", historicActivityInstance.getActivityId());
assertEquals("receiveTask", historicActivityInstance.getActivityType());
assertNull(historicActivityInstance.getEndTime());
assertNull(historicActivityInstance.getDurationInMillis());
assertNotNull(historicActivityInstance.getProcessDefinitionId());
assertEquals(processInstance.getId(), historicActivityInstance.getProcessInstanceId());
assertEquals(processInstance.getId(), historicActivityInstance.getExecutionId());
assertNotNull(historicActivityInstance.getStartTime());
// move clock by 1 second
Date now = ClockUtil.getCurrentTime();
ClockUtil.setCurrentTime(new Date(now.getTime() + 1000));
runtimeService.signal(processInstance.getId());
historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("receive").singleResult();
assertEquals("receive", historicActivityInstance.getActivityId());
assertEquals("receiveTask", historicActivityInstance.getActivityType());
assertNotNull(historicActivityInstance.getEndTime());
assertNotNull(historicActivityInstance.getProcessDefinitionId());
assertEquals(processInstance.getId(), historicActivityInstance.getProcessInstanceId());
assertEquals(processInstance.getId(), historicActivityInstance.getExecutionId());
assertNotNull(historicActivityInstance.getStartTime());
assertTrue(historicActivityInstance.getDurationInMillis() >= 1000);
assertTrue(((HistoricActivityInstanceEventEntity) historicActivityInstance).getDurationRaw() >= 1000);
}
Aggregations