Search in sources :

Example 46 with TaskService

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

the class WorkOnTaskAccTest method testClaimAlreadyClaimedByCallerTask.

@WithAccessId(userName = "user_1_2", groupNames = { "group_1" })
@Test
public void testClaimAlreadyClaimedByCallerTask() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, InvalidStateException, InvalidOwnerException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task task = taskService.getTask("TKI:000000000000000000000000000000000027");
    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 47 with TaskService

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

the class WorkOnTaskAccTest method testForceCancelClaimOfTaskFromAnotherUser.

@WithAccessId(userName = "user_1_2", groupNames = { "group_1" })
@Test
public void testForceCancelClaimOfTaskFromAnotherUser() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, InvalidStateException, InvalidOwnerException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000031");
    taskService.cancelClaim(claimedTask.getId(), true);
    Task unclaimedTask = taskService.getTask("TKI:000000000000000000000000000000000031");
    assertNotNull(unclaimedTask);
    assertEquals(TaskState.READY, unclaimedTask.getState());
    assertNull(unclaimedTask.getClaimed());
    assertTrue(unclaimedTask.isRead());
    assertNull(unclaimedTask.getOwner());
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 48 with TaskService

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

the class WorkOnTaskAccTest method testThrowsExceptionIfCompletingClaimedTaskOfAnotherUser.

@WithAccessId(userName = "user_1_2", groupNames = { "group_1" })
@Test(expected = InvalidOwnerException.class)
public void testThrowsExceptionIfCompletingClaimedTaskOfAnotherUser() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, InvalidStateException, InvalidOwnerException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000034");
    taskService.completeTask(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 49 with TaskService

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

the class WorkOnTaskAccTest method testCancelClaimTask.

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

Example 50 with TaskService

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

the class WorkOnTaskAccTest method testCompleteTask.

@WithAccessId(userName = "user_1_2", groupNames = { "group_1" })
@Test
public void testCompleteTask() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, InvalidStateException, InvalidOwnerException {
    Instant before = Instant.now().minus(Duration.ofSeconds(3L));
    TaskService taskService = taskanaEngine.getTaskService();
    Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000032");
    taskService.completeTask(claimedTask.getId());
    Task completedTask = taskService.getTask("TKI:000000000000000000000000000000000032");
    assertNotNull(completedTask);
    assertEquals(TaskState.COMPLETED, completedTask.getState());
    assertNotNull(completedTask.getCompleted());
    assertEquals(completedTask.getCompleted(), completedTask.getModified());
    assertTrue(completedTask.getCompleted().isAfter(before));
    assertTrue(completedTask.getModified().isAfter(before));
    assertTrue(completedTask.isRead());
    assertEquals("user_1_2", completedTask.getOwner());
}
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)

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