TSK-517: initializing custom attributes for AttachmentImpl with HashMap.

This commit is contained in:
Holger Hagen 2018-06-07 14:00:22 +02:00 committed by Martin Rojas Miguel Angel
parent 2aeb815d8e
commit 8d376131cf
3 changed files with 26 additions and 3 deletions

View File

@ -1,7 +1,7 @@
package pro.taskana.impl;
import java.time.Instant;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import pro.taskana.Attachment;
@ -24,7 +24,7 @@ public class AttachmentImpl implements Attachment {
private ObjectReference objectReference;
private String channel;
private Instant received;
private Map<String, String> customAttributes = Collections.emptyMap();
private Map<String, String> customAttributes = new HashMap<String, String>();
AttachmentImpl() {
}

View File

@ -94,7 +94,9 @@ public abstract class AbstractAccTest {
receivedTimestamp = Instant.parse(receivedDate);
}
attachment.setReceived(receivedTimestamp);
attachment.setCustomAttributes(customAttributes);
if (customAttributes != null) {
attachment.setCustomAttributes(customAttributes);
}
return attachment;
}

View File

@ -484,4 +484,25 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
assertTrue(readTask.getDue().equals(readTask.getPlanned().plus(Duration.ofDays(calendarDays))));
}
@WithAccessId(
userName = "user_1_1",
groupNames = {"group_1"})
@Test
public void testAddCustomAttributeToAttachment()
throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException,
AttachmentPersistenceException, SQLException {
TaskService taskService = taskanaEngine.getTaskService();
task = taskService.getTask("TKI:000000000000000000000000000000000000"); // class T2000, prio 1, SL P1D
attachment = createAttachment("DOCTYPE_DEFAULT", // prio 99, SL P2000D
createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId",
"12345678901234567890123456789012345678901234567890"),
"E-MAIL", "2018-01-15", null);
attachment.getCustomAttributes().put("TEST_KEY", "TEST_VALUE");
task.addAttachment(attachment);
taskService.updateTask(task);
Task updatedTask = taskService.getTask("TKI:000000000000000000000000000000000000");
assertEquals("TEST_VALUE", updatedTask.getAttachments().get(0).getCustomAttributes().get("TEST_KEY"));
}
}