Search in sources :

Example 46 with ClassificationSummary

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

the class UpdateTaskAttachmentsAccTest method modifyExistingAttachment.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void modifyExistingAttachment() throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, AttachmentPersistenceException, SQLException {
    setUpMethod();
    // setup test
    assertThat(task.getAttachments().size(), equalTo(0));
    task.addAttachment(attachment);
    Attachment attachment2 = createAttachment(// prio 101, SL PT7H
    "L10303", createObjectReference("COMPANY_B", "SYSTEM_C", "INSTANCE_C", "ArchiveId", "ABC45678901234567890123456789012345678901234567890"), "ROHRPOST", "2018-01-15", createSimpleCustomProperties(4));
    task.addAttachment(attachment2);
    task = taskService.updateTask(task);
    task = taskService.getTask(task.getId());
    assertTrue(task.getPriority() == 101);
    assertTrue(task.getDue().equals(task.getPlanned()));
    assertThat(task.getAttachments().size(), equalTo(2));
    List<Attachment> attachments = task.getAttachments();
    boolean rohrpostFound = false;
    boolean emailFound = false;
    for (Attachment att : attachments) {
        String channel = att.getChannel();
        int custAttSize = att.getCustomAttributes().size();
        if ("ROHRPOST".equals(channel)) {
            rohrpostFound = true;
        } else if ("E-MAIL".equals(channel)) {
            emailFound = true;
        } else {
            fail("unexpected attachment detected " + att);
        }
        assertTrue(("ROHRPOST".equals(channel) && custAttSize == 4) || ("E-MAIL".equals(channel) && custAttSize == 3));
    }
    assertTrue(rohrpostFound && emailFound);
    ClassificationSummary newClassificationSummary = taskanaEngine.getClassificationService().getClassification(// Prio 5, SL P16D
    "CLI:100000000000000000000000000000000006").asSummary();
    // modify existing attachment
    for (Attachment att : task.getAttachments()) {
        att.setClassificationSummary(newClassificationSummary);
        if (att.getCustomAttributes().size() == 3) {
            att.setChannel("FAX");
        }
    }
    // modify existing attachment and task classification
    // Prio 99, SL P2000D
    task.setClassificationKey("DOCTYPE_DEFAULT");
    task = taskService.updateTask(task);
    task = taskService.getTask(task.getId());
    assertTrue(task.getPriority() == 99);
    DaysToWorkingDaysConverter converter = DaysToWorkingDaysConverter.initialize(Collections.singletonList(new TimeIntervalColumnHeader(0)), Instant.now());
    long calendarDays = converter.convertWorkingDaysToDays(task.getDue(), 16);
    assertTrue(task.getDue().equals(task.getPlanned().plus(Duration.ofDays(calendarDays))));
    rohrpostFound = false;
    boolean faxFound = false;
    for (Attachment att : task.getAttachments()) {
        String channel = att.getChannel();
        int custAttSize = att.getCustomAttributes().size();
        if ("FAX".equals(channel)) {
            faxFound = true;
        } else if ("ROHRPOST".equals(channel)) {
            rohrpostFound = true;
        } else {
            fail("unexpected attachment detected " + att);
        }
        assertTrue(("ROHRPOST".equals(channel) && custAttSize == 4) || ("FAX".equals(channel) && custAttSize == 3));
    }
    assertTrue(faxFound && rohrpostFound);
}
Also used : DaysToWorkingDaysConverter(pro.taskana.impl.DaysToWorkingDaysConverter) ClassificationSummary(pro.taskana.ClassificationSummary) Attachment(pro.taskana.Attachment) TimeIntervalColumnHeader(pro.taskana.impl.report.impl.TimeIntervalColumnHeader) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 47 with ClassificationSummary

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

the class ClassificationQueryAccTest method testFindClassificationsByDomainUnauthenticated.

