use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceQueryTest method testTaskWasAssigned.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testTaskWasAssigned() {
// 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().taskAssigned().list();
// then
assertEquals(list.size(), 2);
// cleanup
taskService.deleteTask("taskOne", true);
taskService.deleteTask("taskTwo", true);
taskService.deleteTask("taskThree", true);
}
use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceQueryTest method testTaskReturnedBeforeEndTime.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testTaskReturnedBeforeEndTime() {
// given
Task taskOne = taskService.newTask("taskOne");
// when
taskOne.setAssignee("aUserId");
taskService.saveTask(taskOne);
Calendar hourAgo = Calendar.getInstance();
hourAgo.add(Calendar.HOUR_OF_DAY, -1);
ClockUtil.setCurrentTime(hourAgo.getTime());
taskService.complete(taskOne.getId());
List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery().finishedBefore(hourAgo.getTime()).list();
// then
assertEquals(1, list.size());
// cleanup
taskService.deleteTask("taskOne", true);
ClockUtil.reset();
}
use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class SubTaskTest method testSubTask.
public void testSubTask() {
Task gonzoTask = taskService.newTask();
gonzoTask.setName("gonzoTask");
taskService.saveTask(gonzoTask);
Task subTaskOne = taskService.newTask();
subTaskOne.setName("subtask one");
String gonzoTaskId = gonzoTask.getId();
subTaskOne.setParentTaskId(gonzoTaskId);
taskService.saveTask(subTaskOne);
Task subTaskTwo = taskService.newTask();
subTaskTwo.setName("subtask two");
subTaskTwo.setParentTaskId(gonzoTaskId);
taskService.saveTask(subTaskTwo);
String subTaskId = subTaskOne.getId();
assertTrue(taskService.getSubTasks(subTaskId).isEmpty());
assertTrue(historyService.createHistoricTaskInstanceQuery().taskParentTaskId(subTaskId).list().isEmpty());
List<Task> subTasks = taskService.getSubTasks(gonzoTaskId);
Set<String> subTaskNames = new HashSet<String>();
for (Task subTask : subTasks) {
subTaskNames.add(subTask.getName());
}
if (processEngineConfiguration.getHistoryLevel().getId() >= HistoryLevel.HISTORY_LEVEL_AUDIT.getId()) {
Set<String> expectedSubTaskNames = new HashSet<String>();
expectedSubTaskNames.add("subtask one");
expectedSubTaskNames.add("subtask two");
assertEquals(expectedSubTaskNames, subTaskNames);
List<HistoricTaskInstance> historicSubTasks = historyService.createHistoricTaskInstanceQuery().taskParentTaskId(gonzoTaskId).list();
subTaskNames = new HashSet<String>();
for (HistoricTaskInstance historicSubTask : historicSubTasks) {
subTaskNames.add(historicSubTask.getName());
}
assertEquals(expectedSubTaskNames, subTaskNames);
}
taskService.deleteTask(gonzoTaskId, true);
}
use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class TaskServiceTest method testDeleteTaskWithDeleteReason.
@Test
public void testDeleteTaskWithDeleteReason() {
// ACT-900: deleteReason can be manually specified - can only be validated when historyLevel > ACTIVITY
if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_ACTIVITY) {
Task task = taskService.newTask();
task.setName("test task");
taskService.saveTask(task);
assertNotNull(task.getId());
taskService.deleteTask(task.getId(), "deleted for testing purposes");
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
assertNotNull(historicTaskInstance);
assertEquals("deleted for testing purposes", historicTaskInstance.getDeleteReason());
// Delete historic task that is left behind, will not be cleaned up because this is not part of a process
taskService.deleteTask(task.getId(), true);
}
}
use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class TaskServiceTest method testSaveTaskUpdate.
@Test
public void testSaveTaskUpdate() throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
Task task = taskService.newTask();
task.setDescription("description");
task.setName("taskname");
task.setPriority(0);
task.setAssignee("taskassignee");
task.setOwner("taskowner");
Date dueDate = sdf.parse("01/02/2003 04:05:06");
task.setDueDate(dueDate);
task.setCaseInstanceId("taskcaseinstanceid");
taskService.saveTask(task);
// Fetch the task again and update
task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
assertEquals("description", task.getDescription());
assertEquals("taskname", task.getName());
assertEquals("taskassignee", task.getAssignee());
assertEquals("taskowner", task.getOwner());
assertEquals(dueDate, task.getDueDate());
assertEquals(0, task.getPriority());
assertEquals("taskcaseinstanceid", task.getCaseInstanceId());
if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) {
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
assertEquals("taskname", historicTaskInstance.getName());
assertEquals("description", historicTaskInstance.getDescription());
assertEquals("taskassignee", historicTaskInstance.getAssignee());
assertEquals("taskowner", historicTaskInstance.getOwner());
assertEquals(dueDate, historicTaskInstance.getDueDate());
assertEquals(0, historicTaskInstance.getPriority());
assertEquals("taskcaseinstanceid", historicTaskInstance.getCaseInstanceId());
}
task.setName("updatedtaskname");
task.setDescription("updateddescription");
task.setPriority(1);
task.setAssignee("updatedassignee");
task.setOwner("updatedowner");
dueDate = sdf.parse("01/02/2003 04:05:06");
task.setDueDate(dueDate);
task.setCaseInstanceId("updatetaskcaseinstanceid");
taskService.saveTask(task);
task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
assertEquals("updatedtaskname", task.getName());
assertEquals("updateddescription", task.getDescription());
assertEquals("updatedassignee", task.getAssignee());
assertEquals("updatedowner", task.getOwner());
assertEquals(dueDate, task.getDueDate());
assertEquals(1, task.getPriority());
assertEquals("updatetaskcaseinstanceid", task.getCaseInstanceId());
if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) {
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
assertEquals("updatedtaskname", historicTaskInstance.getName());
assertEquals("updateddescription", historicTaskInstance.getDescription());
assertEquals("updatedassignee", historicTaskInstance.getAssignee());
assertEquals("updatedowner", historicTaskInstance.getOwner());
assertEquals(dueDate, historicTaskInstance.getDueDate());
assertEquals(1, historicTaskInstance.getPriority());
assertEquals("updatetaskcaseinstanceid", historicTaskInstance.getCaseInstanceId());
}
// Finally, delete task
taskService.deleteTask(task.getId(), true);
}
Aggregations