use of org.kie.api.task.model.Task in project jbpm by kiegroup.
the class LifeCycleBaseTest method testNominateToUser.
@Test
public void testNominateToUser() {
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
str += "peopleAssignments = (with ( new PeopleAssignments() ) { businessAdministrators = [ new User('Darth Vader'), new User('Bobba Fet') ] } ),";
str += "name = 'This is my task name' })";
Task task = TaskFactory.evalTask(new StringReader(str));
taskService.addTask(task, new HashMap<String, Object>());
long taskId = task.getId();
List<OrganizationalEntity> potentialOwners = new ArrayList<OrganizationalEntity>(1);
User user = createUser("Jabba Hutt");
potentialOwners.add(user);
taskService.nominate(taskId, "Darth Vader", potentialOwners);
// shouldn't affect the assignments
Task task1 = taskService.getTaskById(taskId);
assertEquals(task1.getTaskData().getActualOwner().getId(), "Jabba Hutt");
assertEquals(task1.getTaskData().getStatus(), Status.Reserved);
}
use of org.kie.api.task.model.Task in project jbpm by kiegroup.
the class LifeCycleBaseTest method testExitFromReady.
@Test
public void testExitFromReady() {
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { skipable = false} ), ";
str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet'), 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>());
long taskId = task.getId();
task = taskService.getTaskById(taskId);
assertEquals(Status.Ready, task.getTaskData().getStatus());
taskService.exit(taskId, "Administrator");
Task task1 = taskService.getTaskById(taskId);
assertEquals(Status.Exited, task1.getTaskData().getStatus());
}
use of org.kie.api.task.model.Task in project jbpm by kiegroup.
the class LifeCycleBaseTest method testCompleteWithRestrictedGroups.
@Test
public void testCompleteWithRestrictedGroups() {
// 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 Group('analyst'), 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>());
long taskId = task.getId();
List<OrganizationalEntity> potOwners = task.getPeopleAssignments().getPotentialOwners();
assertNotNull(potOwners);
assertEquals(1, potOwners.size());
assertEquals("Crusaders", potOwners.get(0).getId());
// Go straight from Ready to Inprogress
taskService.start(taskId, "Darth Vader");
Task task1 = taskService.getTaskById(taskId);
assertEquals(Status.InProgress, task1.getTaskData().getStatus());
assertEquals("Darth Vader", task1.getTaskData().getActualOwner().getId());
// Check is Complete
taskService.complete(taskId, "Darth Vader", null);
Task task2 = taskService.getTaskById(taskId);
assertEquals(Status.Completed, task2.getTaskData().getStatus());
assertEquals("Darth Vader", task2.getTaskData().getActualOwner().getId());
}
use of org.kie.api.task.model.Task in project jbpm by kiegroup.
the class LifeCycleBaseTest method testExitFromInProgress.
@Test
public void testExitFromInProgress() {
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { skipable = false} ), ";
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>());
long taskId = task.getId();
task = taskService.getTaskById(taskId);
assertEquals(Status.Reserved, task.getTaskData().getStatus());
taskService.start(taskId, "Bobba Fet");
task = taskService.getTaskById(taskId);
assertEquals(Status.InProgress, task.getTaskData().getStatus());
taskService.exit(taskId, "Administrator");
Task task1 = taskService.getTaskById(taskId);
assertEquals(Status.Exited, task1.getTaskData().getStatus());
}
use of org.kie.api.task.model.Task in project jbpm by kiegroup.
the class LifeCycleBaseTest method testForwardFromReady.
@Test
public void testForwardFromReady() throws Exception {
// 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') ],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>());
long taskId = task.getId();
// Check is Forwarded
taskService.forward(taskId, "Darth Vader", "Tony Stark");
Task task2 = taskService.getTaskById(taskId);
assertFalse(task2.getPeopleAssignments().getPotentialOwners().contains(createUser("Darth Vader")));
assertTrue(task2.getPeopleAssignments().getPotentialOwners().contains(createUser("Tony Stark")));
assertNull(task2.getTaskData().getActualOwner());
assertEquals(Status.Ready, task2.getTaskData().getStatus());
}
Aggregations