Search in sources :

Example 71 with TaskService

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

the class WorkOnTaskAccTest method testForceCompleteClaimedTaskOfAnotherUser.

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

Example 72 with TaskService

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

the class WorkOnTaskAccTest method testForceCompleteUnclaimedTask.

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

Example 73 with TaskService

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

the class WorkOnTaskAccTest method testBulkDeleteTasksWithException.

@WithAccessId(userName = "user_1_2", groupNames = { "group_1" })
@Test
public void testBulkDeleteTasksWithException() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, ConcurrencyException, AttachmentPersistenceException {
    TaskService taskService = taskanaEngine.getTaskService();
    List<String> taskIdList = new ArrayList<>();
    taskIdList.add("TKI:000000000000000000000000000000000102");
    taskIdList.add("TKI:000000000000000000000000000000003333");
    BulkOperationResults<String, TaskanaException> results = taskService.deleteTasks(taskIdList);
    assertTrue(results.containsErrors());
    assertThat(results.getErrorMap().size(), equalTo(2));
    assertTrue(results.getErrorForId("TKI:000000000000000000000000000000003333") instanceof TaskNotFoundException);
    assertTrue(results.getErrorForId("TKI:000000000000000000000000000000000102") instanceof InvalidStateException);
}
Also used : TaskNotFoundException(pro.taskana.exceptions.TaskNotFoundException) TaskService(pro.taskana.TaskService) ArrayList(java.util.ArrayList) InvalidStateException(pro.taskana.exceptions.InvalidStateException) TaskanaException(pro.taskana.exceptions.TaskanaException) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 74 with TaskService

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

the class TaskQueryAccTest method testTaskQueryUnauthenticated.

public void testTaskQueryUnauthenticated() {
    TaskService taskService = taskanaEngine.getTaskService();
    List<TaskSummary> results = taskService.createTaskQuery().ownerLike("%a%", "%u%").list();
    assertThat(results.size(), equalTo(0));
}
Also used : TaskService(pro.taskana.TaskService) TaskSummary(pro.taskana.TaskSummary)

Example 75 with TaskService

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

the class CreateTaskAccTest method testCreatedTaskObjectEqualsReadTaskObject.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testCreatedTaskObjectEqualsReadTaskObject() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
    newTask.setClassificationKey("T2100");
    newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
    for (int i = 1; i < 16; i++) {
        newTask.setCustomAttribute(Integer.toString(i), "VALUE " + i);
    }
    newTask.setCustomAttributes(createSimpleCustomProperties(5));
    newTask.setDescription("Description of test task");
    newTask.setNote("My note");
    newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
    Task createdTask = taskService.createTask(newTask);
    Task readTask = taskService.getTask(createdTask.getId());
    assertEquals(createdTask, readTask);
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) 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