Search in sources :

Example 41 with WithAccessId

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

the class QueryTasksWithPaginationAccTest method testListOffsetAndLimitOutOfBounds.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testListOffsetAndLimitOutOfBounds() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    // both will be 0, working
    List<TaskSummary> results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A")).list(-1, -3);
    assertThat(results.size(), equalTo(0));
    // limit will be 0
    results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A")).list(1, -3);
    assertThat(results.size(), equalTo(0));
    // offset will be 0
    results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A")).list(-1, 3);
    assertThat(results.size(), equalTo(3));
}
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 42 with WithAccessId

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

the class QueryTasksWithPaginationAccTest method testCountOfTaskQuery.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testCountOfTaskQuery() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    long count = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A")).count();
    assertThat(count, equalTo(22L));
}
Also used : TaskService(pro.taskana.TaskService) KeyDomain(pro.taskana.KeyDomain) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 43 with WithAccessId

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

the class QueryTasksWithPaginationAccTest method testSecondPageOfTaskQueryWithOffset.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testSecondPageOfTaskQueryWithOffset() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    List<TaskSummary> results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A")).list(10, 10);
    assertThat(results.size(), equalTo(10));
}
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 44 with WithAccessId

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

the class QueryTasksWithPaginationAccTest method testPaginationWithPages.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testPaginationWithPages() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    // Getting full page
    int pageNumber = 2;
    int pageSize = 4;
    List<TaskSummary> results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A")).listPage(pageNumber, pageSize);
    assertThat(results.size(), equalTo(4));
    // Getting full page
    pageNumber = 4;
    pageSize = 1;
    results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A")).listPage(pageNumber, pageSize);
    assertThat(results.size(), equalTo(1));
    // Getting last results on 1 big page
    pageNumber = 1;
    pageSize = 100;
    results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A")).listPage(pageNumber, pageSize);
    assertThat(results.size(), equalTo(22));
    // Getting last results on multiple pages
    pageNumber = 3;
    pageSize = 10;
    results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A")).listPage(pageNumber, pageSize);
    assertThat(results.size(), equalTo(2));
}
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 45 with WithAccessId

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

the class DeleteClassificationAccTest method testThrowExceptionWhenChildClassificationIsInUseAndRollback.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "businessadmin" })
@Test
public void testThrowExceptionWhenChildClassificationIsInUseAndRollback() throws ClassificationInUseException, NotAuthorizedException, ClassificationNotFoundException {
    boolean classificationInUse = false;
    try {
        classificationService.deleteClassification("L11010", "DOMAIN_A");
    } catch (ClassificationInUseException e) {
        classificationInUse = true;
    }
    Classification rollback = classificationService.getClassification("L11010", "DOMAIN_A");
    assertTrue(classificationInUse);
    assertEquals("DOMAIN_A", rollback.getDomain());
    classificationInUse = false;
    try {
        classificationService.deleteClassification("L11010", "");
    } catch (ClassificationInUseException e) {
        classificationInUse = true;
    }
    Classification rollbackMaster = classificationService.getClassification("L11010", "");
    Classification rollbackA = classificationService.getClassification("L11010", "DOMAIN_A");
    assertTrue(classificationInUse);
    assertEquals(rollbackMaster.getKey(), rollbackA.getKey());
    assertNotEquals(rollbackMaster.getDomain(), rollbackA.getDomain());
}
Also used : ClassificationInUseException(pro.taskana.exceptions.ClassificationInUseException) Classification(pro.taskana.Classification) 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