Search in sources :

Example 86 with TaskService

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

the class QueryTasksAccTest method testQueryForAttachmentInSummary.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testQueryForAttachmentInSummary() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, TaskNotFoundException, WorkbasketNotFoundException, ConcurrencyException, InvalidWorkbasketException, AttachmentPersistenceException {
    TaskService taskService = taskanaEngine.getTaskService();
    Attachment attachment = createAttachment(// prio 99, SL P2000D
    "DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3));
    Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
    task.addAttachment(attachment);
    taskService.updateTask(task);
    List<TaskSummary> results = taskService.createTaskQuery().idIn("TKI:000000000000000000000000000000000000").list();
    assertThat(results.size(), equalTo(1));
    assertThat(results.get(0).getAttachmentSummaries().size(), equalTo(3));
    AttachmentSummary att = results.get(0).getAttachmentSummaries().get(0);
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) TaskSummary(pro.taskana.TaskSummary) Attachment(pro.taskana.Attachment) AttachmentSummary(pro.taskana.AttachmentSummary) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 87 with TaskService

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

the class QueryTasksAccTest method testQueryForCustom5.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testQueryForCustom5() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    List<TaskSummary> results = taskService.createTaskQuery().customAttributeLike("5", "%a%", "%b%", "%c%", "%d%", "%e%", "%f%", "%g%", "%h%", "%i%", "%j%", "%k%", "%l%", "%m%", "%n%", "%o%", "%p%", "%q%", "%r%", "%s%", "%w%").list();
    assertThat(results.size(), equalTo(3));
    String[] ids = results.stream().map(t -> {
        try {
            return t.getCustomAttribute("5");
        } catch (InvalidArgumentException e) {
            e.printStackTrace();
            return "";
        }
    }).collect(Collectors.toList()).toArray(new String[0]);
    List<TaskSummary> result2 = taskService.createTaskQuery().customAttributeIn("5", ids).list();
    assertThat(result2.size(), equalTo(3));
}
Also used : InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) TaskService(pro.taskana.TaskService) TaskSummary(pro.taskana.TaskSummary) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 88 with TaskService

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

the class QueryTasksAccTest method testQueryForCustom2.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testQueryForCustom2() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    TaskService taskService = taskanaEngine.getTaskService();
    List<TaskSummary> results = taskService.createTaskQuery().customAttributeLike("2", "%a%", "%b%", "%c%", "%d%", "%e%", "%f%", "%g%", "%h%", "%i%", "%j%", "%k%", "%l%", "%m%", "%n%", "%o%", "%p%", "%q%", "%r%", "%s%", "%w%").list();
    assertThat(results.size(), equalTo(1));
    String[] ids = results.stream().map(t -> {
        try {
            return t.getCustomAttribute("2");
        } catch (InvalidArgumentException e) {
            e.printStackTrace();
            return "";
        }
    }).collect(Collectors.toList()).toArray(new String[0]);
    List<TaskSummary> result2 = taskService.createTaskQuery().customAttributeIn("2", ids).list();
    assertThat(result2.size(), equalTo(1));
}
Also used : InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) TaskService(pro.taskana.TaskService) TaskSummary(pro.taskana.TaskSummary) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 89 with TaskService

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

the class QueryTasksAccTest method testQueryAndCountMatch.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testQueryAndCountMatch() {
    TaskService taskService = taskanaEngine.getTaskService();
    TaskQuery taskQuery = taskService.createTaskQuery();
    List<TaskSummary> tasks = taskQuery.nameIn("Task99", "Task01", "Widerruf").list();
    long numberOfTasks = taskQuery.nameIn("Task99", "Task01", "Widerruf").count();
    Assert.assertEquals(numberOfTasks, tasks.size());
}
Also used : TaskService(pro.taskana.TaskService) TaskQuery(pro.taskana.TaskQuery) TaskSummary(pro.taskana.TaskSummary) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 90 with TaskService

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

the class QueryTasksAccTest method testQueryTaskByCustomAttributes.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testQueryTaskByCustomAttributes() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
    newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
    newTask.setClassificationKey("T2100");
    // about 1 Meg
    Map<String, String> customAttributesForCreate = createSimpleCustomProperties(20000);
    newTask.setCustomAttributes(customAttributesForCreate);
    Task createdTask = taskService.createTask(newTask);
    assertNotNull(createdTask);
    // query the task by custom attributes
    TaskanaEngineProxyForTest engineProxy = new TaskanaEngineProxyForTest((TaskanaEngineImpl) taskanaEngine);
    try {
        SqlSession session = engineProxy.getSqlSession();
        Configuration config = session.getConfiguration();
        if (!config.hasMapper(TaskTestMapper.class)) {
            config.addMapper(TaskTestMapper.class);
        }
        TaskTestMapper mapper = session.getMapper(TaskTestMapper.class);
        engineProxy.openConnection();
        List<TaskImpl> queryResult = mapper.selectTasksByCustomAttributeLike("%Property Value of Property_1339%");
        assertTrue(queryResult.size() == 1);
        Task retrievedTask = queryResult.get(0);
        assertTrue(createdTask.getId().equals(retrievedTask.getId()));
        // verify that the map is correctly retrieved from the database
        Map<String, String> customAttributesFromDb = retrievedTask.getCustomAttributes();
        assertNotNull(customAttributesFromDb);
        assertTrue(customAttributesForCreate.equals(customAttributesFromDb));
    } finally {
        engineProxy.returnConnection();
    }
}
Also used : Task(pro.taskana.Task) SqlSession(org.apache.ibatis.session.SqlSession) Configuration(org.apache.ibatis.session.Configuration) TaskService(pro.taskana.TaskService) TaskImpl(pro.taskana.impl.TaskImpl) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) TaskTestMapper(pro.taskana.mappings.TaskTestMapper) 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