Search in sources :

Example 1 with Classification

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

the class UpdateTaskAttachmentsAccTest method testUpdateAttachment.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testUpdateAttachment() throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException, AttachmentPersistenceException, SQLException {
    setUpMethod();
    ((TaskImpl) task).setAttachments(new ArrayList<>());
    task = taskService.updateTask(task);
    assertTrue(task.getPriority() == 1);
    assertTrue(task.getDue().equals(task.getPlanned().plus(Duration.ofDays(1))));
    Attachment attachment = this.attachment;
    task.addAttachment(attachment);
    task = taskService.updateTask(task);
    assertTrue(task.getPriority() == 99);
    assertTrue(task.getDue().equals(task.getPlanned().plus(Duration.ofDays(1))));
    int attachmentCount = task.getAttachments().size();
    String newChannel = attachment.getChannel() + "-X";
    task.getAttachments().get(0).setChannel(newChannel);
    Classification newClassification = taskanaEngine.getClassificationService().getClassification(// Prio 999, SL PT5H
    "CLI:000000000000000000000000000000000001");
    task.getAttachments().get(0).setClassificationSummary(newClassification.asSummary());
    task = taskService.updateTask(task);
    task = taskService.getTask(task.getId());
    assertThat(task.getAttachments().size(), equalTo(attachmentCount));
    assertThat(task.getAttachments().get(0).getChannel(), equalTo(newChannel));
    assertTrue(task.getPriority() == 999);
    assertTrue(task.getDue().equals(task.getPlanned()));
}
Also used : TaskImpl(pro.taskana.impl.TaskImpl) Classification(pro.taskana.Classification) Attachment(pro.taskana.Attachment) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 2 with Classification

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

the class UpdateTaskAttachmentsAccTest method testAddExistingAttachmentAgainWillUpdateWhenNotEqual.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testAddExistingAttachmentAgainWillUpdateWhenNotEqual() throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, AttachmentPersistenceException, SQLException {
    setUpMethod();
    // Add attachment before
    task = taskService.getTask(task.getId());
    int attachmentCount = task.getAttachments().size();
    task.addAttachment(attachment);
    task = taskService.updateTask(task);
    task = taskService.getTask(task.getId());
    assertThat(task.getAttachments().size(), equalTo(attachmentCount + 1));
    // Change sth. and add same (id) again - override/update
    String newChannel = "UPDATED EXTERNAL SINCE LAST ADD";
    attachmentCount = task.getAttachments().size();
    Attachment updatedAttachment = task.getAttachments().get(0);
    updatedAttachment.setChannel(newChannel);
    Classification newClassification = taskanaEngine.getClassificationService().getClassification(// Prio 999, SL PT5H
    "CLI:000000000000000000000000000000000001");
    updatedAttachment.setClassificationSummary(newClassification.asSummary());
    task.addAttachment(updatedAttachment);
    task = taskService.updateTask(task);
    task = taskService.getTask(task.getId());
    assertThat(task.getAttachments().size(), equalTo(attachmentCount));
    assertThat(task.getAttachments().get(0).getChannel(), equalTo(newChannel));
    assertTrue(task.getPriority() == 999);
    assertTrue(task.getDue().equals(task.getPlanned()));
}
Also used : Classification(pro.taskana.Classification) Attachment(pro.taskana.Attachment) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 3 with Classification

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

