@Test
public void testUpdateAttachmentsRemoveAndUpdate() {

    PortletRequest request = Mockito.mock(PortletRequest.class);
    new TestUserCacheHolder().enable();
    // fill existing data
    Set<Attachment> documentAttachments = createAttachments("1", "2", "3");
    // fill request
    new TestUserCacheHolder().enable(createUser("tid", "test@example.org", "tpd"));
    setAttachmentIds(request, "2");
    setAttachmentFilenames(request, "B");
    setAttachmentTypes(request, AttachmentType.SCREENSHOT);
    setAttachmenCreatedComments(request, "CC2");
    setAttachmentCheckStatus(request, CheckStatus.ACCEPTED);
    setAttachmentCheckComment(request, "CCK2");
    // run tests
    Set<Attachment> updatedAttachments = PortletUtils.updateAttachmentsFromRequest(request, documentAttachments);
    // assertThat(documentAttachments.size(), is(3));
    assertThat(updatedAttachments.size(), is(1));
    Attachment updatedAttachment = updatedAttachments.iterator().next();
    assertThat(updatedAttachment.getAttachmentContentId(), is("2"));
    assertThat(updatedAttachment.getCheckStatus(), is(CheckStatus.ACCEPTED));
    assertThat(updatedAttachment.getCheckedBy(), is("test@example.org"));
    assertThat(updatedAttachment.getCheckedTeam(), is("tpd"));
    assertThat(updatedAttachment.getCheckedComment(), is("CCK2"));
}