Search in sources :

Example 6 with TaskService

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

the class TaskQueryAccTest method testTaskQueryUser_1_1Admin.

@WithAccessId(userName = "user_1_1", groupNames = { "admin" })
@Test
public void testTaskQueryUser_1_1Admin() {
    TaskService taskService = taskanaEngine.getTaskService();
    List<TaskSummary> results = taskService.createTaskQuery().ownerLike("%a%", "%u%").list();
    assertThat(results.size(), equalTo(25));
}
Also used : TaskService(pro.taskana.TaskService) TaskSummary(pro.taskana.TaskSummary) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 7 with TaskService

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

the class CreateTaskAccTest method testPrioDurationOfTaskFromAttachmentsAtCreate.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testPrioDurationOfTaskFromAttachmentsAtCreate() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
    // prio 8, SL P7D
    newTask.setClassificationKey("L12010");
    newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
    newTask.addAttachment(createAttachment(// prio 99, SL P2000D
    "DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
    newTask.addAttachment(createAttachment(// prio 1, SL P1D
    "L1060", createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
    Task createdTask = taskService.createTask(newTask);
    assertNotNull(createdTask.getId());
    assertThat(createdTask.getCreator(), equalTo(CurrentUserContext.getUserid()));
    Task readTask = taskService.getTask(createdTask.getId());
    assertNotNull(readTask);
    assertThat(readTask.getCreator(), equalTo(CurrentUserContext.getUserid()));
    assertNotNull(readTask.getAttachments());
    assertEquals(2, readTask.getAttachments().size());
    assertNotNull(readTask.getAttachments().get(1).getCreated());
    assertNotNull(readTask.getAttachments().get(1).getModified());
    assertEquals(readTask.getAttachments().get(0).getCreated(), readTask.getAttachments().get(1).getModified());
    // assertNotNull(readTask.getAttachments().get(0).getClassification());
    assertNotNull(readTask.getAttachments().get(0).getObjectReference());
    assertTrue(readTask.getPriority() == 99);
    DaysToWorkingDaysConverter converter = DaysToWorkingDaysConverter.initialize(Collections.singletonList(new TimeIntervalColumnHeader(0)), Instant.now());
    long calendarDays = converter.convertWorkingDaysToDays(readTask.getPlanned(), 1);
    assertTrue(readTask.getDue().equals(readTask.getPlanned().plus(Duration.ofDays(calendarDays))));
}
Also used : DaysToWorkingDaysConverter(pro.taskana.impl.DaysToWorkingDaysConverter) Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) TimeIntervalColumnHeader(pro.taskana.impl.report.impl.TimeIntervalColumnHeader) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 8 with TaskService

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

the class CreateTaskAccTest method testCreateExternalTaskWithAttachment.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testCreateExternalTaskWithAttachment() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, ConcurrencyException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
    newTask.setClassificationKey("L12010");
    Map<String, String> customAttributesForCreate = createSimpleCustomProperties(27);
    newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", customAttributesForCreate));
    newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
    Task createdTask = taskService.createTask(newTask);
    assertNotNull(createdTask.getId());
    assertThat(createdTask.getCreator(), equalTo(CurrentUserContext.getUserid()));
    // verify that the database content is as expected
    TaskanaEngineProxyForTest engineProxy = new TaskanaEngineProxyForTest((TaskanaEngineImpl) taskanaEngine);
    try {
        SqlSession session = engineProxy.getSqlSession();
        AttachmentMapper mapper = session.getMapper(AttachmentMapper.class);
        engineProxy.openConnection();
        String customProperties = mapper.getCustomAttributesAsString(createdTask.getAttachments().get(0).getId());
        assertTrue(customProperties.contains("\"Property_26\":\"Property Value of Property_26\""));
        assertTrue(customProperties.contains("\"Property_25\":\"Property Value of Property_25\""));
        assertTrue(customProperties.contains("\"Property_21\":\"Property Value of Property_21\""));
        assertTrue(customProperties.contains("\"Property_19\":\"Property Value of Property_19\""));
        assertTrue(customProperties.contains("\"Property_16\":\"Property Value of Property_16\""));
        assertTrue(customProperties.contains("\"Property_12\":\"Property Value of Property_12\""));
        assertTrue(customProperties.contains("\"Property_11\":\"Property Value of Property_11\""));
        assertTrue(customProperties.contains("\"Property_7\":\"Property Value of Property_7\""));
        assertTrue(customProperties.contains("\"Property_6\":\"Property Value of Property_6\""));
    } finally {
        engineProxy.returnConnection();
    }
    Task readTask = taskService.getTask(createdTask.getId());
    assertNotNull(readTask);
    assertThat(readTask.getCreator(), equalTo(CurrentUserContext.getUserid()));
    assertNotNull(readTask.getAttachments());
    assertEquals(1, readTask.getAttachments().size());
    assertNotNull(readTask.getAttachments().get(0).getCreated());
    assertNotNull(readTask.getAttachments().get(0).getModified());
    assertEquals(readTask.getAttachments().get(0).getCreated(), readTask.getAttachments().get(0).getModified());
    assertNotNull(readTask.getAttachments().get(0).getClassificationSummary());
    assertNotNull(readTask.getAttachments().get(0).getObjectReference());
    // verify that the map is correctly retrieved from the database
    Map<String, String> customAttributesFromDb = readTask.getAttachments().get(0).getCustomAttributes();
    assertNotNull(customAttributesFromDb);
    assertTrue(customAttributesFromDb.equals(customAttributesForCreate));
}
Also used : Task(pro.taskana.Task) SqlSession(org.apache.ibatis.session.SqlSession) TaskService(pro.taskana.TaskService) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) AttachmentMapper(pro.taskana.mappings.AttachmentMapper) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 9 with TaskService

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