the class UpdateClassificationAccTest method testUpdateTaskOnClassificationKeyCategoryChange.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "businessadmin" })
@Test
public void testUpdateTaskOnClassificationKeyCategoryChange() throws Exception {
    setupTest();
    TaskImpl beforeTask = (TaskImpl) taskanaEngine.getTaskService().getTask("TKI:000000000000000000000000000000000000");
    Classification classification = taskanaEngine.getClassificationService().getClassification(beforeTask.getClassificationSummary().getKey(), beforeTask.getDomain());
    classification.setCategory("PROCESS");
    Instant createdBefore = classification.getCreated();
    Instant modifiedBefore = classification.getModified();
    classification = taskanaEngine.getClassificationService().updateClassification(classification);
    TaskImpl updatedTask = (TaskImpl) taskanaEngine.getTaskService().getTask("TKI:000000000000000000000000000000000000");
    assertThat(updatedTask.getClassificationCategory(), not(equalTo(beforeTask.getClassificationCategory())));
    assertThat(updatedTask.getClassificationSummary().getCategory(), not(equalTo(beforeTask.getClassificationSummary().getCategory())));
    assertThat(updatedTask.getClassificationCategory(), equalTo("PROCESS"));
    assertThat(updatedTask.getClassificationSummary().getCategory(), equalTo("PROCESS"));
    assertThat(classification.getCreated(), equalTo(createdBefore));
    assertTrue(modifiedBefore.isBefore(classification.getModified()));
}
Also used : TaskImpl(pro.taskana.impl.TaskImpl) Classification(pro.taskana.Classification) Instant(java.time.Instant) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 4 with Classification

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

the class UpdateClassificationAccTest method testUpdateClassificationPrioServiceLevel.

@WithAccessId(userName = "dummy", groupNames = { "admin" })
@Test
public void testUpdateClassificationPrioServiceLevel() throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException, InterruptedException, TaskNotFoundException, InvalidArgumentException {
    String newEntryPoint = "updated EntryPoint";
    Instant before = Instant.now();
    ClassificationService classificationService = taskanaEngine.getClassificationService();
    Classification classification = classificationService.getClassification("CLI:100000000000000000000000000000000003");
    Instant createdBefore = classification.getCreated();
    Instant modifiedBefore = classification.getModified();
    classification.setPriority(1000);
    classification.setServiceLevel("P15D");
    classificationService.updateClassification(classification);
    Thread.sleep(100);
    JobRunner runner = new JobRunner(taskanaEngine);
    runner.runJobs();
    // Get and check the new value
    Classification updatedClassification = classificationService.getClassification("CLI:100000000000000000000000000000000003");
    assertNotNull(updatedClassification);
    assertTrue(!modifiedBefore.isAfter(updatedClassification.getModified()));
    List<String> affectedTasks = new ArrayList<>(Arrays.asList("TKI:000000000000000000000000000000000000", "TKI:000000000000000000000000000000000003", "TKI:000000000000000000000000000000000004", "TKI:000000000000000000000000000000000005", "TKI:000000000000000000000000000000000006", "TKI:000000000000000000000000000000000007", "TKI:000000000000000000000000000000000008", "TKI:000000000000000000000000000000000009", "TKI:000000000000000000000000000000000010", "TKI:000000000000000000000000000000000011", "TKI:000000000000000000000000000000000012", "TKI:000000000000000000000000000000000013", "TKI:000000000000000000000000000000000014", "TKI:000000000000000000000000000000000015", "TKI:000000000000000000000000000000000016", "TKI:000000000000000000000000000000000017", "TKI:000000000000000000000000000000000018", "TKI:000000000000000000000000000000000019", "TKI:000000000000000000000000000000000020", "TKI:000000000000000000000000000000000021", "TKI:000000000000000000000000000000000022", "TKI:000000000000000000000000000000000023", "TKI:000000000000000000000000000000000024", "TKI:000000000000000000000000000000000025", "TKI:000000000000000000000000000000000026", "TKI:000000000000000000000000000000000027", "TKI:000000000000000000000000000000000028", "TKI:000000000000000000000000000000000029", "TKI:000000000000000000000000000000000030", "TKI:000000000000000000000000000000000031", "TKI:000000000000000000000000000000000032", "TKI:000000000000000000000000000000000033", "TKI:000000000000000000000000000000000034", "TKI:000000000000000000000000000000000035", "TKI:000000000000000000000000000000000053", "TKI:000000000000000000000000000000000054", "TKI:000000000000000000000000000000000055", "TKI:000000000000000000000000000000000100", "TKI:000000000000000000000000000000000101", "TKI:000000000000000000000000000000000102", "TKI:000000000000000000000000000000000103"));
    TaskService taskService = taskanaEngine.getTaskService();
    DaysToWorkingDaysConverter converter = DaysToWorkingDaysConverter.initialize(Collections.singletonList(new TimeIntervalColumnHeader(0)), Instant.now());
    for (String taskId : affectedTasks) {
        Task task = taskService.getTask(taskId);
        assertTrue(task.getModified().isAfter(before));
        assertTrue(task.getPriority() == 1000);
        long calendarDays = converter.convertWorkingDaysToDays(task.getPlanned(), 15);
        if (!taskId.equals("TKI:000000000000000000000000000000000008") && !taskId.equals("TKI:000000000000000000000000000000000053")) {
            assertTrue(task.getDue().equals(task.getPlanned().plus(Duration.ofDays(calendarDays))));
        }
    }
}
Also used : DaysToWorkingDaysConverter(pro.taskana.impl.DaysToWorkingDaysConverter) JobRunner(pro.taskana.impl.JobRunner) Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) Instant(java.time.Instant) Classification(pro.taskana.Classification) ArrayList(java.util.ArrayList) ClassificationService(pro.taskana.ClassificationService) TimeIntervalColumnHeader(pro.taskana.impl.report.impl.TimeIntervalColumnHeader) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 5 with Classification

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

