Search in sources :

Example 11 with Attachment

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

the class TaskAttachmentTest method testAddNullValue.

@Test
public void testAddNullValue() {
    Attachment attachment1 = createAttachment("ID1", "taskId1");
    Attachment attachment2 = null;
    cut.addAttachment(attachment1);
    cut.addAttachment(attachment2);
    assertThat(cut.getAttachments().size(), equalTo(1));
}
Also used : Attachment(pro.taskana.Attachment) Test(org.junit.Test)

Example 12 with Attachment

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

the class TaskAttachmentTest method testRemoveLoopStopsAtResult.

@Test
public void testRemoveLoopStopsAtResult() {
    Attachment attachment1 = createAttachment("ID2", "taskId1");
    // adding same uncommon way to test that the loop will stop.
    cut.getAttachments().add(attachment1);
    cut.getAttachments().add(attachment1);
    cut.getAttachments().add(attachment1);
    assertThat(cut.getAttachments().size(), equalTo(3));
    Attachment actual = cut.removeAttachment(attachment1.getId());
    assertThat(cut.getAttachments().size(), equalTo(2));
    assertThat(actual, equalTo(attachment1));
}
Also used : Attachment(pro.taskana.Attachment) Test(org.junit.Test)

Example 13 with Attachment

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

the class AbstractAccTest method createAttachment.

protected Attachment createAttachment(String classificationKey, ObjectReference objRef, String channel, String receivedDate, Map<String, String> customAttributes) throws ClassificationNotFoundException, NotAuthorizedException {
    Attachment attachment = taskanaEngine.getTaskService().newAttachment();
    attachment.setClassificationSummary(taskanaEngine.getClassificationService().getClassification(classificationKey, "DOMAIN_A").asSummary());
    attachment.setObjectReference(objRef);
    attachment.setChannel(channel);
    Instant receivedTimestamp = null;
    if (receivedDate != null && receivedDate.length() < 11) {
        // contains only the date, not the time
        LocalDate date = LocalDate.parse(receivedDate);
        receivedTimestamp = date.atStartOfDay().toInstant(ZoneOffset.UTC);
    } else {
        receivedTimestamp = Instant.parse(receivedDate);
    }
    attachment.setReceived(receivedTimestamp);
    attachment.setCustomAttributes(customAttributes);
    return attachment;
}
Also used : Instant(java.time.Instant) Attachment(pro.taskana.Attachment) LocalDate(java.time.LocalDate)

Example 14 with Attachment

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

the class TaskImpl method removeAttachment.

@Override
public Attachment removeAttachment(String attachmentId) {
    Attachment result = null;
    Iterator<Attachment> i = attachments.iterator();
    while (i.hasNext()) {
        Attachment attachment = i.next();
        if (attachment.getId().equals(attachmentId)) {
            if (attachments.remove(attachment)) {
                result = attachment;
                break;
            }
        }
    }
    return result;
}
Also used : Attachment(pro.taskana.Attachment)

Example 15 with Attachment

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

the class TaskImpl method asSummary.

@Override
public TaskSummary asSummary() {
    TaskSummaryImpl taskSummary = new TaskSummaryImpl();
    List<AttachmentSummary> attSummaries = new ArrayList<>();
    for (Attachment att : attachments) {
        attSummaries.add(att.asSummary());
    }
    taskSummary.setAttachmentSummaries(attSummaries);
    taskSummary.setBusinessProcessId(this.businessProcessId);
    taskSummary.setClaimed(claimed);
    if (classificationSummary != null) {
        taskSummary.setClassificationSummary(classificationSummary);
    }
    taskSummary.setCompleted(completed);
    taskSummary.setCreated(created);
    taskSummary.setCustom1(custom1);
    taskSummary.setCustom2(custom2);
    taskSummary.setCustom3(custom3);
    taskSummary.setCustom4(custom4);
    taskSummary.setCustom5(custom5);
    taskSummary.setCustom6(custom6);
    taskSummary.setCustom7(custom7);
    taskSummary.setCustom8(custom8);
    taskSummary.setCustom9(custom9);
    taskSummary.setCustom10(custom10);
    taskSummary.setDue(due);
    taskSummary.setTaskId(id);
    taskSummary.setModified(modified);
    taskSummary.setName(name);
    taskSummary.setCreator(creator);
    taskSummary.setNote(note);
    taskSummary.setOwner(owner);
    taskSummary.setParentBusinessProcessId(parentBusinessProcessId);
    taskSummary.setPlanned(planned);
    taskSummary.setPrimaryObjRef(primaryObjRef);
    taskSummary.setPriority(priority);
    taskSummary.setRead(isRead);
    taskSummary.setState(state);
    taskSummary.setTransferred(isTransferred);
    taskSummary.setWorkbasketSummary(workbasketSummary);
    return taskSummary;
}
Also used : ArrayList(java.util.ArrayList) Attachment(pro.taskana.Attachment) AttachmentSummary(pro.taskana.AttachmentSummary)

Aggregations

Attachment (pro.taskana.Attachment)28 Test (org.junit.Test)17 Classification (pro.taskana.Classification)9 AbstractAccTest (acceptance.AbstractAccTest)7 ClassificationSummary (pro.taskana.ClassificationSummary)7 WithAccessId (pro.taskana.security.WithAccessId)7 Task (pro.taskana.Task)6 Workbasket (pro.taskana.Workbasket)6 Duration (java.time.Duration)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 AttachmentPersistenceException (pro.taskana.exceptions.AttachmentPersistenceException)4 SystemException (pro.taskana.exceptions.SystemException)4 Instant (java.time.Instant)3 ArrayList (java.util.ArrayList)3 PersistenceException (org.apache.ibatis.exceptions.PersistenceException)3 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)3 AttachmentSummary (pro.taskana.AttachmentSummary)2 TaskService (pro.taskana.TaskService)2 TaskSummary (pro.taskana.TaskSummary)2 WorkbasketSummary (pro.taskana.WorkbasketSummary)2