Search in sources :

Example 41 with TaskService

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

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

Example 43 with TaskService

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

the class UpdateTaskAccTest method testUpdatePrimaryObjectReferenceOfTask.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testUpdatePrimaryObjectReferenceOfTask() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, ConcurrencyException, AttachmentPersistenceException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
    Instant modifiedOriginal = task.getModified();
    task.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "7654321"));
    Task updatedTask = taskService.updateTask(task);
    updatedTask = taskService.getTask(updatedTask.getId());
    Assert.assertNotNull(updatedTask);
    Assert.assertEquals("7654321", updatedTask.getPrimaryObjRef().getValue());
    Assert.assertNotNull(updatedTask.getCreated());
    Assert.assertNotNull(updatedTask.getModified());
    Assert.assertFalse(modifiedOriginal.isAfter(updatedTask.getModified()));
    Assert.assertNotEquals(updatedTask.getCreated(), updatedTask.getModified());
    Assert.assertEquals(task.getCreated(), updatedTask.getCreated());
    Assert.assertEquals(task.isRead(), updatedTask.isRead());
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) Instant(java.time.Instant) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 44 with TaskService

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

the class UpdateTaskAccTest method testUpdateOfWorkbasketKeyWhatIsNotAllowed.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test(expected = InvalidArgumentException.class)
public void testUpdateOfWorkbasketKeyWhatIsNotAllowed() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, ConcurrencyException, AttachmentPersistenceException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
    ((TaskImpl) task).setWorkbasketKey("USER_2_2");
    taskService.updateTask(task);
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) TaskImpl(pro.taskana.impl.TaskImpl) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 45 with TaskService

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

the class UpdateTaskAccTest method testUpdateClassificationOfTask.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testUpdateClassificationOfTask() throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException, AttachmentPersistenceException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
    ClassificationSummary classificationSummary = task.getClassificationSummary();
    task.setClassificationKey("T2100");
    Task updatedTask = taskService.updateTask(task);
    updatedTask = taskService.getTask(updatedTask.getId());
    assertNotNull(updatedTask);
    assertEquals("T2100", updatedTask.getClassificationSummary().getKey());
    assertThat(updatedTask.getClassificationSummary(), not(equalTo(classificationSummary)));
    assertNotEquals(updatedTask.getCreated(), updatedTask.getModified());
    assertEquals(task.getPlanned(), updatedTask.getPlanned());
    assertEquals(task.getName(), updatedTask.getName());
    assertEquals(task.getDescription(), updatedTask.getDescription());
}
Also used : Task(pro.taskana.Task) ClassificationSummary(pro.taskana.ClassificationSummary) TaskService(pro.taskana.TaskService) 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