Search in sources :

Example 51 with TaskSummary

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

the class QueryTasksAccTest method testQueryForCustom5.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testQueryForCustom5() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    List<TaskSummary> results = taskService.createTaskQuery().customAttributeLike("5", "%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(3));
    String[] ids = results.stream().map(t -> {
        try {
            return t.getCustomAttribute("5");
        } catch (InvalidArgumentException e) {
            e.printStackTrace();
            return "";
        }
    }).collect(Collectors.toList()).toArray(new String[0]);
    List<TaskSummary> result2 = taskService.createTaskQuery().customAttributeIn("5", ids).list();
    assertThat(result2.size(), equalTo(3));
}
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 52 with TaskSummary

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

the class QueryTasksAccTest method testQueryForCustom2.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testQueryForCustom2() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    List<TaskSummary> results = taskService.createTaskQuery().customAttributeLike("2", "%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("2");
        } catch (InvalidArgumentException e) {
            e.printStackTrace();
            return "";
        }
    }).collect(Collectors.toList()).toArray(new String[0]);
    List<TaskSummary> result2 = taskService.createTaskQuery().customAttributeIn("2", 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 53 with TaskSummary

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

the class QueryTasksAccTest method testQueryAndCountMatch.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testQueryAndCountMatch() {
    TaskService taskService = taskanaEngine.getTaskService();
    TaskQuery taskQuery = taskService.createTaskQuery();
    List<TaskSummary> tasks = taskQuery.nameIn("Task99", "Task01", "Widerruf").list();
    long numberOfTasks = taskQuery.nameIn("Task99", "Task01", "Widerruf").count();
    Assert.assertEquals(numberOfTasks, tasks.size());
}
Also used : TaskService(pro.taskana.TaskService) TaskQuery(pro.taskana.TaskQuery) TaskSummary(pro.taskana.TaskSummary) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 54 with TaskSummary

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

the class QueryTasksByTimeIntervalsAccTest method testCompletedWithin.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "group_2" })
@Test
public void testCompletedWithin() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    TimeInterval interval = new TimeInterval(getInstant("2018-01-30T16:55:23"), getInstant("2018-01-30T16:55:25"));
    List<TaskSummary> results = taskService.createTaskQuery().completedWithin(interval).orderByCompleted(asc).list();
    assertThat(results.size(), equalTo(5));
    TaskSummary previousSummary = null;
    for (TaskSummary taskSummary : results) {
        Instant cr = taskSummary.getCompleted();
        Assert.assertTrue(interval.contains(cr));
        if (previousSummary != null) {
            Assert.assertTrue(!previousSummary.getCompleted().isAfter(taskSummary.getCompleted()));
        }
        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 55 with TaskSummary

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

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