Search in sources :

Example 1 with AttachmentImpl

use of pro.taskana.impl.AttachmentImpl in project taskana by Taskana.

the class UpdateTaskAttachmentsAccTest method testAddExistingAttachmentAgainWillDoNothingWhenEqual.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testAddExistingAttachmentAgainWillDoNothingWhenEqual() throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, AttachmentPersistenceException, SQLException {
    setUpMethod();
    // Add Attachment before
    int attachmentCount = task.getAttachments().size();
    ((AttachmentImpl) attachment).setId("TAI:0001");
    task.addAttachment(attachment);
    // overwrite, same id
    task.addAttachment(attachment);
    // overwrite, same id
    task.addAttachment(attachment);
    task = taskService.updateTask(task);
    task = taskService.getTask(task.getId());
    assertThat(task.getAttachments().size(), equalTo(attachmentCount + 1));
    // Add same again - ignored
    attachmentCount = task.getAttachments().size();
    Attachment redundantAttachment = task.getAttachments().get(0);
    task.addAttachment(redundantAttachment);
    task = taskService.updateTask(task);
    assertThat(task.getAttachments().size(), equalTo(attachmentCount));
}
Also used : AttachmentImpl(pro.taskana.impl.AttachmentImpl) Attachment(pro.taskana.Attachment) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 2 with AttachmentImpl

use of pro.taskana.impl.AttachmentImpl in project taskana by Taskana.

the class UpdateTaskAttachmentsAccTest method testAddNewAttachmentTwiceWithoutTaskanaMethodWillThrowAttachmentPersistenceException.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test(expected = AttachmentPersistenceException.class)
public void testAddNewAttachmentTwiceWithoutTaskanaMethodWillThrowAttachmentPersistenceException() throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException, AttachmentPersistenceException, SQLException {
    setUpMethod();
    int attachmentCount = 0;
    task.getAttachments().clear();
    task = taskService.updateTask(task);
    task = taskService.getTask(task.getId());
    assertThat(task.getAttachments().size(), equalTo(attachmentCount));
    AttachmentImpl attachment = (AttachmentImpl) this.attachment;
    attachment.setId("TAI:000017");
    task.getAttachments().add(attachment);
    task.getAttachments().add(attachment);
    task.getAttachments().add(attachment);
    task = taskService.updateTask(task);
}
Also used : AttachmentImpl(pro.taskana.impl.AttachmentImpl) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Aggregations

AbstractAccTest (acceptance.AbstractAccTest)2 Test (org.junit.Test)2 AttachmentImpl (pro.taskana.impl.AttachmentImpl)2 WithAccessId (pro.taskana.security.WithAccessId)2 Attachment (pro.taskana.Attachment)1