Search in sources :

Example 36 with TaskQuery

use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.

the class TaskQueryTest method testQueryByDelegationStateOr.

public void testQueryByDelegationStateOr() {
    TaskQuery query = taskService.createTaskQuery().or().taskId("invalid").taskDelegationState(null);
    assertThat(query.count()).isEqualTo(12);
    assertThat(query.list()).hasSize(12);
    query = taskService.createTaskQuery().or().taskId("invalid").taskDelegationState(DelegationState.PENDING);
    assertThat(query.count()).isEqualTo(0);
    assertThat(query.list()).hasSize(0);
    query = taskService.createTaskQuery().or().taskId("invalid").taskDelegationState(DelegationState.RESOLVED);
    assertThat(query.count()).isEqualTo(0);
    assertThat(query.list()).hasSize(0);
    String taskId = taskService.createTaskQuery().or().taskId("invalid").taskAssignee(GONZO).singleResult().getId();
    taskService.delegateTask(taskId, KERMIT);
    query = taskService.createTaskQuery().or().taskId("invalid").taskDelegationState(null);
    assertThat(query.count()).isEqualTo(11);
    assertThat(query.list()).hasSize(11);
    query = taskService.createTaskQuery().or().taskId("invalid").taskDelegationState(DelegationState.PENDING);
    assertThat(query.count()).isEqualTo(1);
    assertThat(query.list()).hasSize(1);
    query = taskService.createTaskQuery().or().taskId("invalid").taskDelegationState(DelegationState.RESOLVED);
    assertThat(query.count()).isEqualTo(0);
    assertThat(query.list()).hasSize(0);
    taskService.resolveTask(taskId);
    query = taskService.createTaskQuery().or().taskId("invalid").taskDelegationState(null);
    assertThat(query.count()).isEqualTo(11);
    assertThat(query.list()).hasSize(11);
    query = taskService.createTaskQuery().or().taskId("invalid").taskDelegationState(DelegationState.PENDING);
    assertThat(query.count()).isEqualTo(0);
    assertThat(query.list()).hasSize(0);
    query = taskService.createTaskQuery().or().taskId("invalid").taskDelegationState(DelegationState.RESOLVED);
    assertThat(query.count()).isEqualTo(1);
    assertThat(query.list()).hasSize(1);
}
Also used : TaskQuery(org.activiti.engine.task.TaskQuery)

Example 37 with TaskQuery

use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.

the class TaskQueryTest method testQueryByCandidateGroupOr.

public void testQueryByCandidateGroupOr() {
    TaskQuery query = taskService.createTaskQuery().or().taskId("invalid").taskCandidateGroup("management");
    assertThat(query.count()).isEqualTo(3);
    assertThat(query.list()).hasSize(3);
    assertThatExceptionOfType(ActivitiException.class).isThrownBy(() -> query.singleResult());
    TaskQuery querySales = taskService.createTaskQuery().or().taskId("invalid").taskCandidateGroup("sales");
    assertThat(querySales.count()).isEqualTo(0);
    assertThat(querySales.list()).hasSize(0);
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) TaskQuery(org.activiti.engine.task.TaskQuery)

Example 38 with TaskQuery

use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.

the class TaskQueryTest method testQueryByInvalidNameIn.

public void testQueryByInvalidNameIn() {
    final List<String> taskNameList = new ArrayList<String>(1);
    taskNameList.add("invalid");
    TaskQuery query = taskService.createTaskQuery().taskNameIn(taskNameList);
    assertThat(query.list()).hasSize(0);
    assertThat(query.count()).isEqualTo(0);
    assertThatExceptionOfType(ActivitiIllegalArgumentException.class).isThrownBy(() -> taskService.createTaskQuery().or().taskId("invalid").taskNameIn(null).singleResult());
}
Also used : TaskQuery(org.activiti.engine.task.TaskQuery) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ArrayList(java.util.ArrayList)

Example 39 with TaskQuery

use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.

the class TaskQueryTest method testQueryByCandidateGroup.

public void testQueryByCandidateGroup() {
    TaskQuery query = taskService.createTaskQuery().taskCandidateGroup("management");
    assertThat(query.count()).isEqualTo(3);
    assertThat(query.list()).hasSize(3);
    assertThatExceptionOfType(ActivitiException.class).isThrownBy(() -> query.singleResult());
    TaskQuery querySales = taskService.createTaskQuery().taskCandidateGroup("sales");
    assertThat(querySales.count()).isEqualTo(0);
    assertThat(querySales.list()).hasSize(0);
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) TaskQuery(org.activiti.engine.task.TaskQuery)

Example 40 with TaskQuery

use of org.activiti.engine.task.TaskQuery in project Activiti by Activiti.

the class TaskQueryTest method testQueryByNameInIgnoreCase.

public void testQueryByNameInIgnoreCase() {
    final List<String> taskNameList = new ArrayList<String>(2);
    taskNameList.add("testtask");
    taskNameList.add("gonzotask");
    TaskQuery query = taskService.createTaskQuery().taskNameInIgnoreCase(taskNameList);
    assertThat(query.list()).hasSize(7);
    assertThat(query.count()).isEqualTo(7);
    assertThatExceptionOfType(ActivitiException.class).isThrownBy(() -> query.singleResult());
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) TaskQuery(org.activiti.engine.task.TaskQuery) ArrayList(java.util.ArrayList)

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