Search in sources :

Example 31 with TaskQuery

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());
}
Also used : TaskQuery(org.activiti.engine.task.TaskQuery) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException)

Example 32 with TaskQuery

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);
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) TaskQuery(org.activiti.engine.task.TaskQuery)

Example 33 with TaskQuery

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());
}
Also used : TaskQuery(org.activiti.engine.task.TaskQuery) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException)

Example 34 with TaskQuery

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);
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) TaskQuery(org.activiti.engine.task.TaskQuery)

Example 35 with TaskQuery

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);
}
Also used : TaskQuery(org.activiti.engine.task.TaskQuery)

Aggregations

TaskQuery (org.activiti.engine.task.TaskQuery)120 Task (org.activiti.engine.task.Task)47 Deployment (org.activiti.engine.test.Deployment)30 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)21 ActivitiException (org.activiti.engine.ActivitiException)20 ArrayList (java.util.ArrayList)18 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)12 SimpleDateFormat (java.text.SimpleDateFormat)8 Date (java.util.Date)8 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)7 HashMap (java.util.HashMap)6 InvalidArgumentException (org.alfresco.rest.framework.core.exceptions.InvalidArgumentException)4 Test (org.junit.jupiter.api.Test)4 Map (java.util.Map)3 HistoricVariableInstance (org.activiti.engine.history.HistoricVariableInstance)3 HistoricVariableInstanceEntity (org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity)3 Job (org.activiti.engine.runtime.Job)3 IdentityLink (org.activiti.engine.task.IdentityLink)3 HashSet (java.util.HashSet)2 List (java.util.List)2