Search in sources :

Example 26 with TaskService

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

the class QueryTasksByTimeIntervalsAccTest method testModifiedWithin.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "group_2" })
@Test
public void testModifiedWithin() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    TimeInterval interval = new TimeInterval(getInstant("2018-01-30T15:55:00"), getInstant("2018-01-30T15:55:22"));
    List<TaskSummary> results = taskService.createTaskQuery().modifiedWithin(interval).orderByModified(asc).list();
    assertThat(results.size(), equalTo(6));
    TaskSummary previousSummary = null;
    for (TaskSummary taskSummary : results) {
        Instant cr = taskSummary.getModified();
        Assert.assertTrue(interval.contains(cr));
        if (previousSummary != null) {
            Assert.assertTrue(!previousSummary.getModified().isAfter(taskSummary.getModified()));
        }
        previousSummary = taskSummary;
    }
}
Also used : TimeInterval(pro.taskana.TimeInterval) TaskService(pro.taskana.TaskService) Instant(java.time.Instant) TaskSummary(pro.taskana.TaskSummary) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 27 with TaskService

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

the class QueryTasksByTimeIntervalsAccTest method testClaimedWithin2Intervals.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "group_2" })
@Test
public void testClaimedWithin2Intervals() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    TimeInterval interval1 = new TimeInterval(getInstant("2018-01-30T15:55:00"), getInstant("2018-01-30T15:55:10"));
    TimeInterval interval2 = new TimeInterval(getInstant("2018-01-30T15:55:23"), getInstant("2018-01-30T15:55:25"));
    List<TaskSummary> results = taskService.createTaskQuery().claimedWithin(interval1, interval2).orderByCreated(asc).list();
    assertThat(results.size(), equalTo(24));
    TaskSummary previousSummary = null;
    for (TaskSummary taskSummary : results) {
        Instant cr = taskSummary.getClaimed();
        Assert.assertTrue(interval1.contains(cr) || interval2.contains(cr));
        if (previousSummary != null) {
            Assert.assertTrue(!previousSummary.getClaimed().isAfter(taskSummary.getClaimed()));
        }
        previousSummary = taskSummary;
    }
}
Also used : TimeInterval(pro.taskana.TimeInterval) TaskService(pro.taskana.TaskService) Instant(java.time.Instant) TaskSummary(pro.taskana.TaskSummary) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 28 with TaskService

use of pro.taskana.TaskService 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 29 with TaskService

use of pro.taskana.TaskService 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 30 with TaskService

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

Aggregations

TaskService (pro.taskana.TaskService)102 Test (org.junit.Test)101 AbstractAccTest (acceptance.AbstractAccTest)99 WithAccessId (pro.taskana.security.WithAccessId)98 Task (pro.taskana.Task)48 TaskSummary (pro.taskana.TaskSummary)45 TaskanaEngineProxyForTest (pro.taskana.impl.TaskanaEngineProxyForTest)32 KeyDomain (pro.taskana.KeyDomain)16 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)16 Instant (java.time.Instant)13 TimeInterval (pro.taskana.TimeInterval)8 ArrayList (java.util.ArrayList)7 TaskanaException (pro.taskana.exceptions.TaskanaException)6 InvalidStateException (pro.taskana.exceptions.InvalidStateException)5 TaskNotFoundException (pro.taskana.exceptions.TaskNotFoundException)4 SqlSession (org.apache.ibatis.session.SqlSession)3 Ignore (org.junit.Ignore)3 Workbasket (pro.taskana.Workbasket)3 ConcurrencyException (pro.taskana.exceptions.ConcurrencyException)3 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)3