use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class TaskQueryTest method testQueryByAssigneeOr.
public void testQueryByAssigneeOr() {
TaskQuery query = taskService.createTaskQuery().or().taskId("invalid").taskAssignee(GONZO);
assertThat(query.count()).isEqualTo(1);
assertThat(query.list()).hasSize(1);
assertThat(query.singleResult()).isNotNull();
query = taskService.createTaskQuery().or().taskId("invalid").taskAssignee(KERMIT);
assertThat(query.count()).isEqualTo(0);
assertThat(query.list()).hasSize(0);
assertThat(query.singleResult()).isNull();
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class TaskQueryTest method testQueryByCandidateGroupInOr.
public void testQueryByCandidateGroupInOr() {
List<String> groups = asList("management", "accountancy");
TaskQuery queryForException = taskService.createTaskQuery().or().taskId("invalid").taskCandidateGroupIn(groups);
assertThat(queryForException.count()).isEqualTo(5);
assertThat(queryForException.list()).hasSize(5);
assertThatExceptionOfType(ActivitiException.class).isThrownBy(() -> queryForException.singleResult());
TaskQuery query = taskService.createTaskQuery().or().taskCandidateUser(KERMIT, KERMITSGROUPS).taskCandidateGroupIn(groups).endOr();
assertThat(query.count()).isEqualTo(11);
assertThat(query.list()).hasSize(11);
query = taskService.createTaskQuery().or().taskCandidateUser(KERMIT, KERMITSGROUPS).taskCandidateGroup("unexisting").endOr();
assertThat(query.count()).isEqualTo(6);
assertThat(query.list()).hasSize(6);
query = taskService.createTaskQuery().or().taskCandidateUser("unexisting", null).taskCandidateGroup("unexisting").endOr();
assertThat(query.count()).isEqualTo(0);
assertThat(query.list()).hasSize(0);
query = taskService.createTaskQuery().or().taskCandidateUser(KERMIT, KERMITSGROUPS).taskCandidateGroupIn(groups).endOr().or().taskCandidateUser(GONZO, GONZOSGROUPS).taskCandidateGroupIn(groups);
assertThat(query.count()).isEqualTo(5);
assertThat(query.list()).hasSize(5);
// Unexisting groups or groups that don't have candidate tasks shouldn't influence other results
groups = asList("management", "accountancy", "sales", "unexising");
query = taskService.createTaskQuery().or().taskId("invalid").taskCandidateGroupIn(groups);
assertThat(query.count()).isEqualTo(5);
assertThat(query.list()).hasSize(5);
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class TaskQueryTest method testQueryByInvalidNameInOr.
public void testQueryByInvalidNameInOr() {
final List<String> taskNameList = new ArrayList<String>(2);
taskNameList.add("invalid");
TaskQuery query = taskService.createTaskQuery().or().taskNameIn(taskNameList).taskId("invalid");
assertThat(query.list()).hasSize(0);
assertThat(query.count()).isEqualTo(0);
assertThatExceptionOfType(ActivitiException.class).isThrownBy(() -> taskService.createTaskQuery().or().taskId("invalid").taskNameIn(null).singleResult());
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class TaskQueryTest method testQueryNoCriteria.
public void testQueryNoCriteria() {
TaskQuery query = taskService.createTaskQuery();
assertThat(query.count()).isEqualTo(12);
assertThat(query.list()).hasSize(12);
assertThatExceptionOfType(ActivitiException.class).isThrownBy(() -> query.singleResult());
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class TaskQueryTest method testQueryByInvalidName.
public void testQueryByInvalidName() {
TaskQuery query = taskService.createTaskQuery().taskName("invalid");
assertThat(query.singleResult()).isNull();
assertThat(query.list()).hasSize(0);
assertThat(query.count()).isEqualTo(0);
assertThatExceptionOfType(ActivitiIllegalArgumentException.class).isThrownBy(() -> taskService.createTaskQuery().or().taskId("invalid").taskName(null).singleResult());
}
Aggregations