@Test
public void testUpdateAttachmentsUncheckRemovesCheckedFields() {

    PortletRequest request = Mockito.mock(PortletRequest.class);
    // fill existing data
    User user = createUser("tid", "test@example.org", "tpd");
    Attachment attachment = createAttachments(user, "1").iterator().next();
    attachment.setCheckStatus(CheckStatus.ACCEPTED);
    attachment.setCheckedBy("check@example.org");
    attachment.setCheckedComment("check-comment");
    attachment.setCheckedOn("2017-01-31");
    attachment.setCheckedTeam("check-team");
    // fill request
    setAttachmentIds(request, "1");
    setAttachmentFilenames(request, "A");
    setAttachmentTypes(request, AttachmentType.SOURCE);
    setAttachmenCreatedComments(request, "CC1");
    setAttachmentCheckStatus(request, CheckStatus.NOTCHECKED);
    setAttachmentCheckComment(request, "");
    // run test
    Set<Attachment> updatedAttachments = PortletUtils.updateAttachmentsFromRequest(request, Sets.newHashSet(attachment));
    assertThat(updatedAttachments.size(), is(1));
    Attachment updatedAttachment = updatedAttachments.iterator().next();
    assertThat(updatedAttachment.getAttachmentContentId(), is("1"));
    assertThat(updatedAttachment.getCheckStatus(), is(CheckStatus.NOTCHECKED));
    assertNull(updatedAttachment.getCheckedBy());
    assertNull(updatedAttachment.getCheckedTeam());
    assertThat(updatedAttachment.getCheckedComment(), is(""));
}