@Test
public void testFindClassificationsByDomainUnauthenticated() throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
    ClassificationService classificationService = taskanaEngine.getClassificationService();
    List<ClassificationSummary> classificationSummaryList = classificationService.createClassificationQuery().domainIn("DOMAIN_A").list();
    assertNotNull(classificationSummaryList);
    assertEquals(17, classificationSummaryList.size());
}
Also used : ClassificationSummary(pro.taskana.ClassificationSummary) ClassificationService(pro.taskana.ClassificationService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test)

Example 48 with ClassificationSummary

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

the class ClassificationQueryAccTest method testFindClassificationsByDomainBusinessAdmin.

@WithAccessId(userName = "businessadmin")
@Test
public void testFindClassificationsByDomainBusinessAdmin() throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
    ClassificationService classificationService = taskanaEngine.getClassificationService();
    List<ClassificationSummary> classificationSummaryList = classificationService.createClassificationQuery().domainIn("DOMAIN_A").list();
    assertNotNull(classificationSummaryList);
    assertEquals(17, classificationSummaryList.size());
}
Also used : ClassificationSummary(pro.taskana.ClassificationSummary) ClassificationService(pro.taskana.ClassificationService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 49 with ClassificationSummary

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

the class QueryClassificationWithPaginationAccTest method testGetSecondPageOfClassificationQueryWithOffset.

@Test
public void testGetSecondPageOfClassificationQueryWithOffset() throws NotAuthorizedException {
    ClassificationService classificationService = taskanaEngine.getClassificationService();
    List<ClassificationSummary> results = classificationService.createClassificationQuery().domainIn("DOMAIN_A").list(5, 5);
    assertThat(results.size(), equalTo(5));
}
Also used : ClassificationSummary(pro.taskana.ClassificationSummary) ClassificationService(pro.taskana.ClassificationService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test)

Example 50 with ClassificationSummary

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

the class QueryClassificationWithPaginationAccTest method testPaginationWithPages.

@Test
public void testPaginationWithPages() throws NotAuthorizedException {
    ClassificationService classificationService = taskanaEngine.getClassificationService();
    // Getting full page
    int pageNumber = 1;
    int pageSize = 4;
    List<ClassificationSummary> results = classificationService.createClassificationQuery().domainIn("DOMAIN_A").listPage(pageNumber, pageSize);
    assertThat(results.size(), equalTo(4));
    // Getting full page
    pageNumber = 3;
    pageSize = 4;
    results = classificationService.createClassificationQuery().domainIn("DOMAIN_A").listPage(pageNumber, pageSize);
    assertThat(results.size(), equalTo(4));
    // Getting last results on 1 big page
    pageNumber = 1;
    pageSize = 100;
    results = classificationService.createClassificationQuery().domainIn("DOMAIN_A").listPage(pageNumber, pageSize);
    assertThat(results.size(), equalTo(17));
    // Getting last results on multiple pages
    pageNumber = 2;
    pageSize = 10;
    results = classificationService.createClassificationQuery().domainIn("DOMAIN_A").listPage(pageNumber, pageSize);
    assertThat(results.size(), equalTo(7));
}
Also used : ClassificationSummary(pro.taskana.ClassificationSummary) ClassificationService(pro.taskana.ClassificationService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test)

Aggregations

ClassificationSummary (pro.taskana.ClassificationSummary)51 Test (org.junit.Test)38 AbstractAccTest (acceptance.AbstractAccTest)21 Classification (pro.taskana.Classification)20 ClassificationService (pro.taskana.ClassificationService)20 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)14 Connection (java.sql.Connection)7 Attachment (pro.taskana.Attachment)7 Duration (java.time.Duration)5 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)5 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 Task (pro.taskana.Task)4 ClassificationNotFoundException (pro.taskana.exceptions.ClassificationNotFoundException)4 SystemException (pro.taskana.exceptions.SystemException)4 WithAccessId (pro.taskana.security.WithAccessId)4 PersistenceException (org.apache.ibatis.exceptions.PersistenceException)3 SQLException (java.sql.SQLException)2