@Test
public void testUpdateAttachmentsFromRequestUpdateOnly() {

    PortletRequest request = Mockito.mock(PortletRequest.class);
    // fill existing data
    User user = createUser("tid", "test@example.org", "tpd");
    new TestUserCacheHolder().enable(user);
    Set<Attachment> documentAttachments = createAttachments(user, "1", "2", "3");
    // fill request
    new TestUserCacheHolder().enable(createUser("cid", "check@example.org", "cpd"));
    setAttachmentIds(request, "1", "2", "3");
    setAttachmentFilenames(request, "A", "B", "C");
    setAttachmentTypes(request, AttachmentType.DOCUMENT, AttachmentType.SOURCE, AttachmentType.DESIGN);
    setAttachmenCreatedComments(request, "CC1", "CC2", "CC3");
    setAttachmentCheckStatus(request, CheckStatus.NOTCHECKED, CheckStatus.ACCEPTED, CheckStatus.ACCEPTED);
    setAttachmentCheckComment(request, "", "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"));
    assertThat(updatedAttachments.stream().map(Attachment::getFilename).collect(Collectors.toList()),
            containsInAnyOrder("file1", "file2", "file3"));
    assertThat(updatedAttachments.stream().map(Attachment::getAttachmentType).collect(Collectors.toList()),
            containsInAnyOrder(AttachmentType.DOCUMENT, AttachmentType.SOURCE, AttachmentType.DESIGN));
    assertThat(updatedAttachments.stream().map(Attachment::getCreatedBy).collect(Collectors.toList()),
            containsInAnyOrder("test@example.org", "test@example.org", "test@example.org"));
    assertThat(updatedAttachments.stream().map(Attachment::getCreatedTeam).collect(Collectors.toList()),
            containsInAnyOrder("tpd", "tpd", "tpd"));
    assertThat(updatedAttachments.stream().map(Attachment::getCreatedComment).collect(Collectors.toList()),
            containsInAnyOrder("CC1", "CC2", "CC3"));
    assertThat(updatedAttachments.stream().map(Attachment::getCheckStatus).collect(Collectors.toList()),
            containsInAnyOrder(CheckStatus.NOTCHECKED, CheckStatus.ACCEPTED, CheckStatus.ACCEPTED));
    assertThat(updatedAttachments.stream().map(Attachment::getCheckedBy).collect(Collectors.toList()),
            containsInAnyOrder(null, "check@example.org", "check@example.org"));
    assertThat(updatedAttachments.stream().map(Attachment::getCheckedTeam).collect(Collectors.toList()),
            containsInAnyOrder(null, "cpd", "cpd"));
    assertThat(updatedAttachments.stream().map(Attachment::getCheckedComment).collect(Collectors.toList()),
            containsInAnyOrder("", "CCK2", "CCK3"));
}