Search in sources :

Example 71 with WithAccessId

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

the class DeleteTaskAccTest method testForceDeleteTaskIfNotCompleted.

@WithAccessId(userName = "user_1_2", groupNames = { "group_1", "admin" })
@Test(expected = TaskNotFoundException.class)
public void testForceDeleteTaskIfNotCompleted() throws SQLException, TaskNotFoundException, InvalidStateException, NotAuthorizedException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task task = taskService.getTask("TKI:000000000000000000000000000000000027");
    try {
        taskService.deleteTask(task.getId());
        fail("Should not be possible to delete claimed task without force flag");
    } catch (InvalidStateException ex) {
        taskService.deleteTask(task.getId(), true);
    }
    taskService.getTask("TKI:000000000000000000000000000000000027");
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) InvalidStateException(pro.taskana.exceptions.InvalidStateException) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 72 with WithAccessId

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

the class QueryTasksByWorkbasketAccTest method testThrowsExceptionIfNoOpenerPermissionOnAtLeastOneQueriedWorkbasket.

// BB
@Ignore
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test(expected = NotAuthorizedToQueryWorkbasketException.class)
public void testThrowsExceptionIfNoOpenerPermissionOnAtLeastOneQueriedWorkbasket() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("USER_1_1", "DOMAIN_A"), new KeyDomain("USER_2_1", "DOMAIN_A")).list();
}
Also used : TaskService(pro.taskana.TaskService) KeyDomain(pro.taskana.KeyDomain) Ignore(org.junit.Ignore) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 73 with WithAccessId

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

the class QueryTasksByWorkbasketAccTest method testThrowsExceptionIfNoOpenerPermissionOnQueriedWorkbasket.

// BB
@Ignore
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test(expected = NotAuthorizedToQueryWorkbasketException.class)
public void testThrowsExceptionIfNoOpenerPermissionOnQueriedWorkbasket() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("USER_2_1", "DOMAIN_A")).list();
}
Also used : TaskService(pro.taskana.TaskService) KeyDomain(pro.taskana.KeyDomain) Ignore(org.junit.Ignore) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 74 with WithAccessId

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

the class QueryTasksWithSortingAccTest method testSortByDomainNameAndCreated.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "group_2" })
@Test
public void testSortByDomainNameAndCreated() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    List<TaskSummary> results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("USER_3_2", "DOMAIN_B")).orderByDomain(asc).orderByName(asc).orderByCreated(null).list();
    assertThat(results.size(), equalTo(25));
    TaskSummary previousSummary = null;
    for (TaskSummary taskSummary : results) {
        // created: " + taskSummary.getCreated());
        if (previousSummary != null) {
            Assert.assertTrue(taskSummary.getDomain().compareToIgnoreCase(previousSummary.getDomain()) >= 0);
            if (taskSummary.getDomain().equals(previousSummary.getDomain())) {
                Assert.assertTrue(taskSummary.getName().compareToIgnoreCase(previousSummary.getName()) >= 0);
                if (taskSummary.getName().equals(previousSummary.getName())) {
                    Assert.assertTrue(!taskSummary.getCreated().isBefore(previousSummary.getCreated()));
                }
            }
        }
        previousSummary = taskSummary;
    }
}
Also used : TaskService(pro.taskana.TaskService) TaskSummary(pro.taskana.TaskSummary) KeyDomain(pro.taskana.KeyDomain) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 75 with WithAccessId

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

the class QueryTasksWithSortingAccTest method testSortByModifiedAndDomain.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "group_2" })
@Test
public void testSortByModifiedAndDomain() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    List<TaskSummary> results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("USER_3_2", "DOMAIN_B")).orderByModified(desc).orderByDomain(null).list();
    assertThat(results.size(), equalTo(25));
    TaskSummary previousSummary = null;
    for (TaskSummary taskSummary : results) {
        if (previousSummary != null) {
            Assert.assertTrue(!previousSummary.getModified().isBefore(taskSummary.getModified()));
        }
        previousSummary = taskSummary;
    }
}
Also used : TaskService(pro.taskana.TaskService) TaskSummary(pro.taskana.TaskSummary) KeyDomain(pro.taskana.KeyDomain) 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