the class CreateTaskAccTest method testCreateExternalTaskWithMultipleAttachments.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testCreateExternalTaskWithMultipleAttachments() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
    newTask.setClassificationKey("L12010");
    newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
    newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
    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);
    assertNotNull(createdTask.getId());
    assertThat(createdTask.getCreator(), equalTo(CurrentUserContext.getUserid()));
    Task readTask = taskService.getTask(createdTask.getId());
    assertNotNull(readTask);
    assertThat(readTask.getCreator(), equalTo(CurrentUserContext.getUserid()));
    assertNotNull(readTask.getAttachments());
    assertEquals(2, readTask.getAttachments().size());
    assertNotNull(readTask.getAttachments().get(1).getCreated());
    assertNotNull(readTask.getAttachments().get(1).getModified());
    assertEquals(readTask.getAttachments().get(0).getCreated(), readTask.getAttachments().get(1).getModified());
    // assertNotNull(readTask.getAttachments().get(0).getClassification());
    assertNotNull(readTask.getAttachments().get(0).getObjectReference());
}
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)

Example 10 with TaskService

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

the class CreateTaskAccTest method testSetDomainFromWorkbasket.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testSetDomainFromWorkbasket() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
    TaskService taskService = taskanaEngine.getTaskService();
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    Workbasket workbasket = workbasketService.getWorkbasket("USER_1_1", "DOMAIN_A");
    Task newTask = taskService.newTask("WBI:100000000000000000000000000000000006");
    newTask.setClassificationKey("T2100");
    newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
    Task createdTask = taskService.createTask(newTask);
    assertNotNull(createdTask);
    assertThat(createdTask.getCreator(), equalTo(CurrentUserContext.getUserid()));
    assertNotNull(createdTask.getDomain());
    assertEquals(workbasket.getDomain(), createdTask.getDomain());
}
Also used : Task(pro.taskana.Task) WorkbasketService(pro.taskana.WorkbasketService) TaskService(pro.taskana.TaskService) Workbasket(pro.taskana.Workbasket) 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