use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class TaskQueryTest method testQueryByDescriptionLikeOr.
public void testQueryByDescriptionLikeOr() {
TaskQuery query = taskService.createTaskQuery().or().taskId("invalid").taskDescriptionLike("%gonzo%");
assertThat(query.singleResult()).isNotNull();
assertThat(query.list()).hasSize(1);
assertThat(query.count()).isEqualTo(1);
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class TaskQueryTest method testQueryByInvalidNameLike.
public void testQueryByInvalidNameLike() {
TaskQuery query = taskService.createTaskQuery().taskNameLike("1");
assertThat(query.singleResult()).isNull();
assertThat(query.list()).hasSize(0);
assertThat(query.count()).isEqualTo(0);
assertThatExceptionOfType(ActivitiIllegalArgumentException.class).isThrownBy(() -> taskService.createTaskQuery().or().taskId("invalid").taskNameLike(null).singleResult());
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class TaskQueryTest method testQueryByInvalidNameLikeOr.
public void testQueryByInvalidNameLikeOr() {
TaskQuery query = taskService.createTaskQuery().or().taskId("invalid").taskNameLike("1");
assertThat(query.singleResult()).isNull();
assertThat(query.list()).hasSize(0);
assertThat(query.count()).isEqualTo(0);
assertThatExceptionOfType(ActivitiIllegalArgumentException.class).isThrownBy(() -> taskService.createTaskQuery().or().taskId("invalid").taskNameLike(null).singleResult());
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class TaskQueryTest method testQueryByCandidateOrAssigned.
public void testQueryByCandidateOrAssigned() {
TaskQuery query = taskService.createTaskQuery().taskCandidateOrAssigned(KERMIT, KERMITSGROUPS);
assertThat(query.count()).isEqualTo(11);
List<Task> tasks = query.list();
assertThat(tasks).hasSize(11);
// if dbIdentityUsed set false in process engine configuration of using
// custom session factory of GroupIdentityManager
ArrayList<String> candidateGroups = new ArrayList<String>();
candidateGroups.add("management");
candidateGroups.add("accountancy");
candidateGroups.add("noexist");
query = taskService.createTaskQuery().taskCandidateGroupIn(candidateGroups).taskCandidateOrAssigned(KERMIT, KERMITSGROUPS);
assertThat(query.count()).isEqualTo(11);
tasks = query.list();
assertThat(tasks).hasSize(11);
query = taskService.createTaskQuery().taskCandidateOrAssigned(FOZZIE, FOZZIESGROUPS);
assertThat(query.count()).isEqualTo(3);
assertThat(query.list()).hasSize(3);
// create a new task that no identity link and assignee to kermit
Task task = taskService.newTask();
task.setName("assigneeToKermit");
task.setDescription("testTask description");
task.setPriority(3);
task.setAssignee(KERMIT);
taskService.saveTask(task);
query = taskService.createTaskQuery().taskCandidateOrAssigned(KERMIT, KERMITSGROUPS);
assertThat(query.count()).isEqualTo(12);
tasks = query.list();
assertThat(tasks).hasSize(12);
Task assigneeToKermit = taskService.createTaskQuery().taskName("assigneeToKermit").singleResult();
taskService.deleteTask(assigneeToKermit.getId());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
historyService.deleteHistoricTaskInstance(assigneeToKermit.getId());
}
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class TaskQueryTest method testQueryByPriority.
public void testQueryByPriority() {
TaskQuery query = taskService.createTaskQuery().taskPriority(100);
assertThat(query.singleResult()).isNull();
assertThat(query.list()).hasSize(0);
assertThat(query.count()).isEqualTo(0);
query = taskService.createTaskQuery().taskMinPriority(50);
assertThat(query.list()).hasSize(3);
query = taskService.createTaskQuery().taskMinPriority(10);
assertThat(query.list()).hasSize(5);
query = taskService.createTaskQuery().taskMaxPriority(10);
assertThat(query.list()).hasSize(9);
query = taskService.createTaskQuery().taskMaxPriority(3);
assertThat(query.list()).hasSize(6);
}
Aggregations