use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testAsyncStartActivityId.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testStartActivityId-super.bpmn20.xml", "org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testAsyncStartActivityId-sub.bpmn20.xml" })
public void testAsyncStartActivityId() {
// given
runtimeService.startProcessInstanceByKey("super");
// when
executeAvailableJobs();
// 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 testBusinessKey.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testBusinessKey.cmmn", "org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testBusinessKey.bpmn20.xml" })
public void testBusinessKey() {
// given
String businessKey = "aBusinessKey";
caseService.withCaseDefinitionByKey("case").businessKey(businessKey).create().getId();
// then
HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery();
query.processInstanceBusinessKey(businessKey);
assertEquals(1, query.count());
assertEquals(1, query.list().size());
HistoricProcessInstance historicProcessInstance = query.singleResult();
assertNotNull(historicProcessInstance);
assertEquals(businessKey, historicProcessInstance.getBusinessKey());
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testSuperCaseInstanceIdProperty.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCase.cmmn", "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testSuperCaseInstanceIdProperty() {
String superCaseInstanceId = caseService.createCaseInstanceByKey("oneProcessTaskCase").getId();
caseService.createCaseExecutionQuery().activityId("PI_ProcessTask_1").singleResult().getId();
HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery().singleResult();
assertNotNull(instance);
assertEquals(superCaseInstanceId, instance.getSuperCaseInstanceId());
String taskId = taskService.createTaskQuery().singleResult().getId();
taskService.complete(taskId);
instance = historyService.createHistoricProcessInstanceQuery().singleResult();
assertNotNull(instance);
assertEquals(superCaseInstanceId, instance.getSuperCaseInstanceId());
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testHistoricProcInstExecutedActivityBefore.
@Test
public void testHistoricProcInstExecutedActivityBefore() {
// given
Calendar now = Calendar.getInstance();
ClockUtil.setCurrentTime(now.getTime());
BpmnModelInstance model = Bpmn.createExecutableProcess("proc").startEvent().endEvent().done();
deployment(model);
Calendar hourBeforeNow = (Calendar) now.clone();
hourBeforeNow.add(Calendar.HOUR, -1);
runtimeService.startProcessInstanceByKey("proc");
// when query historic process instance which has executed an activity before the start time
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().executedActivityBefore(now.getTime()).singleResult();
// then query returns result, since the query is less-then-equal
assertNotNull(historicProcessInstance);
// when query historic proc inst which executes an activity an hour before the starting time
historicProcessInstance = historyService.createHistoricProcessInstanceQuery().executedActivityBefore(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 testHistoricProcInstQueryWithExecutedActivityIds.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testHistoricProcInstQueryWithExecutedActivityIds() {
// given
deployment(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
Task task = taskService.createTaskQuery().active().singleResult();
taskService.complete(task.getId());
// assume
HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstance.getId()).activityId("userTask1").singleResult();
assertNotNull(historicActivityInstance);
// when
List<HistoricProcessInstance> result = historyService.createHistoricProcessInstanceQuery().executedActivityIdIn(historicActivityInstance.getActivityId()).list();
// then
assertNotNull(result);
assertEquals(1, result.size());
assertEquals(result.get(0).getId(), processInstance.getId());
}
Aggregations