use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class HistoryServiceTest method testHistoricTaskInstanceQueryByDeploymentId.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" })
public void testHistoricTaskInstanceQueryByDeploymentId() {
org.activiti.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult();
HashSet<String> processInstanceIds = new HashSet<String>();
for (int i = 0; i < 4; i++) {
processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess", i + "").getId());
}
processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1").getId());
HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentId(deployment.getId());
assertEquals(5, taskInstanceQuery.count());
List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list();
assertNotNull(taskInstances);
assertEquals(5, taskInstances.size());
taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentId("invalid");
assertEquals(0, taskInstanceQuery.count());
}
use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class ProcessInstanceLogQueryTest method testIncludeTasks.
public void testIncludeTasks() {
ProcessInstanceHistoryLog log = historyService.createProcessInstanceHistoryLogQuery(processInstanceId).includeTasks().singleResult();
List<HistoricData> events = log.getHistoricData();
assertEquals(2, events.size());
for (HistoricData event : events) {
assertTrue(event instanceof HistoricTaskInstance);
}
}
use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class HistoricTaskQueryEscapeClauseTest method testQueryByTaskDeleteReasonLike.
@Test
public void testQueryByTaskDeleteReasonLike() {
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
// make test data
Task task5 = taskService.newTask("task5");
taskService.saveTask(task5);
taskService.deleteTask(task5.getId(), "deleteReason%");
Task task6 = taskService.newTask("task6");
taskService.saveTask(task6);
taskService.deleteTask(task6.getId(), "deleteReason_");
// taskDeleteReasonLike
HistoricTaskInstance historicTask = historyService.createHistoricTaskInstanceQuery().taskDeleteReasonLike("%\\%%").singleResult();
assertNotNull(historicTask);
assertEquals(task5.getId(), historicTask.getId());
historicTask = historyService.createHistoricTaskInstanceQuery().taskDeleteReasonLike("%\\_%").singleResult();
assertNotNull(historicTask);
assertEquals(task6.getId(), historicTask.getId());
// orQuery
historicTask = historyService.createHistoricTaskInstanceQuery().or().taskDeleteReasonLike("%\\%%").processDefinitionId("undefined").singleResult();
assertNotNull(historicTask);
assertEquals(task5.getId(), historicTask.getId());
historicTask = historyService.createHistoricTaskInstanceQuery().or().taskDeleteReasonLike("%\\_%").processDefinitionId("undefined").singleResult();
assertNotNull(historicTask);
assertEquals(task6.getId(), historicTask.getId());
// clean
historyService.deleteHistoricTaskInstance(task5.getId());
historyService.deleteHistoricTaskInstance(task6.getId());
}
}
use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class TaskServiceTest method testSaveTaskUpdate.
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);
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());
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);
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());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(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());
}
// Finally, delete task
taskService.deleteTask(task.getId(), true);
}
use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class TaskServiceTest method testFormKeyExpression.
@Deployment
public void testFormKeyExpression() {
runtimeService.startProcessInstanceByKey("testFormExpression", CollectionUtil.singletonMap("var", "abc"));
Task task = taskService.createTaskQuery().singleResult();
assertEquals("first-form.json", task.getFormKey());
taskService.complete(task.getId());
task = taskService.createTaskQuery().singleResult();
assertEquals("form-abc.json", task.getFormKey());
task.setFormKey("form-changed.json");
taskService.saveTask(task);
task = taskService.createTaskQuery().singleResult();
assertEquals("form-changed.json", task.getFormKey());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
assertEquals("form-changed.json", historicTaskInstance.getFormKey());
}
}
Aggregations