use of pro.taskana.Attachment in project taskana by Taskana.
the class UpdateTaskAttachmentsAccTest method testRemoveAttachment.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testRemoveAttachment() throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException, AttachmentPersistenceException, SQLException {
setUpMethod();
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();
Attachment attachmentToRemove = task.getAttachments().get(0);
task.removeAttachment(attachmentToRemove.getId());
task = taskService.updateTask(task);
// locally, removed and not persisted
assertThat(task.getAttachments().size(), equalTo(attachmentCount - 1));
task = taskService.getTask(task.getId());
// persisted, values removed
assertThat(task.getAttachments().size(), equalTo(attachmentCount - 1));
assertTrue(task.getPriority() == 1);
assertTrue(task.getDue().equals(task.getPlanned().plus(Duration.ofDays(1))));
}
use of pro.taskana.Attachment in project taskana by Taskana.
the class UpdateTaskAttachmentsAccTest method replaceExistingAttachments.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void replaceExistingAttachments() 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("DOCTYPE_DEFAULT", createObjectReference("COMPANY_B", "SYSTEM_C", "INSTANCE_C", "ArchiveId", "ABC45678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(4));
task.addAttachment(attachment2);
task = taskService.updateTask(task);
task = taskService.getTask(task.getId());
assertThat(task.getAttachments().size(), equalTo(2));
assertThat(task.getAttachments().get(0).getClassificationSummary().getKey(), equalTo("DOCTYPE_DEFAULT"));
Attachment attachment3 = createAttachment("DOCTYPE_DEFAULT", createObjectReference("COMPANY_C", "SYSTEM_7", "INSTANCE_7", "ArchiveId", "ABC4567890123456789012345678901234567890DEF"), "DHL", "2018-01-15", createSimpleCustomProperties(4));
// replace existing attachments by new via addAttachment call
task.getAttachments().clear();
task.addAttachment(attachment3);
task = taskService.updateTask(task);
assertThat(task.getAttachments().size(), equalTo(1));
assertThat(task.getAttachments().get(0).getChannel(), equalTo("DHL"));
// setup environment for 2nd version of replacement (list.add call)
task.getAttachments().add(attachment2);
task = taskService.updateTask(task);
assertThat(task.getAttachments().size(), equalTo(2));
assertThat(task.getAttachments().get(1).getChannel(), equalTo("E-MAIL"));
// replace attachments
task.getAttachments().clear();
task.getAttachments().add(attachment3);
task = taskService.updateTask(task);
assertThat(task.getAttachments().size(), equalTo(1));
assertThat(task.getAttachments().get(0).getChannel(), equalTo("DHL"));
}
use of pro.taskana.Attachment 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.Attachment 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()));
}
use of pro.taskana.Attachment 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()));
}
Aggregations