use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
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().isAtLeast(HistoryLevel.AUDIT)) {
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.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class SubTaskTest method testSubTaskDeleteOnProcessInstanceDelete.
public void testSubTaskDeleteOnProcessInstanceDelete() {
Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml").deploy();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.setAssignee(task.getId(), "test");
Task subTask1 = taskService.newTask();
subTask1.setName("Sub task 1");
subTask1.setParentTaskId(task.getId());
subTask1.setAssignee("test");
taskService.saveTask(subTask1);
Task subTask2 = taskService.newTask();
subTask2.setName("Sub task 2");
subTask2.setParentTaskId(task.getId());
subTask2.setAssignee("test");
taskService.saveTask(subTask2);
List<Task> tasks = taskService.createTaskQuery().taskAssignee("test").list();
assertEquals(3, tasks.size());
runtimeService.deleteProcessInstance(processInstance.getId(), "none");
tasks = taskService.createTaskQuery().taskAssignee("test").list();
assertEquals(0, tasks.size());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
List<HistoricTaskInstance> historicTasks = historyService.createHistoricTaskInstanceQuery().taskAssignee("test").list();
assertEquals(3, historicTasks.size());
historyService.deleteHistoricProcessInstance(processInstance.getId());
historicTasks = historyService.createHistoricTaskInstanceQuery().taskAssignee("test").list();
assertEquals(0, historicTasks.size());
}
repositoryService.deleteDeployment(deployment.getId(), true);
}
use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class RuntimeServiceTest method testDeleteProcessInstance.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testDeleteProcessInstance() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
assertEquals(1, runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count());
String deleteReason = "testing instance deletion";
runtimeService.deleteProcessInstance(processInstance.getId(), deleteReason);
assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count());
// ACT-848
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
assertEquals(deleteReason, historicTaskInstance.getDeleteReason());
HistoricProcessInstance historicInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(historicInstance);
assertEquals(deleteReason, historicInstance.getDeleteReason());
assertNotNull(historicInstance.getEndTime());
}
}
use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class AbstractActivitiTestCase method assertProcessEnded.
public void assertProcessEnded(final String processInstanceId) {
ProcessInstance processInstance = processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
if (processInstance != null) {
throw new AssertionFailedError("Expected finished process instance '" + processInstanceId + "' but it was still in the db");
}
// Verify historical data if end times are correctly set
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
// process instance
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
assertEquals(processInstanceId, historicProcessInstance.getId());
assertNotNull("Historic process instance has no start time", historicProcessInstance.getStartTime());
assertNotNull("Historic process instance has no end time", historicProcessInstance.getEndTime());
// tasks
List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstanceId).list();
if (historicTaskInstances != null && historicTaskInstances.size() > 0) {
for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) {
assertEquals(processInstanceId, historicTaskInstance.getProcessInstanceId());
assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no start time", historicTaskInstance.getStartTime());
assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no end time", historicTaskInstance.getEndTime());
}
}
// activities
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list();
if (historicActivityInstances != null && historicActivityInstances.size() > 0) {
for (HistoricActivityInstance historicActivityInstance : historicActivityInstances) {
assertEquals(processInstanceId, historicActivityInstance.getProcessInstanceId());
assertNotNull("Historic activity instance " + historicActivityInstance.getActivityId() + " has no start time", historicActivityInstance.getStartTime());
assertNotNull("Historic activity instance " + historicActivityInstance.getActivityId() + " has no end time", historicActivityInstance.getEndTime());
}
}
}
}
use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class HistoricTaskInstanceQueryImpl method executeList.
@Override
public List<HistoricTaskInstance> executeList(CommandContext commandContext, Page page) {
ensureVariablesInitialized();
checkQueryOk();
List<HistoricTaskInstance> tasks = null;
if (includeTaskLocalVariables || includeProcessVariables) {
tasks = commandContext.getHistoricTaskInstanceEntityManager().findHistoricTaskInstancesAndVariablesByQueryCriteria(this);
} else {
tasks = commandContext.getHistoricTaskInstanceEntityManager().findHistoricTaskInstancesByQueryCriteria(this);
}
if (tasks != null) {
for (HistoricTaskInstance task : tasks) {
localize(task);
}
}
return tasks;
}
Aggregations