the class UpdateClassificationAccTest method testUpdateClassificationFails.

@Test(expected = NotAuthorizedException.class)
public void testUpdateClassificationFails() throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException, InvalidArgumentException {
    String newName = "updated Name";
    String newEntryPoint = "updated EntryPoint";
    ClassificationService classificationService = taskanaEngine.getClassificationService();
    Classification classification = classificationService.getClassification("T2100", "DOMAIN_A");
    classification.setApplicationEntryPoint(newEntryPoint);
    classification.setCategory("PROCESS");
    classification.setCustom1("newCustom1");
    classification.setCustom2("newCustom2");
    classification.setCustom3("newCustom3");
    classification.setCustom4("newCustom4");
    classification.setCustom5("newCustom5");
    classification.setCustom6("newCustom6");
    classification.setCustom7("newCustom7");
    classification.setCustom8("newCustom8");
    classification.setDescription("newDescription");
    classification.setIsValidInDomain(false);
    classification.setName(newName);
    classification.setParentId("T2000");
    classification.setPriority(1000);
    classification.setServiceLevel("P2DT3H4M");
    classificationService.updateClassification(classification);
}
Also used : Classification(pro.taskana.Classification) ClassificationService(pro.taskana.ClassificationService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test)

Aggregations

Classification (pro.taskana.Classification)102 Test (org.junit.Test)88 Task (pro.taskana.Task)32 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)29 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)28 AbstractAccTest (acceptance.AbstractAccTest)23 WithAccessId (pro.taskana.security.WithAccessId)21 ClassificationSummary (pro.taskana.ClassificationSummary)20 Workbasket (pro.taskana.Workbasket)18 Connection (java.sql.Connection)14 ClassificationNotFoundException (pro.taskana.exceptions.ClassificationNotFoundException)14 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)13 TaskAlreadyExistException (pro.taskana.exceptions.TaskAlreadyExistException)11 ClassificationService (pro.taskana.ClassificationService)10 AttachmentPersistenceException (pro.taskana.exceptions.AttachmentPersistenceException)10 ConcurrencyException (pro.taskana.exceptions.ConcurrencyException)10 InvalidOwnerException (pro.taskana.exceptions.InvalidOwnerException)10 InvalidStateException (pro.taskana.exceptions.InvalidStateException)10 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)10 SystemException (pro.taskana.exceptions.SystemException)10