Search in sources :

Example 81 with WithAccessId

use of pro.taskana.security.WithAccessId in project taskana by Taskana.

the class WorkOnTaskAccTest method testForceCancelClaimOfTaskFromAnotherUser.

@WithAccessId(userName = "user_1_2", groupNames = { "group_1" })
@Test
public void testForceCancelClaimOfTaskFromAnotherUser() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, InvalidStateException, InvalidOwnerException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000031");
    taskService.cancelClaim(claimedTask.getId(), true);
    Task unclaimedTask = taskService.getTask("TKI:000000000000000000000000000000000031");
    assertNotNull(unclaimedTask);
    assertEquals(TaskState.READY, unclaimedTask.getState());
    assertNull(unclaimedTask.getClaimed());
    assertTrue(unclaimedTask.isRead());
    assertNull(unclaimedTask.getOwner());
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 82 with WithAccessId

use of pro.taskana.security.WithAccessId in project taskana by Taskana.

the class WorkOnTaskAccTest method testThrowsExceptionIfCompletingClaimedTaskOfAnotherUser.

@WithAccessId(userName = "user_1_2", groupNames = { "group_1" })
@Test(expected = InvalidOwnerException.class)
public void testThrowsExceptionIfCompletingClaimedTaskOfAnotherUser() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, InvalidStateException, InvalidOwnerException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000034");
    taskService.completeTask(claimedTask.getId());
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 83 with WithAccessId

use of pro.taskana.security.WithAccessId in project taskana by Taskana.

the class WorkOnTaskAccTest method testCancelClaimTask.

@WithAccessId(userName = "user_1_2", groupNames = { "group_1" })
@Test
public void testCancelClaimTask() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, InvalidStateException, InvalidOwnerException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000029");
    taskService.cancelClaim(claimedTask.getId());
    Task unclaimedTask = taskService.getTask("TKI:000000000000000000000000000000000029");
    assertNotNull(unclaimedTask);
    assertEquals(TaskState.READY, unclaimedTask.getState());
    assertNull(unclaimedTask.getClaimed());
    assertTrue(unclaimedTask.isRead());
    assertNull(unclaimedTask.getOwner());
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 84 with WithAccessId

use of pro.taskana.security.WithAccessId in project taskana by Taskana.

the class WorkOnTaskAccTest method testCompleteTask.

@WithAccessId(userName = "user_1_2", groupNames = { "group_1" })
@Test
public void testCompleteTask() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, InvalidStateException, InvalidOwnerException {
    Instant before = Instant.now().minus(Duration.ofSeconds(3L));
    TaskService taskService = taskanaEngine.getTaskService();
    Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000032");
    taskService.completeTask(claimedTask.getId());
    Task completedTask = taskService.getTask("TKI:000000000000000000000000000000000032");
    assertNotNull(completedTask);
    assertEquals(TaskState.COMPLETED, completedTask.getState());
    assertNotNull(completedTask.getCompleted());
    assertEquals(completedTask.getCompleted(), completedTask.getModified());
    assertTrue(completedTask.getCompleted().isAfter(before));
    assertTrue(completedTask.getModified().isAfter(before));
    assertTrue(completedTask.isRead());
    assertEquals("user_1_2", completedTask.getOwner());
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) Instant(java.time.Instant) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 85 with WithAccessId

use of pro.taskana.security.WithAccessId in project taskana by Taskana.

the class DeleteWorkbasketAccTest method testDeleteWorkbasketWhichIsUsed.

@WithAccessId(userName = "user_1_1", groupNames = { "businessadmin" })
@Test(expected = WorkbasketInUseException.class)
public void testDeleteWorkbasketWhichIsUsed() throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException {
    // all rights, DOMAIN_A with Tasks
    Workbasket wb = workbasketService.getWorkbasket("USER_1_1", "DOMAIN_A");
    workbasketService.deleteWorkbasket(wb.getId());
}
Also used : Workbasket(pro.taskana.Workbasket) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Aggregations

Test (org.junit.Test)216 WithAccessId (pro.taskana.security.WithAccessId)216 AbstractAccTest (acceptance.AbstractAccTest)201 TaskService (pro.taskana.TaskService)100 WorkbasketService (pro.taskana.WorkbasketService)78 Task (pro.taskana.Task)57 WorkbasketSummary (pro.taskana.WorkbasketSummary)51 TaskSummary (pro.taskana.TaskSummary)47 TaskanaEngineProxyForTest (pro.taskana.impl.TaskanaEngineProxyForTest)34 Workbasket (pro.taskana.Workbasket)23 Classification (pro.taskana.Classification)21 KeyDomain (pro.taskana.KeyDomain)19 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)19 ArrayList (java.util.ArrayList)17 Instant (java.time.Instant)16 WorkbasketAccessItem (pro.taskana.WorkbasketAccessItem)16 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)15 Connection (java.sql.Connection)10 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)9 TimeInterval (pro.taskana.TimeInterval)8