Search in sources :

Example 46 with WithAccessId

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

the class TransferTaskAccTest method testThrowsExceptionIfTransferWithNoAppendAuthorization.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test(expected = NotAuthorizedException.class)
public void testThrowsExceptionIfTransferWithNoAppendAuthorization() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task task = taskService.getTask("TKI:000000000000000000000000000000000002");
    taskService.transfer(task.getId(), "WBI:100000000000000000000000000000000008");
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 47 with WithAccessId

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

the class TransferTaskAccTest method testDomainChangingWhenTransferTask.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testDomainChangingWhenTransferTask() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
    String domain1 = task.getDomain();
    Task transferedTask = taskService.transfer(task.getId(), "GPK_B_KSC_1", "DOMAIN_B");
    assertNotNull(transferedTask);
    assertNotEquals(domain1, transferedTask.getDomain());
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 48 with WithAccessId

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

the class TransferTaskAccTest method testBulkTransferTaskWithExceptions.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testBulkTransferTaskWithExceptions() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, InvalidStateException, InvalidOwnerException {
    TaskService taskService = taskanaEngine.getTaskService();
    Workbasket wb = taskanaEngine.getWorkbasketService().getWorkbasket("USER_1_1", "DOMAIN_A");
    Instant before = Instant.now();
    ArrayList<String> taskIdList = new ArrayList<>();
    // working
    taskIdList.add("TKI:000000000000000000000000000000000006");
    // NotAuthorized
    taskIdList.add("TKI:000000000000000000000000000000000041");
    // InvalidArgument
    taskIdList.add("");
    // InvalidArgument (added with ""), duplicate
    taskIdList.add(null);
    // TaskNotFound
    taskIdList.add("TKI:000000000000000000000000000000000099");
    BulkOperationResults<String, TaskanaException> results = taskService.transferTasks("WBI:100000000000000000000000000000000006", taskIdList);
    assertTrue(results.containsErrors());
    assertThat(results.getErrorMap().values().size(), equalTo(3));
    // react to result
    for (String taskId : results.getErrorMap().keySet()) {
        TaskanaException ex = results.getErrorForId(taskId);
        if (ex instanceof NotAuthorizedException) {
            System.out.println("NotAuthorizedException on bulkTransfer for taskId=" + taskId);
        } else if (ex instanceof InvalidArgumentException) {
            System.out.println("InvalidArgumentException on bulkTransfer for EMPTY/NULL taskId='" + taskId + "'");
        } else if (ex instanceof TaskNotFoundException) {
            System.out.println("TaskNotFoundException on bulkTransfer for taskId=" + taskId);
        } else {
            fail("Impossible failure Entry registered");
        }
    }
    Task transferredTask = taskService.getTask("TKI:000000000000000000000000000000000006");
    assertNotNull(transferredTask);
    assertTrue(transferredTask.isTransferred());
    assertFalse(transferredTask.isRead());
    assertEquals(TaskState.READY, transferredTask.getState());
    assertThat(transferredTask.getWorkbasketKey(), equalTo(wb.getKey()));
    assertThat(transferredTask.getDomain(), equalTo(wb.getDomain()));
    assertFalse(transferredTask.getModified().isBefore(before));
    assertThat(transferredTask.getOwner(), equalTo(null));
    transferredTask = taskService.getTask("TKI:000000000000000000000000000000000002");
    assertNotNull(transferredTask);
    assertFalse(transferredTask.isTransferred());
    assertEquals("USER_1_1", transferredTask.getWorkbasketKey());
}
Also used : Task(pro.taskana.Task) InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) TaskNotFoundException(pro.taskana.exceptions.TaskNotFoundException) TaskService(pro.taskana.TaskService) Instant(java.time.Instant) ArrayList(java.util.ArrayList) NotAuthorizedException(pro.taskana.exceptions.NotAuthorizedException) Workbasket(pro.taskana.Workbasket) TaskanaException(pro.taskana.exceptions.TaskanaException) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 49 with WithAccessId

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

the class TransferTaskAccTest method testBulkTransferTaskToWorkbasketById.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testBulkTransferTaskToWorkbasketById() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, InvalidStateException, InvalidOwnerException {
    Instant before = Instant.now();
    TaskService taskService = taskanaEngine.getTaskService();
    ArrayList<String> taskIdList = new ArrayList<>();
    taskIdList.add("TKI:000000000000000000000000000000000004");
    taskIdList.add("TKI:000000000000000000000000000000000005");
    BulkOperationResults<String, TaskanaException> results = taskService.transferTasks("WBI:100000000000000000000000000000000006", taskIdList);
    assertFalse(results.containsErrors());
    Workbasket wb = taskanaEngine.getWorkbasketService().getWorkbasket("USER_1_1", "DOMAIN_A");
    Task transferredTask = taskService.getTask("TKI:000000000000000000000000000000000004");
    assertNotNull(transferredTask);
    assertTrue(transferredTask.isTransferred());
    assertFalse(transferredTask.isRead());
    assertEquals(TaskState.READY, transferredTask.getState());
    assertThat(transferredTask.getWorkbasketKey(), equalTo(wb.getKey()));
    assertThat(transferredTask.getDomain(), equalTo(wb.getDomain()));
    assertFalse(transferredTask.getModified().isBefore(before));
    assertThat(transferredTask.getOwner(), equalTo(null));
    transferredTask = taskService.getTask("TKI:000000000000000000000000000000000005");
    assertNotNull(transferredTask);
    assertTrue(transferredTask.isTransferred());
    assertFalse(transferredTask.isRead());
    assertEquals(TaskState.READY, transferredTask.getState());
    assertThat(transferredTask.getWorkbasketKey(), equalTo(wb.getKey()));
    assertThat(transferredTask.getDomain(), equalTo(wb.getDomain()));
    assertFalse(transferredTask.getModified().isBefore(before));
    assertThat(transferredTask.getOwner(), equalTo(null));
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) Instant(java.time.Instant) ArrayList(java.util.ArrayList) Workbasket(pro.taskana.Workbasket) TaskanaException(pro.taskana.exceptions.TaskanaException) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 50 with WithAccessId

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

the class TransferTaskAccTest method testTransferTaskToWorkbasketId.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testTransferTaskToWorkbasketId() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, InvalidStateException, InvalidOwnerException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task task = taskService.getTask("TKI:000000000000000000000000000000000003");
    taskService.claim(task.getId());
    taskService.setTaskRead(task.getId(), true);
    taskService.transfer(task.getId(), "WBI:100000000000000000000000000000000006");
    Task transferredTask = taskService.getTask("TKI:000000000000000000000000000000000003");
    assertNotNull(transferredTask);
    assertTrue(transferredTask.isTransferred());
    assertFalse(transferredTask.isRead());
    assertEquals(TaskState.READY, transferredTask.getState());
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) 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