Search in sources :

Example 66 with TaskSummary

use of org.kie.api.task.model.TaskSummary in project jbpm by kiegroup.

the class TaskQueryServiceBaseTest method testGetTasksAssignedAsPotentialOwnerCheckSubject.

@Test
public void testGetTasksAssignedAsPotentialOwnerCheckSubject() {
    // One potential owner, should go straight to state Reserved
    String str = "(with (new Task()) { subject = 'test subject', priority = 55, taskData = (with( new TaskData()) {skipable=true } ), ";
    str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet')  ],businessAdministrators = [ new User('Administrator') ], }),";
    str += "name = 'This is my task name' })";
    Task task = TaskFactory.evalTask(new StringReader(str));
    taskService.addTask(task, new HashMap<String, Object>());
    List<String> groupIds = new ArrayList<String>();
    groupIds.add("Crusaders");
    List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("Bobba Fet", groupIds);
    assertEquals(1, tasks.size());
    assertEquals("Bobba Fet", tasks.get(0).getActualOwnerId());
    assertEquals(true, tasks.get(0).isSkipable());
    assertEquals("test subject", tasks.get(0).getSubject());
}
Also used : Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) StringReader(java.io.StringReader) ArrayList(java.util.ArrayList) TaskSummary(org.kie.api.task.model.TaskSummary) Test(org.junit.Test)

Example 67 with TaskSummary

use of org.kie.api.task.model.TaskSummary in project jbpm by kiegroup.

the class TaskQueryServiceBaseTest method testGetTasksAssignedAsPotentialOwnerWithExcluded.

@Test
public void testGetTasksAssignedAsPotentialOwnerWithExcluded() {
    // One potential owner, should go straight to state Reserved
    String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
    str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet'), new User('Darth Vader') ], excludedOwners = [new User('Darth Vader')],businessAdministrators = [ new User('Administrator') ], }),";
    str += "name =  'This is my task name' })";
    Task task = TaskFactory.evalTask(new StringReader(str));
    taskService.addTask(task, new HashMap<String, Object>());
    List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("Bobba Fet", "en-UK");
    assertEquals(1, tasks.size());
    tasks = taskService.getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
    assertEquals(0, tasks.size());
}
Also used : Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) StringReader(java.io.StringReader) TaskSummary(org.kie.api.task.model.TaskSummary) Test(org.junit.Test)

Example 68 with TaskSummary

use of org.kie.api.task.model.TaskSummary in project jbpm by kiegroup.

the class TaskQueryServiceBaseTest method testGetTasksOwnedWithUserStatusLangOneTaskCompleted.

@Test
public void testGetTasksOwnedWithUserStatusLangOneTaskCompleted() {
    // One potential owner, should go straight to state Reserved
    String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
    str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet')  ],businessAdministrators = [ new User('Administrator') ], }),";
    str += "name =  'This is my task name' })";
    Task task = TaskFactory.evalTask(new StringReader(str));
    taskService.addTask(task, new HashMap<String, Object>());
    List<Status> statuses = new ArrayList<Status>();
    statuses.add(Status.Completed);
    List<TaskSummary> tasks = taskService.getTasksOwnedByStatus("Bobba Fet", statuses, "en-UK");
    assertEquals(0, tasks.size());
}
Also used : Status(org.kie.api.task.model.Status) Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) StringReader(java.io.StringReader) ArrayList(java.util.ArrayList) TaskSummary(org.kie.api.task.model.TaskSummary) Test(org.junit.Test)

Example 69 with TaskSummary

use of org.kie.api.task.model.TaskSummary in project jbpm by kiegroup.

the class TaskQueryServiceBaseTest method testGetTasksAssignedAsPotentialOwnerWithUserGroupsLangOffsetCountTwoTasksTwoMaxResults.

@Test
public void testGetTasksAssignedAsPotentialOwnerWithUserGroupsLangOffsetCountTwoTasksTwoMaxResults() {
    // One potential owner, should go straight to state Reserved
    String str1 = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
    str1 += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet') ],businessAdministrators = [ new User('Administrator') ], }),";
    str1 += "name =  'First task' })";
    String str2 = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
    str2 += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet') ],businessAdministrators = [ new User('Administrator') ], }),";
    str2 += "name = 'Second task' })";
    Task task1 = TaskFactory.evalTask(new StringReader(str1));
    taskService.addTask(task1, new HashMap<String, Object>());
    Task task2 = TaskFactory.evalTask(new StringReader(str2));
    taskService.addTask(task2, new HashMap<String, Object>());
    List<String> groupIds = new ArrayList<String>();
    groupIds.add("Crusaders");
    List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("Bobba Fet", groupIds, null, 0, 2);
    assertEquals(2, tasks.size());
// FIXME tasks are returned in random order
// assertEquals("First task", tasks.get(0).getName());
// assertEquals("Second task", tasks.get(1).getName());
}
Also used : Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) StringReader(java.io.StringReader) ArrayList(java.util.ArrayList) TaskSummary(org.kie.api.task.model.TaskSummary) Test(org.junit.Test)

Example 70 with TaskSummary

use of org.kie.api.task.model.TaskSummary in project jbpm by kiegroup.

the class TaskQueryServiceBaseTest method testGetTasksOwnedByExpirationDateWithUserStatusDateOneTaskCompleted.

@Test
public void testGetTasksOwnedByExpirationDateWithUserStatusDateOneTaskCompleted() {
    // One potential owner, should go straight to state Reserved
    String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { expirationTime = new Date( 10000000 ), } ), ";
    str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet')  ],businessAdministrators = [ new User('Administrator') ], }),";
    str += "name = 'This is my task name' })";
    Task task = TaskFactory.evalTask(new StringReader(str));
    taskService.addTask(task, new HashMap<String, Object>());
    List<Status> statuses = new ArrayList<Status>();
    statuses.add(Status.Completed);
    Date date = new Date(10000000);
    List<TaskSummary> tasks = taskService.getTasksOwnedByExpirationDate("Bobba Fet", statuses, date);
    assertEquals(0, tasks.size());
}
Also used : Status(org.kie.api.task.model.Status) Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) StringReader(java.io.StringReader) ArrayList(java.util.ArrayList) TaskSummary(org.kie.api.task.model.TaskSummary) Date(java.util.Date) Test(org.junit.Test)

Aggregations

TaskSummary (org.kie.api.task.model.TaskSummary)371 Test (org.junit.Test)327 HashMap (java.util.HashMap)132 QueryFilter (org.kie.internal.query.QueryFilter)126 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)100 Task (org.kie.api.task.model.Task)91 ArrayList (java.util.ArrayList)87 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)86 KieSession (org.kie.api.runtime.KieSession)84 TaskService (org.kie.api.task.TaskService)66 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)58 StringReader (java.io.StringReader)55 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)49 QueryContext (org.kie.api.runtime.query.QueryContext)49 Status (org.kie.api.task.model.Status)47 InternalTask (org.kie.internal.task.api.model.InternalTask)47 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)41 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)38 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)36 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)28