@Test
public void testAFailedSendToFossology() throws Exception {

    final String id = "41";
    final FilledAttachment filledAttachment = getMockFilledAttachment(id);
    final AttachmentContent attachmentContent = filledAttachment.getAttachmentContent();
    final Release release = mock(Release.class);
    when(componentService.getReleaseById(releaseId, user)).thenReturn(release);
    spyGetFilledSourceAttachment(filledAttachment);
    final InputStream inputStream = mock(InputStream.class);
    when(release.isSetFossologyId()).thenReturn(false);
    when(attachmentConnector.getAttachmentStream(attachmentContent, user, release)).thenReturn(inputStream);
    when(fossologyUploader.uploadToFossology(inputStream, attachmentContent, clearingTeam)).thenReturn(-1);
    assertThat(fossologyFileHandler.sendToFossology(releaseId, user, clearingTeam), is(RequestStatus.FAILURE));
    verify(inputStream).close();
    // unimportant verifies
    verify(componentService, atLeastOnce()).getReleaseById(releaseId, user);
    verify(attachmentConnector).getAttachmentStream(attachmentContent, user, release);
    verify(fossologyUploader).uploadToFossology(inputStream, attachmentContent, clearingTeam);
}