@Test
public void testUpdateAttachmentsFromRequestAddAndUpdate() {

    PortletRequest request = Mockito.mock(PortletRequest.class);
    new TestUserCacheHolder().enable();
    // fill existing data
    Set<Attachment> documentAttachments = createAttachments("9", "8");
    // fill request
    setAttachmentIds(request, "1", "2", "8", "9");
    setAttachmentFilenames(request, "A", "B", "C", "D");
    setAttachmentTypes(request, AttachmentType.DOCUMENT, AttachmentType.BINARY, AttachmentType.DECISION_REPORT, AttachmentType.OTHER);
    setAttachmenCreatedComments(request, "CC1", "CC2", "CC3", "CC4");
    setAttachmentCheckStatus(request, CheckStatus.NOTCHECKED, CheckStatus.ACCEPTED, CheckStatus.REJECTED, CheckStatus.NOTCHECKED);
    setAttachmentCheckComment(request, "CCK1", "CCK2", "CCK3", "CCK4;");
    // run test
    Set<Attachment> updatedAttachments = PortletUtils.updateAttachmentsFromRequest(request, documentAttachments);
    assertThat(updatedAttachments.size(), is(4));
    assertThat(updatedAttachments.stream().map(Attachment::getAttachmentContentId).collect(Collectors.toList()),
            containsInAnyOrder("1", "2", "8", "9"));
    assertThat(updatedAttachments.stream().map(Attachment::getFilename).collect(Collectors.toList()),
            containsInAnyOrder("A", "B", "file8", "file9"));
}