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));
}
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);
}
Aggregations