use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceTest method testHistoricCalledProcessInstanceId.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCaseWithManualActivation.cmmn", "org/camunda/bpm/engine/test/history/HistoricCaseActivityInstanceTest.oneTaskProcess.bpmn20.xml" })
public void testHistoricCalledProcessInstanceId() {
String taskId = "PI_ProcessTask_1";
createCaseInstanceByKey("oneProcessTaskCase").getId();
// as long as the process task is not activated there should be no process instance
assertCount(0, historyService.createHistoricProcessInstanceQuery());
HistoricCaseActivityInstance historicInstance = queryHistoricActivityCaseInstance(taskId);
assertNull(historicInstance.getCalledProcessInstanceId());
// start process task manually to create case instance
CaseExecution processTask = queryCaseExecutionByActivityId(taskId);
manualStart(processTask.getId());
// there should exist a new process instance
HistoricProcessInstance calledProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult();
assertNotNull(calledProcessInstance);
assertNotNull(calledProcessInstance.getEndTime());
// check that the called process instance id was correctly set
historicInstance = queryHistoricActivityCaseInstance(taskId);
assertEquals(calledProcessInstance.getId(), historicInstance.getCalledProcessInstanceId());
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testQueryByCaseInstanceIdHierarchy.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testQueryByCaseInstanceId.cmmn", "org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testQueryByCaseInstanceIdHierarchy-super.bpmn20.xml", "org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testQueryByCaseInstanceIdHierarchy-sub.bpmn20.xml" })
public void testQueryByCaseInstanceIdHierarchy() {
// given
String caseInstanceId = caseService.withCaseDefinitionByKey("case").create().getId();
// then
HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery();
query.caseInstanceId(caseInstanceId);
assertEquals(2, query.count());
assertEquals(2, query.list().size());
for (HistoricProcessInstance hpi : query.list()) {
assertEquals(caseInstanceId, hpi.getCaseInstanceId());
}
// complete existing user task -> completes the process instance(s)
String taskId = taskService.createTaskQuery().caseInstanceId(caseInstanceId).singleResult().getId();
taskService.complete(taskId);
// the completed historic process instance is still associated with the
// case instance id
assertEquals(2, query.count());
assertEquals(2, query.list().size());
for (HistoricProcessInstance hpi : query.list()) {
assertEquals(caseInstanceId, hpi.getCaseInstanceId());
}
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testProcessInstanceShouldBeActive.
@Deployment
public void testProcessInstanceShouldBeActive() {
// given
// when
String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
// then
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
assertNull(historicProcessInstance.getEndTime());
assertNull(historicProcessInstance.getDurationInMillis());
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testStartActivityId.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testStartActivityId-super.bpmn20.xml", "org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testStartActivityId-sub.bpmn20.xml" })
public void testStartActivityId() {
// given
// when
runtimeService.startProcessInstanceByKey("super");
// then
HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("sub").singleResult();
assertEquals("theSubStart", hpi.getStartActivityId());
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testHistoricProcInstExecutedActivityAfter.
@Test
public void testHistoricProcInstExecutedActivityAfter() {
// given
Calendar now = Calendar.getInstance();
ClockUtil.setCurrentTime(now.getTime());
BpmnModelInstance model = Bpmn.createExecutableProcess("proc").startEvent().endEvent().done();
deployment(model);
Calendar hourFromNow = (Calendar) now.clone();
hourFromNow.add(Calendar.HOUR_OF_DAY, 1);
runtimeService.startProcessInstanceByKey("proc");
// when query historic process instance which has executed an activity after the start time
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().executedActivityAfter(now.getTime()).singleResult();
// then query returns result
assertNotNull(historicProcessInstance);
// when query historic proc inst with execute activity after a hour of the starting time
historicProcessInstance = historyService.createHistoricProcessInstanceQuery().executedActivityAfter(hourFromNow.getTime()).singleResult();
// then query returns no result
assertNull(historicProcessInstance);
}
Aggregations