Search in sources :

Example 86 with TaskQuery

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

the class TaskQueryTest method testQueryByInvalidDescriptionOr.

public void testQueryByInvalidDescriptionOr() {
    TaskQuery query = taskService.createTaskQuery().or().taskId("invalid").taskDescription("invalid");
    assertNull(query.singleResult());
    assertEquals(0, query.list().size());
    assertEquals(0, query.count());
    try {
        taskService.createTaskQuery().or().taskId("invalid").taskDescription(null).list();
        fail();
    } catch (ActivitiIllegalArgumentException e) {
    }
}
Also used : TaskQuery(org.activiti.engine.task.TaskQuery) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException)

Example 87 with TaskQuery

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

the class TaskQueryTest method testQueryByUnassignedOr.

public void testQueryByUnassignedOr() {
    TaskQuery query = taskService.createTaskQuery().or().taskId("invalid").taskUnassigned();
    assertEquals(11, query.count());
    assertEquals(11, query.list().size());
}
Also used : TaskQuery(org.activiti.engine.task.TaskQuery)

Example 88 with TaskQuery

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

the class TaskQueryTest method testQueryByInvalidTaskIdOr.

public void testQueryByInvalidTaskIdOr() {
    TaskQuery query = taskService.createTaskQuery().or().taskId("invalid").taskName("invalid");
    assertNull(query.singleResult());
    assertEquals(0, query.list().size());
    assertEquals(0, query.count());
    try {
        taskService.createTaskQuery().taskId(null);
        fail("expected exception");
    } catch (ActivitiIllegalArgumentException e) {
    // OK
    }
}
Also used : TaskQuery(org.activiti.engine.task.TaskQuery) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException)

Example 89 with TaskQuery

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

the class TaskQueryTest method testQueryByCandidateOrAssignedOr.

public void testQueryByCandidateOrAssignedOr() {
    TaskQuery query = taskService.createTaskQuery().or().taskId("invalid").taskCandidateOrAssigned("kermit");
    assertEquals(11, query.count());
    List<Task> tasks = query.list();
    assertEquals(11, tasks.size());
    // 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().or().taskId("invalid").taskCandidateGroupIn(candidateGroups).taskCandidateOrAssigned("kermit");
    assertEquals(11, query.count());
    tasks = query.list();
    assertEquals(11, tasks.size());
    query = taskService.createTaskQuery().or().taskId("invalid").taskCandidateOrAssigned("fozzie");
    assertEquals(3, query.count());
    assertEquals(3, query.list().size());
    // 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().or().taskId("invalid").taskCandidateOrAssigned("kermit");
    assertEquals(12, query.count());
    tasks = query.list();
    assertEquals(12, tasks.size());
    Task assigneeToKermit = taskService.createTaskQuery().or().taskId("invalid").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 90 with TaskQuery

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

the class TaskQueryTest method testQueryByNameIn.

public void testQueryByNameIn() {
    final List<String> taskNameList = new ArrayList<String>(2);
    taskNameList.add("testTask");
    taskNameList.add("gonzoTask");
    TaskQuery query = taskService.createTaskQuery().taskNameIn(taskNameList);
    assertEquals(7, query.list().size());
    assertEquals(7, query.count());
    try {
        query.singleResult();
        fail("expected exception");
    } catch (ActivitiException e) {
    // OK
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) TaskQuery(org.activiti.engine.task.TaskQuery) ArrayList(java.util.ArrayList)

Aggregations

TaskQuery (org.activiti.engine.task.TaskQuery)92 Task (org.activiti.engine.task.Task)32 Deployment (org.activiti.engine.test.Deployment)29 ActivitiException (org.activiti.engine.ActivitiException)19 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)19 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)12 ArrayList (java.util.ArrayList)10 SimpleDateFormat (java.text.SimpleDateFormat)8 Date (java.util.Date)7 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)6 DelegateTask (org.activiti.engine.delegate.DelegateTask)3 HistoricVariableInstance (org.activiti.engine.history.HistoricVariableInstance)3 HistoricVariableInstanceEntity (org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity)3 Job (org.activiti.engine.runtime.Job)3 HashMap (java.util.HashMap)2 TaskService (org.activiti.engine.TaskService)2 Test (org.testng.annotations.Test)2 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)1 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)1 PrismValue (com.evolveum.midpoint.prism.PrismValue)1