Search in sources :

Example 11 with TimeInterval

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

the class QueryTasksByTimeIntervalsAccTest method testCreatedAfter.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "group_2" })
@Test
public void testCreatedAfter() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    TimeInterval interval1 = new TimeInterval(getInstant("2018-01-29T15:55:17"), null);
    List<TaskSummary> results = taskService.createTaskQuery().createdWithin(interval1).orderByCreated(asc).list();
    assertThat(results.size(), equalTo(36));
    TaskSummary previousSummary = null;
    for (TaskSummary taskSummary : results) {
        Instant cr = taskSummary.getCreated();
        Assert.assertTrue(interval1.contains(cr));
        if (previousSummary != null) {
            Assert.assertTrue(!previousSummary.getCreated().isAfter(taskSummary.getCreated()));
        }
        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 12 with TimeInterval

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

the class QueryTasksByTimeIntervalsAccTest method testDueWithin.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "group_2" })
@Test
public void testDueWithin() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    TimeInterval interval = new TimeInterval(getInstant("2018-01-29T15:55:00"), getInstant("2018-01-30T15:55:22"));
    List<TaskSummary> results = taskService.createTaskQuery().dueWithin(interval).orderByPlanned(asc).list();
    assertThat(results.size(), equalTo(70));
    TaskSummary previousSummary = null;
    for (TaskSummary taskSummary : results) {
        Instant cr = taskSummary.getDue();
        Assert.assertTrue(interval.contains(cr));
        if (previousSummary != null) {
            Assert.assertTrue(!previousSummary.getPlanned().isAfter(taskSummary.getPlanned()));
        }
        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)

Aggregations

Instant (java.time.Instant)12 TimeInterval (pro.taskana.TimeInterval)12 AbstractAccTest (acceptance.AbstractAccTest)8 Test (org.junit.Test)8 TaskService (pro.taskana.TaskService)8 TaskSummary (pro.taskana.TaskSummary)8 WithAccessId (pro.taskana.security.WithAccessId)8