use of org.jbpm.services.task.exception.PermissionDeniedException in project jbpm by kiegroup.
the class LifeCycleBaseTest method testCompleteAlreadyCompleted.
@Test
public void testCompleteAlreadyCompleted() {
// 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();
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());
try {
taskService.complete(taskId, "Darth Vader", null);
Fail.fail("Task should already be completed and thus can't be completed again");
} catch (PermissionDeniedException e) {
// expected
}
}
use of org.jbpm.services.task.exception.PermissionDeniedException in project jbpm by kiegroup.
the class LifeCycleBaseTest method testDelegateFromReservedWithIncorrectUser.
@Test
public void testDelegateFromReservedWithIncorrectUser() 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();
// Claim and Reserved
taskService.claim(taskId, "Darth Vader");
Task task1 = taskService.getTaskById(taskId);
assertEquals(Status.Reserved, task1.getTaskData().getStatus());
assertEquals("Darth Vader", task1.getTaskData().getActualOwner().getId());
// Check was not delegated
PermissionDeniedException denied = null;
try {
taskService.delegate(taskId, "Bobba Fet", "Tony Stark");
} catch (PermissionDeniedException e) {
denied = e;
}
assertNotNull("Should get permissed denied exception", denied);
Task task2 = taskService.getTaskById(taskId);
User user = createUser("Darth Vader");
assertTrue(task2.getPeopleAssignments().getPotentialOwners().contains(user));
user = createUser("Tony Stark");
assertFalse(task2.getPeopleAssignments().getPotentialOwners().contains(user));
assertEquals("Darth Vader", task2.getTaskData().getActualOwner().getId());
assertEquals(Status.Reserved, task2.getTaskData().getStatus());
}
use of org.jbpm.services.task.exception.PermissionDeniedException in project jbpm by kiegroup.
the class LifeCycleBaseTest method testStartFromReservedWithIncorrectUser.
@Test
public void testStartFromReservedWithIncorrectUser() {
// 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());
assertEquals("Bobba Fet", task1.getTaskData().getActualOwner().getId());
// Should change not change
PermissionDeniedException denied = null;
try {
taskService.start(taskId, "Tony Stark");
} catch (PermissionDeniedException e) {
denied = e;
}
assertNotNull("Should get permissed denied exception", denied);
Task task2 = taskService.getTaskById(taskId);
assertEquals(Status.Reserved, task2.getTaskData().getStatus());
assertEquals("Bobba Fet", task1.getTaskData().getActualOwner().getId());
}
use of org.jbpm.services.task.exception.PermissionDeniedException in project jbpm by kiegroup.
the class LifeCycleBaseTest method testReleaseWithIncorrectUser.
@Test
public void testReleaseWithIncorrectUser() {
// 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.claim(taskId, "Darth Vader");
Task task1 = taskService.getTaskById(taskId);
assertEquals(Status.Reserved, task1.getTaskData().getStatus());
assertEquals("Darth Vader", task1.getTaskData().getActualOwner().getId());
// Check is not changed
PermissionDeniedException denied = null;
try {
taskService.release(taskId, "Bobba Fet");
} catch (PermissionDeniedException e) {
denied = e;
}
assertNotNull("Should get permissed denied exception", denied);
Task task2 = taskService.getTaskById(taskId);
assertEquals(Status.Reserved, task2.getTaskData().getStatus());
assertEquals("Darth Vader", task2.getTaskData().getActualOwner().getId());
}
use of org.jbpm.services.task.exception.PermissionDeniedException in project jbpm by kiegroup.
the class LifeCycleBaseTest method testStartFromReadyStateWithIncorrectPotentialOwner.
@Test
public void testStartFromReadyStateWithIncorrectPotentialOwner() {
// 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.
List<TaskSummary> tasksAssignedAsPotentialOwner = taskService.getTasksAssignedAsPotentialOwner("Bobba Fet", "en-UK");
assertEquals(1, tasksAssignedAsPotentialOwner.size());
Task task1 = taskService.getTaskById(taskId);
assertEquals(Status.Ready, task1.getTaskData().getStatus());
// State should not change as user isn't potential owner
PermissionDeniedException denied = null;
try {
taskService.start(taskId, "Tony Stark");
} catch (PermissionDeniedException e) {
denied = e;
}
assertNotNull("Should get permissed denied exception", denied);
Task task2 = taskService.getTaskById(taskId);
assertEquals(Status.Ready, task2.getTaskData().getStatus());
assertNull(task2.getTaskData().getActualOwner());
}
Aggregations