@Test
public void testUpdateAttachmentsFromRequestOnlyAddToEmpty() {

    PortletRequest request = Mockito.mock(PortletRequest.class);
    new TestUserCacheHolder().enable();
    // fill existing data
    Set<Attachment> documentAttachments = ImmutableSet.of(); // use immutable set to ensure that set is not changed.
    // fill request
    setAttachmentIds(request, "1", "2", "3");
    setAttachmentFilenames(request, "A", "B", "C");
    setAttachmentTypes(request, AttachmentType.DOCUMENT, AttachmentType.BINARY, AttachmentType.DECISION_REPORT);
    setAttachmenCreatedComments(request, "CC1", "CC2", "CC3");
    setAttachmentCheckStatus(request, CheckStatus.NOTCHECKED, CheckStatus.ACCEPTED, CheckStatus.REJECTED);
    setAttachmentCheckComment(request, "CCK1", "CCK2", "CCK3");
    // run tests
    Set<Attachment> updatedAttachments = PortletUtils.updateAttachmentsFromRequest(request, documentAttachments);
    assertThat(updatedAttachments.size(), is(3));
    assertThat(updatedAttachments.stream().map(Attachment::getAttachmentContentId).collect(Collectors.toList()),
            containsInAnyOrder("1", "2", "3"));
}