@Test
public void testGetFullStream() throws Exception {

    AttachmentContent attachment = mock(AttachmentContent.class);
    when(attachment.isOnlyRemote()).thenReturn(false);
    when(attachment.isSetPartsCount()).thenReturn(false);
    when(attachment.getFilename()).thenReturn("fil");
    String attachmentId = "id";
    when(attachment.getId()).thenReturn(attachmentId);
    AttachmentInputStream full = mock(AttachmentInputStream.class);
    when(connector.getAttachment(attachmentId, "fil")).thenReturn(full);
    when(full.read()).thenReturn(1, 2, -1);
    InputStream attachmentStream = attachmentStreamConnector.getAttachmentStream(attachment, dummyUser,
            new Project()
                    .setVisbility(Visibility.ME_AND_MODERATORS)
                    .setCreatedBy(dummyUser.getEmail())
                    .setAttachments(Collections.singleton(new Attachment().setAttachmentContentId(attachmentId))));
    assertThat(attachmentStream.read(), is(1));
    assertThat(attachmentStream.read(), is(2));
    assertThat(attachmentStream.read(), is(-1));
}