use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testQueryWithRootIncidents.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testQueryWithRootIncidents() {
// given
deployment("org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testQueryWithRootIncidents.bpmn20.xml");
deployment(CallActivityModels.oneBpmnCallActivityProcess("Process_1"));
runtimeService.startProcessInstanceByKey("Process");
ProcessInstance calledProcessInstance = runtimeService.createProcessInstanceQuery().processDefinitionKey("Process_1").singleResult();
executeAvailableJobs();
// when
List<HistoricProcessInstance> historicProcInstances = historyService.createHistoricProcessInstanceQuery().withRootIncidents().list();
// then
assertNotNull(calledProcessInstance);
assertEquals(1, historicProcInstances.size());
assertEquals(calledProcessInstance.getId(), historicProcInstances.get(0).getId());
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testDeleteReason.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml" })
public // ACT-1098
void testDeleteReason() {
if (!ProcessEngineConfiguration.HISTORY_NONE.equals(processEngineConfiguration.getHistory())) {
final String deleteReason = "some delete reason";
ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess");
runtimeService.deleteProcessInstance(pi.getId(), deleteReason);
HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery().processInstanceId(pi.getId()).singleResult();
assertEquals(deleteReason, hpi.getDeleteReason());
}
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testHistoricProcInstExecutedJobWithEmptyInterval.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testHistoricProcInstExecutedJobWithEmptyInterval() {
// given
BpmnModelInstance asyncModel = Bpmn.createExecutableProcess("async").startEvent().camundaAsyncBefore().endEvent().done();
deployment(asyncModel);
BpmnModelInstance model = Bpmn.createExecutableProcess("proc").startEvent().endEvent().done();
deployment(model);
Calendar now = Calendar.getInstance();
ClockUtil.setCurrentTime(now.getTime());
Calendar hourBeforeNow = (Calendar) now.clone();
hourBeforeNow.add(Calendar.HOUR_OF_DAY, -1);
runtimeService.startProcessInstanceByKey("async");
Job job = managementService.createJobQuery().singleResult();
managementService.executeJob(job.getId());
runtimeService.startProcessInstanceByKey("proc");
// when query historic proc inst with executed job before and after an hour before the starting time
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().executedJobBefore(hourBeforeNow.getTime()).executedJobAfter(hourBeforeNow.getTime()).singleResult();
// then query returns no result
assertNull(historicProcessInstance);
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testLongRunningHistoricDataCreatedForProcessExecution.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml" })
public void testLongRunningHistoricDataCreatedForProcessExecution() {
final long ONE_YEAR = 1000 * 60 * 60 * 24 * 365;
Calendar cal = Calendar.getInstance();
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Date now = cal.getTime();
ClockUtil.setCurrentTime(now);
final ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", "myBusinessKey");
assertEquals(1, historyService.createHistoricProcessInstanceQuery().unfinished().count());
assertEquals(0, historyService.createHistoricProcessInstanceQuery().finished().count());
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
assertEquals(now, historicProcessInstance.getStartTime());
List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
assertEquals(1, tasks.size());
// in this test scenario we assume that one year after the process start, the
// user completes the task (incredible speedy!)
cal.add(Calendar.YEAR, 1);
Date oneYearLater = cal.getTime();
ClockUtil.setCurrentTime(oneYearLater);
taskService.complete(tasks.get(0).getId());
historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
assertEquals(now, historicProcessInstance.getStartTime());
assertEquals(oneYearLater, historicProcessInstance.getEndTime());
assertTrue(historicProcessInstance.getDurationInMillis() >= ONE_YEAR);
assertTrue(((HistoricProcessInstanceEventEntity) historicProcessInstance).getDurationRaw() >= ONE_YEAR);
assertEquals(0, historyService.createHistoricProcessInstanceQuery().unfinished().count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().finished().count());
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testDeleteProcessInstanceWithoutSubprocessInstances.
public void testDeleteProcessInstanceWithoutSubprocessInstances() {
// given a process instance with subprocesses
BpmnModelInstance calling = Bpmn.createExecutableProcess("calling").startEvent().callActivity().calledElement("called").endEvent("endA").done();
BpmnModelInstance called = Bpmn.createExecutableProcess("called").startEvent().userTask("Task1").endEvent().done();
deployment(calling, called);
ProcessInstance instance = runtimeService.startProcessInstanceByKey("calling");
// when the process instance is deleted and we do skip sub processes
String id = instance.getId();
runtimeService.deleteProcessInstance(id, "test_purposes", false, true, false, true);
// then
List<HistoricProcessInstance> historicSubprocessList = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("called").list();
for (HistoricProcessInstance historicProcessInstance : historicSubprocessList) {
assertNull(historicProcessInstance.getSuperProcessInstanceId());
}
}
Aggregations