TSK-1441: Enable Admin to complete tasks already claimed by other users
This commit is contained in:
parent
5ddb81a618
commit
81b89e1c08
|
@ -1244,10 +1244,11 @@ public class TaskServiceImpl implements TaskService {
|
|||
throw new InvalidStateException(
|
||||
String.format("Task with Id %s has to be claimed before.", task.getId()));
|
||||
} else if (!taskanaEngine
|
||||
.getEngine()
|
||||
.getCurrentUserContext()
|
||||
.getAccessIds()
|
||||
.contains(task.getOwner())) {
|
||||
.getEngine()
|
||||
.getCurrentUserContext()
|
||||
.getAccessIds()
|
||||
.contains(task.getOwner())
|
||||
&& !taskanaEngine.getEngine().isUserInRole(TaskanaRole.ADMIN)) {
|
||||
throw new InvalidOwnerException(
|
||||
String.format(
|
||||
"Owner of task %s is %s, but current user is %s ",
|
||||
|
|
|
@ -45,6 +45,18 @@ class CompleteTaskAccTest extends AbstractAccTest {
|
|||
assertThat(completedTask.getModified()).isNotEqualTo(completedTask.getCreated());
|
||||
}
|
||||
|
||||
@WithAccessId(user = "admin")
|
||||
@Test
|
||||
void should_completeClaimedTaskByAnotherUser_When_UserIsAdmin() throws Exception {
|
||||
assertThat(TASK_SERVICE.getTask("TKI:000000000000000000000000000000000029").getState())
|
||||
.isEqualTo(TaskState.CLAIMED);
|
||||
Task completedTask = TASK_SERVICE.completeTask("TKI:000000000000000000000000000000000029");
|
||||
assertThat(completedTask).isNotNull();
|
||||
assertThat(completedTask.getCompleted()).isNotNull();
|
||||
assertThat(completedTask.getState()).isEqualTo(TaskState.COMPLETED);
|
||||
assertThat(completedTask.getModified()).isNotEqualTo(completedTask.getCreated());
|
||||
}
|
||||
|
||||
@WithAccessId(user = "admin")
|
||||
@WithAccessId(user = "taskadmin")
|
||||
@TestTemplate
|
||||
|
|
Loading…
Reference in New Issue