use of org.kie.api.task.model.Task in project jbpm by kiegroup.
the class LifeCycleBaseTest method testStartFromReadyStateWithPotentialOwner.
@Test
public void testStartFromReadyStateWithPotentialOwner() 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();
// A Task with multiple potential owners moves to "Ready" state until someone claims it.
Task task1 = taskService.getTaskById(taskId);
assertEquals(Status.Ready, task1.getTaskData().getStatus());
// Go straight from Ready to Inprogress
taskService.start(taskId, "Darth Vader");
Task task2 = taskService.getTaskById(taskId);
assertEquals(Status.InProgress, 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 testCompleteWithResults.
@Test
public void testCompleteWithResults() {
// 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();
// 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());
Map<String, Object> params = new HashMap<String, Object>();
params.put("content", "content");
taskService.complete(taskId, "Darth Vader", params);
Task task2 = taskService.getTaskById(taskId);
assertEquals(AccessType.Inline, ((InternalTaskData) task2.getTaskData()).getOutputAccessType());
assertEquals("java.util.HashMap", task2.getTaskData().getOutputType());
long contentId = task2.getTaskData().getOutputContentId();
assertTrue(contentId != -1);
Content content = taskService.getContentById(contentId);
Map<String, Object> unmarshalledObject = (Map<String, Object>) ContentMarshallerHelper.unmarshall(content.getContent(), null);
assertEquals("content", unmarshalledObject.get("content"));
}
use of org.kie.api.task.model.Task in project jbpm by kiegroup.
the class LifeCycleBaseTest method testStopWithIncorrectUser.
@Test
public void testStopWithIncorrectUser() {
// 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();
// 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());
// Should not stop
PermissionDeniedException denied = null;
try {
taskService.stop(taskId, "Bobba Fet");
} catch (PermissionDeniedException e) {
denied = e;
}
assertNotNull("Should get permissed denied exception", denied);
Task task2 = taskService.getTaskById(taskId);
assertEquals(Status.InProgress, 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 testNewTaskWithSinglePotentialOwner.
@Test
public void testNewTaskWithSinglePotentialOwner() {
// 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>());
long taskId = task.getId();
// Task should be assigned to the single potential owner and state set to Reserved
Task task1 = taskService.getTaskById(taskId);
assertEquals(Status.Reserved, task1.getTaskData().getStatus());
String potOwner = "Bobba Fet";
assertEquals(potOwner, task1.getTaskData().getActualOwner().getId());
taskService.getTasksAssignedAsPotentialOwner(potOwner, "en-UK");
}
use of org.kie.api.task.model.Task in project jbpm by kiegroup.
the class LifeCycleBaseTest method testSkipFromReserved.
@Test
public void testSkipFromReserved() {
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { skipable = true} ), ";
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();
// Go straight from Ready
taskService.claim(taskId, "Darth Vader");
// Check is Complete
taskService.skip(taskId, "Darth Vader");
taskService.getTaskById(taskId);
Task task1 = taskService.getTaskById(taskId);
assertEquals(Status.Obsolete, task1.getTaskData().getStatus());
assertEquals("Darth Vader", task1.getTaskData().getActualOwner().getId());
}
Aggregations