@Test
public void testGetConcatenatedStreamReadThrowsOnNonExistent() throws Exception {

    AttachmentContent attachment = mock(AttachmentContent.class);
    when(attachment.isOnlyRemote()).thenReturn(false);
    when(attachment.isSetPartsCount()).thenReturn(true);
    when(attachment.getPartsCount()).thenReturn("2");
    when(attachment.getFilename()).thenReturn("fil");
    String attachmentId = "id";
    when(attachment.getId()).thenReturn(attachmentId);
    AttachmentInputStream part1 = mock(AttachmentInputStream.class);
    when(connector.getAttachment(attachmentId, "fil_part1")).thenReturn(part1);
    when(connector.getAttachment(attachmentId, "fil_part2")).thenThrow(new DocumentNotFoundException(""));
    when(part1.read()).thenReturn(1, -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));
    try {
        assertThat(attachmentStream.read(), is(2));
        fail("expected Exception not thrown");
    } catch (IOException ignored) {
    }
    verify(part1).close();
}