use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testProcessDefinitionKeyProperty.
@Deployment(resources = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml")
public void testProcessDefinitionKeyProperty() {
// given
String key = "oneTaskProcess";
String processInstanceId = runtimeService.startProcessInstanceByKey(key).getId();
// when
HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
// then
assertNotNull(instance.getProcessDefinitionKey());
assertEquals(key, instance.getProcessDefinitionKey());
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testHistoricProcInstExecutedActivityWithEmptyInterval.
@Test
public void testHistoricProcInstExecutedActivityWithEmptyInterval() {
// 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 proc inst which executes an activity an hour before and after the starting time
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().executedActivityBefore(hourBeforeNow.getTime()).executedActivityAfter(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 testQueryBySuperCaseInstanceId.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCase.cmmn", "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testQueryBySuperCaseInstanceId() {
String superCaseInstanceId = caseService.createCaseInstanceByKey("oneProcessTaskCase").getId();
HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().superCaseInstanceId(superCaseInstanceId);
assertEquals(1, query.list().size());
assertEquals(1, query.count());
HistoricProcessInstance subProcessInstance = query.singleResult();
assertNotNull(subProcessInstance);
assertEquals(superCaseInstanceId, subProcessInstance.getSuperCaseInstanceId());
assertNull(subProcessInstance.getSuperProcessInstanceId());
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testLongProcessDefinitionKey.
@Deployment
public void testLongProcessDefinitionKey() {
// must be equals to attribute id of element process in process model
final String PROCESS_DEFINITION_KEY = "myrealrealrealrealrealrealrealrealrealrealreallongprocessdefinitionkeyawesome";
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).singleResult();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
// get HPI by process instance id
HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(hpi);
assertProcessEnded(hpi.getId());
// get HPI by process definition key
HistoricProcessInstance hpi2 = historyService.createHistoricProcessInstanceQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).singleResult();
assertNotNull(hpi2);
assertProcessEnded(hpi2.getId());
// check we got the same HPIs
assertEquals(hpi.getId(), hpi2.getId());
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testHistoricProcInstExecutedActivityInInterval.
@Test
public void testHistoricProcInstExecutedActivityInInterval() {
// given proc instance with wait state
Calendar now = Calendar.getInstance();
ClockUtil.setCurrentTime(now.getTime());
BpmnModelInstance model = Bpmn.createExecutableProcess("proc").startEvent().userTask().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
// and before a hour after start time
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().executedActivityAfter(now.getTime()).executedActivityBefore(hourFromNow.getTime()).singleResult();
// then query returns result
assertNotNull(historicProcessInstance);
// when proc inst is not in interval
Calendar sixHoursFromNow = (Calendar) now.clone();
sixHoursFromNow.add(Calendar.HOUR_OF_DAY, 6);
historicProcessInstance = historyService.createHistoricProcessInstanceQuery().executedActivityAfter(hourFromNow.getTime()).executedActivityBefore(sixHoursFromNow.getTime()).singleResult();
// then query should return NO result
assertNull(historicProcessInstance);
}
Aggregations