Search in sources :

Example 66 with TaskService

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

the class WorkOnTaskAccTest method testClaimTask.

@WithAccessId(userName = "user_1_2", groupNames = { "group_1" })
@Test
public void testClaimTask() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, InvalidStateException, InvalidOwnerException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task task = taskService.getTask("TKI:000000000000000000000000000000000025");
    taskService.claim(task.getId());
    Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000025");
    assertNotNull(claimedTask);
    assertEquals(TaskState.CLAIMED, claimedTask.getState());
    assertNotNull(claimedTask.getClaimed());
    assertNotEquals(claimedTask.getCreated(), claimedTask.getModified());
    assertEquals(claimedTask.getClaimed(), claimedTask.getModified());
    assertTrue(claimedTask.isRead());
    assertEquals("user_1_2", claimedTask.getOwner());
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 67 with TaskService

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

the class WorkOnTaskAccTest method testBulkCompleteTasks.

@WithAccessId(userName = "user_1_2", groupNames = { "group_1" })
@Test
public void testBulkCompleteTasks() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, ConcurrencyException, AttachmentPersistenceException {
    TaskService taskService = taskanaEngine.getTaskService();
    List<String> taskIdList = new ArrayList<>();
    taskIdList.add("TKI:000000000000000000000000000000000100");
    taskIdList.add("TKI:000000000000000000000000000000000101");
    BulkOperationResults<String, TaskanaException> results = taskService.completeTasks(taskIdList);
    assertFalse(results.containsErrors());
    Task completedTask1 = taskService.getTask("TKI:000000000000000000000000000000000100");
    assertEquals(TaskState.COMPLETED, completedTask1.getState());
    assertNotNull(completedTask1.getCompleted());
    Task completedTask2 = taskService.getTask("TKI:000000000000000000000000000000000101");
    assertEquals(TaskState.COMPLETED, completedTask2.getState());
    assertNotNull(completedTask2.getCompleted());
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) ArrayList(java.util.ArrayList) TaskanaException(pro.taskana.exceptions.TaskanaException) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 68 with TaskService

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

the class WorkOnTaskAccTest method testForceClaimTaskWhichIsAlreadyClaimedByAnotherUser.

@WithAccessId(userName = "user_1_2", groupNames = { "group_1" })
@Test(expected = InvalidOwnerException.class)
public void testForceClaimTaskWhichIsAlreadyClaimedByAnotherUser() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, InvalidStateException, InvalidOwnerException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task task = taskService.getTask("TKI:000000000000000000000000000000000028");
    taskService.claim(task.getId());
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 69 with TaskService

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

the class WorkOnTaskAccTest method testThrowsExceptionIfCancelClaimOfTaskFromAnotherUser.

@WithAccessId(userName = "user_1_2", groupNames = { "group_1" })
@Test(expected = InvalidOwnerException.class)
public void testThrowsExceptionIfCancelClaimOfTaskFromAnotherUser() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, InvalidStateException, InvalidOwnerException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000030");
    taskService.cancelClaim(claimedTask.getId());
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 70 with TaskService

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

the class WorkOnTaskAccTest method testThrowsExceptionIfTaskIsAlreadyClaimed.

@WithAccessId(userName = "user_1_2", groupNames = { "group_1" })
@Test(expected = InvalidOwnerException.class)
public void testThrowsExceptionIfTaskIsAlreadyClaimed() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, InvalidStateException, InvalidOwnerException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task task = taskService.getTask("TKI:000000000000000000000000000000000026");
    taskService.claim(task.getId());
}
Also used : Task(pro.taskana.Task) 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