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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations