Search in sources :

Example 61 with TaskService

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

the class UpdateTaskAccTest method testUpdateTasksByPorForUser1.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testUpdateTasksByPorForUser1() throws InvalidArgumentException {
    ObjectReference por = new ObjectReference();
    por.setCompany("00");
    por.setSystem("PASystem");
    por.setSystemInstance("00");
    por.setType("VNR");
    por.setValue("22334455");
    Map<String, String> customProperties = new HashMap<>();
    customProperties.put("7", "This is modifiedValue 7");
    customProperties.put("14", null);
    customProperties.put("3", "This is modifiedValue 3");
    customProperties.put("16", "This is modifiedValue 16");
    TaskService taskService = taskanaEngine.getTaskService();
    List<String> taskIds = taskService.updateTasks(por, customProperties);
    assertEquals(0, taskIds.size());
}
Also used : ObjectReference(pro.taskana.impl.ObjectReference) HashMap(java.util.HashMap) TaskService(pro.taskana.TaskService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 62 with TaskService

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

the class UpdateTaskAccTest method testUpdateTasksByPor.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testUpdateTasksByPor() throws InvalidArgumentException, TaskNotFoundException, NotAuthorizedException {
    ObjectReference por = new ObjectReference();
    por.setCompany("00");
    por.setSystem("PASystem");
    por.setSystemInstance("00");
    por.setType("VNR");
    por.setValue("22334455");
    Map<String, String> customProperties = new HashMap<>();
    customProperties.put("7", "This is modifiedValue 7");
    customProperties.put("14", null);
    customProperties.put("3", "This is modifiedValue 3");
    customProperties.put("16", "This is modifiedValue 16");
    TaskService taskService = taskanaEngine.getTaskService();
    List<String> taskIds = taskService.updateTasks(por, customProperties);
    assertEquals(6, taskIds.size());
    for (String taskId : taskIds) {
        Task task = taskService.getTask(taskId);
        assertEquals("This is modifiedValue 3", task.getCustomAttribute("3"));
        assertEquals("This is modifiedValue 7", task.getCustomAttribute("7"));
        assertEquals("This is modifiedValue 16", task.getCustomAttribute("16"));
        assertNull(task.getCustomAttribute("14"));
    }
}
Also used : Task(pro.taskana.Task) ObjectReference(pro.taskana.impl.ObjectReference) HashMap(java.util.HashMap) TaskService(pro.taskana.TaskService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 63 with TaskService

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

the class UpdateTaskAccTest method testThrowsExceptionIfMandatoryPrimaryObjectReferenceIsNotSetOrIncomplete.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testThrowsExceptionIfMandatoryPrimaryObjectReferenceIsNotSetOrIncomplete() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, ConcurrencyException, AttachmentPersistenceException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
    task.setPrimaryObjRef(null);
    try {
        taskService.updateTask(task);
        fail("update() should have thrown InvalidArgumentException.");
    } catch (InvalidArgumentException ex) {
    // nothing to do
    }
    task.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", null));
    try {
        taskService.updateTask(task);
        fail("update() should have thrown InvalidArgumentException.");
    } catch (InvalidArgumentException ex) {
    // nothing to do
    }
    task.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", null, "1234567"));
    try {
        taskService.updateTask(task);
        fail("update() should have thrown InvalidArgumentException.");
    } catch (InvalidArgumentException ex) {
    // nothing to do
    }
    task.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", null, "VNR", "1234567"));
    try {
        taskService.updateTask(task);
        fail("update() should have thrown InvalidArgumentException.");
    } catch (InvalidArgumentException ex) {
    // nothing to do
    }
    task.setPrimaryObjRef(createObjectReference("COMPANY_A", null, "INSTANCE_A", "VNR", "1234567"));
    try {
        taskService.updateTask(task);
        fail("update() should have thrown InvalidArgumentException.");
    } catch (InvalidArgumentException ex) {
    // nothing to do
    }
    task.setPrimaryObjRef(createObjectReference(null, "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
    try {
        taskService.updateTask(task);
        fail("update() should have thrown InvalidArgumentException.");
    } catch (InvalidArgumentException ex) {
    // nothing to do
    }
}
Also used : Task(pro.taskana.Task) InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) TaskService(pro.taskana.TaskService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 64 with TaskService

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

the class UpdateTaskAccTest method testThrowsExceptionIfTaskHasAlreadyBeenUpdated.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testThrowsExceptionIfTaskHasAlreadyBeenUpdated() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, ConcurrencyException, AttachmentPersistenceException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
    Task task2 = taskService.getTask("TKI:000000000000000000000000000000000000");
    task.setCustomAttribute("1", "willi");
    Task updatedTask = null;
    updatedTask = taskService.updateTask(task);
    updatedTask = taskService.getTask(updatedTask.getId());
    task2.setCustomAttribute("2", "Walter");
    try {
        updatedTask = taskService.updateTask(task2);
    } catch (ConcurrencyException ex) {
        assertEquals("The task has already been updated by another user", ex.getMessage());
    }
}
Also used : Task(pro.taskana.Task) ConcurrencyException(pro.taskana.exceptions.ConcurrencyException) TaskService(pro.taskana.TaskService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 65 with TaskService

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

the class UpdateTaskAccTest method testCustomPropertiesOfTask.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testCustomPropertiesOfTask() throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException, AttachmentPersistenceException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
    task.setCustomAttribute("1", "T2100");
    Task updatedTask = taskService.updateTask(task);
    updatedTask = taskService.getTask(updatedTask.getId());
    assertNotNull(updatedTask);
}
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