Search in sources :

Example 21 with TaskSummary

use of pro.taskana.TaskSummary 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 22 with TaskSummary

use of pro.taskana.TaskSummary in project taskana by Taskana.

the class TaskQueryImplTest method should_ReturnOneItem_when_BuilderIsUsed.

@Test
public void should_ReturnOneItem_when_BuilderIsUsed() throws NotAuthorizedException, InvalidArgumentException {
    when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
    when(sqlSession.selectOne(any(), any())).thenReturn(new TaskSummaryImpl());
    List<TaskSummary> intermediate = new ArrayList<>();
    intermediate.add(new TaskSummaryImpl());
    doReturn(intermediate).when(taskServiceMock).augmentTaskSummariesByContainedSummaries(any());
    // when(taskServiceMock.augmentTaskSummariesByContainedSummaries(any())).thenReturn(intermediate);
    TaskSummary result = taskQueryImpl.nameIn("test", "asd", "blubber").priorityIn(1, 2).stateIn(TaskState.CLAIMED, TaskState.COMPLETED).single();
    Assert.assertNotNull(result);
}
Also used : TaskSummary(pro.taskana.TaskSummary) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 23 with TaskSummary

use of pro.taskana.TaskSummary 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 24 with TaskSummary

use of pro.taskana.TaskSummary 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)

Example 25 with TaskSummary

use of pro.taskana.TaskSummary in project taskana by Taskana.

the class QueryTasksWithSortingAccTest method testSortByPorCompanyAndClaimed.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "group_2" })
@Test
public void testSortByPorCompanyAndClaimed() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    List<TaskSummary> results = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain("USER_3_2", "DOMAIN_B")).orderByPrimaryObjectReferenceCompany(desc).orderByClaimed(asc).list();
    assertThat(results.size(), equalTo(25));
    TaskSummary previousSummary = null;
    for (TaskSummary taskSummary : results) {
        // + taskSummary.getClaimed());
        if (previousSummary != null) {
            Assert.assertTrue(taskSummary.getPrimaryObjRef().getCompany().compareToIgnoreCase(previousSummary.getPrimaryObjRef().getCompany()) <= 0);
        }
        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

TaskSummary (pro.taskana.TaskSummary)58 Test (org.junit.Test)48 TaskService (pro.taskana.TaskService)47 WithAccessId (pro.taskana.security.WithAccessId)45 AbstractAccTest (acceptance.AbstractAccTest)44 TaskanaEngineProxyForTest (pro.taskana.impl.TaskanaEngineProxyForTest)17 KeyDomain (pro.taskana.KeyDomain)14 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)14 Instant (java.time.Instant)9 ArrayList (java.util.ArrayList)8 TimeInterval (pro.taskana.TimeInterval)8 Classification (pro.taskana.Classification)5 Task (pro.taskana.Task)5 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)5 NotAuthorizedToQueryWorkbasketException (pro.taskana.exceptions.NotAuthorizedToQueryWorkbasketException)5 TaskQuery (pro.taskana.TaskQuery)4 Workbasket (pro.taskana.Workbasket)3 Arrays (java.util.Arrays)2 HashSet (java.util.HashSet)2 List (java.util.List)2