use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class HistoricActivityInstanceTest method testHistoricActivityInstanceProperties.
@Deployment
public void testHistoricActivityInstanceProperties() {
// Start process instance
runtimeService.startProcessInstanceByKey("taskAssigneeProcess");
// Get task list
HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("theTask").singleResult();
Task task = taskService.createTaskQuery().singleResult();
assertEquals(task.getId(), historicActivityInstance.getTaskId());
assertEquals("kermit", historicActivityInstance.getAssignee());
// change assignee of the task
taskService.setAssignee(task.getId(), "gonzo");
task = taskService.createTaskQuery().singleResult();
historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("theTask").singleResult();
assertEquals("gonzo", historicActivityInstance.getAssignee());
}
use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class HistoricActivityInstanceTest method testHistoricActivityInstanceCalledProcessId.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/calledProcess.bpmn20.xml", "org/camunda/bpm/engine/test/history/HistoricActivityInstanceTest.testCallSimpleSubProcess.bpmn20.xml" })
public void testHistoricActivityInstanceCalledProcessId() {
runtimeService.startProcessInstanceByKey("callSimpleSubProcess");
HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("callSubProcess").singleResult();
HistoricProcessInstance oldInstance = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("calledProcess").singleResult();
assertEquals(oldInstance.getId(), historicActivityInstance.getCalledProcessInstanceId());
}
use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class HistoricActivityInstanceTest method testHistoricActivityInstanceQueryByCompleteScope.
@Deployment
public void testHistoricActivityInstanceQueryByCompleteScope() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
List<Task> tasks = taskService.createTaskQuery().list();
for (Task task : tasks) {
taskService.complete(task.getId());
}
HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery().completeScope();
assertEquals(3, query.count());
List<HistoricActivityInstance> instances = query.list();
for (HistoricActivityInstance instance : instances) {
if (!instance.getActivityId().equals("innerEnd") && !instance.getActivityId().equals("end1") && !instance.getActivityId().equals("end2")) {
fail("Unexpected instance with activity id " + instance.getActivityId() + " found.");
}
}
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class HistoricActivityInstanceTest method testLongRunningHistoricActivityInstanceReceive.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricActivityInstanceTest.testHistoricActivityInstanceReceive.bpmn20.xml" })
public void testLongRunningHistoricActivityInstanceReceive() {
final long ONE_YEAR = 1000 * 60 * 60 * 24 * 365;
Calendar cal = Calendar.getInstance();
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
ClockUtil.setCurrentTime(cal.getTime());
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 year
cal.add(Calendar.YEAR, 1);
ClockUtil.setCurrentTime(cal.getTime());
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() >= ONE_YEAR);
assertTrue(((HistoricActivityInstanceEventEntity) historicActivityInstance).getDurationRaw() >= ONE_YEAR);
}
use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class HistoricActivityInstanceTest method testErrorEventSubprocess.
@Deployment(resources = "org/camunda/bpm/engine/test/history/HistoricActivityInstanceTest.startEventTypesForEventSubprocess.bpmn20.xml")
public void testErrorEventSubprocess() {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("shouldThrowError", true);
runtimeService.startProcessInstanceByKey("process", vars);
HistoricActivityInstance historicActivity = historyService.createHistoricActivityInstanceQuery().activityId("errorStartEvent").singleResult();
assertEquals("errorStartEvent", historicActivity.getActivityType());
}
Aggregations