Search in sources :

Example 26 with TaskQuery

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

Example 27 with TaskQuery

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

Example 28 with TaskQuery

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

Example 29 with TaskQuery

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

Example 30 with TaskQuery

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);
}
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