Search in sources :

Example 76 with TaskSummary

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

the class TaskQueryServiceBaseTest method testGetSubTasksAssignedAsPotentialOwnerWithParentUserLangOneTask.

@Ignore("not familiar with sub task concept")
@Test
public void testGetSubTasksAssignedAsPotentialOwnerWithParentUserLangOneTask() {
    // 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() ) { taskStakeholders = [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<TaskSummary> tasks = taskService.getSubTasksAssignedAsPotentialOwner(0, "Bobba Fet");
    assertEquals(1, 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) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 77 with TaskSummary

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

the class TaskQueryServiceBaseTest method testGetTasksAssignedAsPotentialOwnerByStatusByGroupWithUserStatusLangOneTaskReserved.

@Test
public void testGetTasksAssignedAsPotentialOwnerByStatusByGroupWithUserStatusLangOneTaskReserved() {
    // 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<String> groupIds = new ArrayList<String>();
    groupIds.add("Crusaders");
    List<Status> statuses = new ArrayList<Status>();
    statuses.add(Status.Reserved);
    List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwnerByStatusByGroup("Bobba Fet", groupIds, statuses);
    assertEquals(1, tasks.size());
    assertEquals("Bobba Fet", tasks.get(0).getActualOwnerId());
}
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 78 with TaskSummary

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

the class TaskQueryServiceBaseTest method testGetTasksAssignedAsPotentialOwnerWithUserGroupsLangStatus.

@Test
public void testGetTasksAssignedAsPotentialOwnerWithUserGroupsLangStatus() {
    String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
    str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet'), new Group('Crusaders'), ],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<Status> status = new ArrayList<Status>();
    status.add(Status.Ready);
    List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwnerByStatusByGroup("Bobba Fet", groupIds, status);
    assertEquals(1, tasks.size());
    assertNull(tasks.get(0).getActualOwner());
    assertNull(tasks.get(0).getActualOwnerId());
    assertEquals(Status.Ready, tasks.get(0).getStatus());
}
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 79 with TaskSummary

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

the class TaskQueryServiceBaseTest method testModifyTaskName.

@Test
public void testModifyTaskName() {
    // JBPM-4148
    String taskName = "This is my task name";
    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 = '" + taskName + "' })";
    Task task = TaskFactory.evalTask(new StringReader(str));
    List<I18NText> names = new ArrayList<I18NText>();
    I18NText text = TaskModelProvider.getFactory().newI18NText();
    ((InternalI18NText) text).setLanguage("en-UK");
    ((InternalI18NText) text).setText(taskName);
    names.add(text);
    ((InternalTask) task).setNames(names);
    taskService.addTask(task, new HashMap<String, Object>());
    List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("Bobba Fet", "en-UK");
    assertEquals(1, tasks.size());
    assertEquals(taskName, tasks.get(0).getName());
    Task newTask = taskService.getTaskById(tasks.get(0).getId());
    List<I18NText> updatedNames = new ArrayList<I18NText>();
    I18NText updatedName = TaskModelProvider.getFactory().newI18NText();
    ((InternalI18NText) updatedName).setLanguage(newTask.getNames().get(0).getLanguage());
    ((InternalI18NText) updatedName).setText("New task name");
    updatedNames.add(updatedName);
    taskService.setTaskNames(newTask.getId(), updatedNames);
    List<TaskSummary> newTasks = taskService.getTasksAssignedAsPotentialOwner("Bobba Fet", "en-UK");
    assertEquals(1, newTasks.size());
    newTask = taskService.getTaskById(newTasks.get(0).getId());
    assertEquals("New task name", newTask.getNames().get(0).getText());
}
Also used : Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) I18NText(org.kie.api.task.model.I18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) 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 80 with TaskSummary

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

the class TaskQueryServiceBaseTest method testGetTasksByStatusByProcessIdByTaskName.

@Test
public void testGetTasksByStatusByProcessIdByTaskName() {
    // One potential owner, should go straight to state Reserved
    String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) {processInstanceId = 99 } ), ";
    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));
    String otherProcessId = "org.process.task.other";
    ((TaskDataImpl) task.getTaskData()).setProcessId(otherProcessId);
    ;
    taskService.addTask(task, new HashMap<String, Object>());
    str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) {processInstanceId = 100 } ), ";
    str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet')],businessAdministrators = [ new User('Administrator') ], }),";
    str += "name =  'Another name' })";
    task = TaskFactory.evalTask(new StringReader(str));
    String processId = "org.process.task.test";
    ((TaskDataImpl) task.getTaskData()).setProcessId(processId);
    taskService.addTask(task, new HashMap<String, Object>());
    List<Status> statuses = new ArrayList<Status>();
    statuses.add(Status.Reserved);
    List<TaskSummary> tasks = taskService.getTasksByStatusByProcessInstanceIdByTaskName(99L, statuses, "This is my task name");
    assertEquals(1, tasks.size());
    tasks = taskService.getTasksAssignedAsPotentialOwnerByProcessId("Bobba Fet", processId);
    assertEquals(1, tasks.size());
    tasks = taskService.getTasksAssignedAsPotentialOwnerByProcessId("Administrator", processId);
    assertEquals(0, tasks.size());
    tasks = taskService.getTasksAssignedAsPotentialOwnerByProcessId("Bobba Fet", otherProcessId);
    assertEquals(1, tasks.size());
    tasks = taskService.getTasksAssignedAsPotentialOwnerByProcessId("Bobba Fet", "bad.process.id");
    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) TaskDataImpl(org.jbpm.services.task.impl.model.TaskDataImpl) 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