Search in sources :

Example 41 with TaskQuery

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

Example 42 with TaskQuery

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

Example 43 with TaskQuery

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

Example 44 with TaskQuery

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

Example 45 with TaskQuery

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

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