use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceTest method testHistoricTaskInstanceQueryByProcessVariableValue.
@Deployment
public void testHistoricTaskInstanceQueryByProcessVariableValue() throws Exception {
int historyLevel = processEngineConfiguration.getHistoryLevel().getId();
if (historyLevel >= ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("hallo", "steffen");
String processInstanceId = runtimeService.startProcessInstanceByKey("HistoricTaskInstanceTest", variables).getId();
Task runtimeTask = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
String taskId = runtimeTask.getId();
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().processVariableValueEquals("hallo", "steffen").singleResult();
assertNotNull(historicTaskInstance);
assertEquals(taskId, historicTaskInstance.getId());
taskService.complete(taskId);
assertEquals(1, historyService.createHistoricTaskInstanceQuery().taskId(taskId).count());
historyService.deleteHistoricTaskInstance(taskId);
assertEquals(0, historyService.createHistoricTaskInstanceQuery().count());
}
}
use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceTest method testQueryByCaseDefinitionKey.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testQueryByCaseDefinitionKey() {
// given
String key = "oneTaskCase";
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(key).singleResult().getId();
String caseInstanceId = caseService.withCaseDefinitionByKey(key).create().getId();
String humanTaskId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
// then
HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
query.caseDefinitionKey(key);
assertEquals(1, query.count());
assertEquals(1, query.list().size());
assertNotNull(query.singleResult());
HistoricTaskInstance task = query.singleResult();
assertNotNull(task);
assertEquals(caseDefinitionId, task.getCaseDefinitionId());
assertEquals(caseInstanceId, task.getCaseInstanceId());
assertEquals(humanTaskId, task.getCaseExecutionId());
}
use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceTest method testHistoricTaskInstanceCaseInstanceId.
public void testHistoricTaskInstanceCaseInstanceId() {
Task task = taskService.newTask();
task.setCaseInstanceId("aCaseInstanceId");
taskService.saveTask(task);
HistoricTaskInstance hti = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
assertEquals("aCaseInstanceId", hti.getCaseInstanceId());
task.setCaseInstanceId("anotherCaseInstanceId");
taskService.saveTask(task);
hti = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
assertEquals("anotherCaseInstanceId", hti.getCaseInstanceId());
// Finally, delete task
taskService.deleteTask(task.getId(), true);
}
use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceTest method testHistoricTaskInstancePriority.
public void testHistoricTaskInstancePriority() {
Task task = taskService.newTask();
taskService.saveTask(task);
// task exists & has normal priority:
HistoricTaskInstance hti = historyService.createHistoricTaskInstanceQuery().singleResult();
assertEquals(Task.PRIORITY_NORMAL, hti.getPriority());
// set priority to maximum value:
taskService.setPriority(task.getId(), Task.PRIORITY_MAXIMUM);
// should be reflected in history
hti = historyService.createHistoricTaskInstanceQuery().singleResult();
assertEquals(Task.PRIORITY_MAXIMUM, hti.getPriority());
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 HistoricTaskInstanceQueryTest method testTaskWasUnassigned.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testTaskWasUnassigned() {
// given
Task taskOne = taskService.newTask("taskOne");
Task taskTwo = taskService.newTask("taskTwo");
Task taskThree = taskService.newTask("taskThree");
// when
taskOne.setAssignee("aUserId");
taskService.saveTask(taskOne);
taskTwo.setAssignee("anotherUserId");
taskService.saveTask(taskTwo);
taskService.saveTask(taskThree);
List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery().taskUnassigned().list();
// then
assertEquals(list.size(), 1);
// cleanup
taskService.deleteTask("taskOne", true);
taskService.deleteTask("taskTwo", true);
taskService.deleteTask("taskThree", true);
}
Aggregations