Search in sources :

Example 21 with TaskService

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

the class QueryTasksAccTest method testQueryForParentBusinessProcessId.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "group_2" })
@Test
public void testQueryForParentBusinessProcessId() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    List<TaskSummary> results = taskService.createTaskQuery().parentBusinessProcessIdLike("%PBPI%", "doc%3%").list();
    assertThat(results.size(), equalTo(24));
    String[] parentIds = results.stream().map(TaskSummary::getParentBusinessProcessId).collect(Collectors.toList()).toArray(new String[0]);
    List<TaskSummary> result2 = taskService.createTaskQuery().parentBusinessProcessIdIn(parentIds).list();
    assertThat(result2.size(), equalTo(24));
}
Also used : TaskService(pro.taskana.TaskService) TaskSummary(pro.taskana.TaskSummary) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 22 with TaskService

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

the class QueryTasksAccTest method testQueryForCustom4.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testQueryForCustom4() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    List<TaskSummary> results = taskService.createTaskQuery().customAttributeLike("4", "%a%", "%b%", "%c%", "%d%", "%e%", "%f%", "%g%", "%h%", "%i%", "%j%", "%k%", "%l%", "%m%", "%n%", "%o%", "%p%", "%q%", "%r%", "%s%", "%w%").list();
    assertThat(results.size(), equalTo(1));
    String[] ids = results.stream().map(t -> {
        try {
            return t.getCustomAttribute("4");
        } catch (InvalidArgumentException e) {
            e.printStackTrace();
            return "";
        }
    }).collect(Collectors.toList()).toArray(new String[0]);
    List<TaskSummary> result2 = taskService.createTaskQuery().customAttributeIn("4", ids).list();
    assertThat(result2.size(), equalTo(1));
}
Also used : InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) TaskService(pro.taskana.TaskService) TaskSummary(pro.taskana.TaskSummary) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 23 with TaskService

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

the class QueryTasksByTimeIntervalsAccTest method testPlannedWithin.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "group_2" })
@Test
public void testPlannedWithin() 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().plannedWithin(interval).orderByPlanned(asc).list();
    assertThat(results.size(), equalTo(70));
    TaskSummary previousSummary = null;
    for (TaskSummary taskSummary : results) {
        Instant cr = taskSummary.getPlanned();
        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)

Example 24 with TaskService

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

the class QueryTasksByTimeIntervalsAccTest method testCreatedWithin2Intervals.

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

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

the class QueryTasksByTimeIntervalsAccTest method testCreatedBefore.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "group_2" })
@Test
public void testCreatedBefore() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    TimeInterval interval1 = new TimeInterval(null, getInstant("2018-01-29T15:55:17"));
    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)

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