use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class TaskQueryTest method testQueryByInvalidDescription.
public void testQueryByInvalidDescription() {
TaskQuery query = taskService.createTaskQuery().taskDescription("invalid");
assertThat(query.singleResult()).isNull();
assertThat(query.list()).hasSize(0);
assertThat(query.count()).isEqualTo(0);
assertThatExceptionOfType(ActivitiIllegalArgumentException.class).isThrownBy(() -> taskService.createTaskQuery().or().taskId("invalid").taskDescription(null).list());
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class TaskQueryTest method testQueryByCandidateGroupInOrUsingUserGroupLookupProxy.
public void testQueryByCandidateGroupInOrUsingUserGroupLookupProxy() {
// don't specify groups in query calls, instead get them through UserGroupLookupProxy (which could be remote service)
Mockito.when(userGroupManager.getUserGroups(KERMIT)).thenReturn(KERMITSGROUPS);
Mockito.when(userGroupManager.getUserGroups(GONZO)).thenReturn(GONZOSGROUPS);
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).taskCandidateGroupIn(groups).endOr();
assertThat(query.count()).isEqualTo(11);
assertThat(query.list()).hasSize(11);
query = taskService.createTaskQuery().or().taskCandidateUser(KERMIT).taskCandidateGroup("unexisting").endOr();
assertThat(query.count()).isEqualTo(6);
assertThat(query.list()).hasSize(6);
query = taskService.createTaskQuery().or().taskCandidateUser(KERMIT).taskCandidateGroupIn(groups).endOr().or().taskCandidateUser(GONZO).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 testQueryByInvalidDescriptionLikeOr.
public void testQueryByInvalidDescriptionLikeOr() {
TaskQuery query = taskService.createTaskQuery().or().taskId("invalid").taskDescriptionLike("invalid");
assertThat(query.singleResult()).isNull();
assertThat(query.list()).hasSize(0);
assertThat(query.count()).isEqualTo(0);
assertThatExceptionOfType(ActivitiIllegalArgumentException.class).isThrownBy(() -> taskService.createTaskQuery().or().taskId("invalid").taskDescriptionLike(null).list());
}
use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.
the class TaskQueryTest method testQueryByCandidateGroupIn.
public void testQueryByCandidateGroupIn() {
List<String> groups = asList("management", "accountancy");
TaskQuery queryForException = taskService.createTaskQuery().taskCandidateGroupIn(groups);
assertThat(queryForException.count()).isEqualTo(5);
assertThat(queryForException.list()).hasSize(5);
assertThatExceptionOfType(ActivitiException.class).isThrownBy(() -> queryForException.singleResult());
TaskQuery query = taskService.createTaskQuery().taskCandidateUser(KERMIT, groups);
assertThat(query.count()).isEqualTo(11);
assertThat(query.list()).hasSize(11);
query = taskService.createTaskQuery().taskCandidateUser(KERMIT, asList("unexisting"));
assertThat(query.count()).isEqualTo(6);
assertThat(query.list()).hasSize(6);
query = taskService.createTaskQuery().taskCandidateUser("unexisting", asList("unexisting"));
assertThat(query.count()).isEqualTo(0);
assertThat(query.list()).hasSize(0);
// Unexisting groups or groups that don't have candidate tasks shouldn't influence other results
groups = asList("management", "accountancy", "sales", "unexising");
query = taskService.createTaskQuery().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 testQueryByNameLike.
public void testQueryByNameLike() {
TaskQuery query = taskService.createTaskQuery().taskNameLike("gonzo%");
assertThat(query.singleResult()).isNotNull();
assertThat(query.list()).hasSize(1);
assertThat(query.count()).isEqualTo(1);
}
Aggregations