use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class HistoryServiceTest method testHistoricTaskInstanceQueryByDeploymentIdIn.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" })
public void testHistoricTaskInstanceQueryByDeploymentIdIn() {
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());
List<String> deploymentIds = new ArrayList<String>();
deploymentIds.add(deployment.getId());
HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentIdIn(deploymentIds);
assertEquals(5, taskInstanceQuery.count());
List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list();
assertNotNull(taskInstances);
assertEquals(5, taskInstances.size());
deploymentIds.add("invalid");
taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentIdIn(deploymentIds);
assertEquals(5, taskInstanceQuery.count());
deploymentIds = new ArrayList<String>();
deploymentIds.add("invalid");
taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentIdIn(deploymentIds);
assertEquals(0, taskInstanceQuery.count());
}
use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class ProcessInstanceLogQueryTest method testIncludeTasksandComments.
public void testIncludeTasksandComments() {
ProcessInstanceHistoryLog log = historyService.createProcessInstanceHistoryLogQuery(processInstanceId).includeTasks().includeComments().singleResult();
List<HistoricData> events = log.getHistoricData();
assertEquals(5, events.size());
for (int i = 0; i < 5; i++) {
HistoricData event = events.get(i);
if (i < 2) {
// tasks are created before comments
assertTrue(event instanceof HistoricTaskInstance);
} else {
assertTrue(event instanceof Comment);
}
}
}
use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class HistoricTaskAndVariablesQueryTest method testQueryWithPagingAndVariables.
public void testQueryWithPagingAndVariables() {
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().includeTaskLocalVariables().orderByTaskPriority().desc().listPage(0, 1);
assertEquals(1, tasks.size());
HistoricTaskInstance task = tasks.get(0);
Map<String, Object> variableMap = task.getTaskLocalVariables();
assertEquals(2, variableMap.size());
assertEquals("someVariable", variableMap.get("testVar"));
assertEquals(123, variableMap.get("testVar2"));
tasks = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().includeTaskLocalVariables().orderByTaskPriority().asc().listPage(1, 2);
assertEquals(2, tasks.size());
task = tasks.get(1);
variableMap = task.getTaskLocalVariables();
assertEquals(2, variableMap.size());
assertEquals("someVariable", variableMap.get("testVar"));
assertEquals(123, variableMap.get("testVar2"));
tasks = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().includeTaskLocalVariables().orderByTaskPriority().asc().listPage(2, 4);
assertEquals(1, tasks.size());
task = tasks.get(0);
variableMap = task.getTaskLocalVariables();
assertEquals(2, variableMap.size());
assertEquals("someVariable", variableMap.get("testVar"));
assertEquals(123, variableMap.get("testVar2"));
tasks = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().includeTaskLocalVariables().orderByTaskPriority().asc().listPage(4, 2);
assertEquals(0, tasks.size());
}
}
use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class HistoricTaskAndVariablesQueryTest method testQueryWithIncludeTaskVariableAndTaskCategory.
// Unit test for https://activiti.atlassian.net/browse/ACT-4152
public void testQueryWithIncludeTaskVariableAndTaskCategory() {
List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery().taskAssignee("gonzo").list();
for (HistoricTaskInstance task : tasks) {
assertNotNull(task.getCategory());
assertEquals("testCategory", task.getCategory());
}
tasks = historyService.createHistoricTaskInstanceQuery().taskAssignee("gonzo").includeTaskLocalVariables().list();
for (HistoricTaskInstance task : tasks) {
assertNotNull(task.getCategory());
assertEquals("testCategory", task.getCategory());
}
tasks = historyService.createHistoricTaskInstanceQuery().taskAssignee("gonzo").includeProcessVariables().list();
for (HistoricTaskInstance task : tasks) {
assertNotNull(task.getCategory());
assertEquals("testCategory", task.getCategory());
}
}
use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class HistoryServiceTest method testLocalizeTasks.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testLocalizeTasks() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()).list();
assertEquals(1, tasks.size());
assertEquals("my task", tasks.get(0).getName());
assertNull(tasks.get(0).getDescription());
ObjectNode infoNode = dynamicBpmnService.changeLocalizationName("en-GB", "theTask", "My localized name");
dynamicBpmnService.changeLocalizationDescription("en-GB".toString(), "theTask", "My localized description", infoNode);
dynamicBpmnService.saveProcessDefinitionInfo(processInstance.getProcessDefinitionId(), infoNode);
tasks = historyService.createHistoricTaskInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()).list();
assertEquals(1, tasks.size());
assertEquals("my task", tasks.get(0).getName());
assertNull(tasks.get(0).getDescription());
tasks = historyService.createHistoricTaskInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()).locale("en-GB").list();
assertEquals(1, tasks.size());
assertEquals("My localized name", tasks.get(0).getName());
assertEquals("My localized description", tasks.get(0).getDescription());
tasks = historyService.createHistoricTaskInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()).listPage(0, 10);
assertEquals(1, tasks.size());
assertEquals("my task", tasks.get(0).getName());
assertNull(tasks.get(0).getDescription());
tasks = historyService.createHistoricTaskInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()).locale("en-GB").listPage(0, 10);
assertEquals(1, tasks.size());
assertEquals("My localized name", tasks.get(0).getName());
assertEquals("My localized description", tasks.get(0).getDescription());
HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();
assertEquals("my task", task.getName());
assertNull(task.getDescription());
task = historyService.createHistoricTaskInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()).locale("en-GB").singleResult();
assertEquals("My localized name", task.getName());
assertEquals("My localized description", task.getDescription());
task = historyService.createHistoricTaskInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();
assertEquals("my task", task.getName());
assertNull(task.getDescription());
}
Aggregations