@Test
public void testUploadAttachmentsWithFailures() {

    Path uploadPath1 = Paths.get("failedUpload1.err");
    SW360AttachmentType attachmentType1 = SW360AttachmentType.DESIGN;
    Throwable failure1 = new IOException("I/O exception during upload");
    Path uploadPath2 = Paths.get("failedUpload2.exc");
    SW360AttachmentType attachmentType2 = SW360AttachmentType.BINARY_SELF;
    Throwable failure2 = new SW360ClientException("Forbidden upload");
    Path uploadPath3 = Paths.get("success.yes");
    SW360AttachmentType attachmentType3 = SW360AttachmentType.CLEARING_REPORT;
    release.setEmbedded(createEmbeddedReleaseWithAttachments());
    SW360Release updatedRelease = createReleaseWithAttachments("attach1");
    AttachmentUploadRequest<SW360Release> uploadRequest = AttachmentUploadRequest.builder(release)
            .addAttachment(uploadPath1, attachmentType1)
            .addAttachment(uploadPath2, attachmentType2)
            .addAttachment(uploadPath3, attachmentType3)
            .build();
    when(releaseClient.uploadAndAttachAttachment(release, uploadPath1, attachmentType1))
            .thenReturn(FutureUtils.failedFuture(failure1));
    when(releaseClient.uploadAndAttachAttachment(release, uploadPath2, attachmentType2))
            .thenReturn(FutureUtils.failedFuture(failure2));
    when(releaseClient.uploadAndAttachAttachment(release, uploadPath3, attachmentType3))
            .thenReturn(CompletableFuture.completedFuture(updatedRelease));
    AttachmentUploadResult<SW360Release> result = block(releaseClientAdapter.uploadAttachments(uploadRequest));
    assertThat(result.getTarget()).isEqualTo(updatedRelease);
    assertThat(result.isSuccess()).isFalse();
    assertThat(result.successfulUploads())
            .containsOnly(new AttachmentUploadRequest.Item(uploadPath3, attachmentType3));
    assertThat(result.failedUploads()).hasSize(2);
    assertThat(result.failedUploads().get(new AttachmentUploadRequest.Item(uploadPath1, attachmentType1)))
            .isEqualTo(failure1);
    assertThat(result.failedUploads().get(new AttachmentUploadRequest.Item(uploadPath2, attachmentType2)))
            .isEqualTo(failure2);
}