use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class MultiInstanceTest method testParallelCallActivityHistory.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.testParallelCallActivity.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.externalSubProcess.bpmn20.xml" })
public void testParallelCallActivityHistory() {
runtimeService.startProcessInstanceByKey("miParallelCallActivity");
List<Task> tasks = taskService.createTaskQuery().list();
assertEquals(12, tasks.size());
for (int i = 0; i < tasks.size(); i++) {
taskService.complete(tasks.get(i).getId());
}
if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
// Validate historic processes
List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list();
// 6 subprocesses + main process
assertEquals(7, historicProcessInstances.size());
for (HistoricProcessInstance hpi : historicProcessInstances) {
assertNotNull(hpi.getStartTime());
assertNotNull(hpi.getEndTime());
}
// Validate historic activities
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityType("callActivity").list();
assertEquals(6, historicActivityInstances.size());
for (HistoricActivityInstance hai : historicActivityInstances) {
assertNotNull(hai.getStartTime());
assertNotNull(hai.getEndTime());
}
}
if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_ACTIVITY) {
// Validate historic tasks
List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().list();
assertEquals(12, historicTaskInstances.size());
for (HistoricTaskInstance hti : historicTaskInstances) {
assertNotNull(hti.getStartTime());
assertNotNull(hti.getEndTime());
assertNotNull(hti.getAssignee());
assertEquals("completed", hti.getDeleteReason());
}
}
}
use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceTest method testHistoricTaskInstanceAssignment.
public void testHistoricTaskInstanceAssignment() {
Task task = taskService.newTask();
taskService.saveTask(task);
// task exists & has no assignee:
HistoricTaskInstance hti = historyService.createHistoricTaskInstanceQuery().singleResult();
assertNull(hti.getAssignee());
// assign task to jonny:
taskService.setAssignee(task.getId(), "jonny");
// should be reflected in history
hti = historyService.createHistoricTaskInstanceQuery().singleResult();
assertEquals("jonny", hti.getAssignee());
assertNull(hti.getOwner());
taskService.deleteTask(task.getId());
historyService.deleteHistoricTaskInstance(hti.getId());
}
use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceTest method testHistoricTaskInstanceAssignmentListener.
@Deployment
public void testHistoricTaskInstanceAssignmentListener() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("assignee", "jonny");
runtimeService.startProcessInstanceByKey("testProcess", variables);
HistoricActivityInstance hai = historyService.createHistoricActivityInstanceQuery().activityId("task").singleResult();
assertEquals("jonny", hai.getAssignee());
HistoricTaskInstance hti = historyService.createHistoricTaskInstanceQuery().singleResult();
assertEquals("jonny", hti.getAssignee());
assertNull(hti.getOwner());
}
use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceTest method testHistoricTaskInstanceOwner.
public void testHistoricTaskInstanceOwner() {
Task task = taskService.newTask();
taskService.saveTask(task);
// task exists & has no owner:
HistoricTaskInstance hti = historyService.createHistoricTaskInstanceQuery().singleResult();
assertNull(hti.getOwner());
// set owner to jonny:
taskService.setOwner(task.getId(), "jonny");
// should be reflected in history
hti = historyService.createHistoricTaskInstanceQuery().singleResult();
assertEquals("jonny", hti.getOwner());
taskService.deleteTask(task.getId());
historyService.deleteHistoricTaskInstance(hti.getId());
}
use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceTest method testQueryByCaseInstanceIdHierarchy.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricTaskInstanceTest.testQueryByCaseInstanceIdHierarchy.cmmn", "org/camunda/bpm/engine/test/history/HistoricTaskInstanceTest.testQueryByCaseInstanceIdHierarchy.bpmn20.xml" })
public void testQueryByCaseInstanceIdHierarchy() {
// given
String caseInstanceId = caseService.withCaseDefinitionByKey("case").create().getId();
caseService.createCaseExecutionQuery().activityId("PI_ProcessTask_1").singleResult().getId();
// then
HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
query.caseInstanceId(caseInstanceId);
assertEquals(2, query.count());
assertEquals(2, query.list().size());
for (HistoricTaskInstance task : query.list()) {
assertEquals(caseInstanceId, task.getCaseInstanceId());
assertNull(task.getCaseDefinitionId());
assertNull(task.getCaseExecutionId());
taskService.complete(task.getId());
}
assertEquals(3, query.count());
assertEquals(3, query.list().size());
for (HistoricTaskInstance task : query.list()) {
assertEquals(caseInstanceId, task.getCaseInstanceId());
assertNull(task.getCaseDefinitionId());
assertNull(task.getCaseExecutionId());
}
}
Aggregations