@Test
public void testUploadToFossology() throws Exception {

    AttachmentContent attachment = mock(AttachmentContent.class);
    when(attachment.getId()).thenReturn("id");
    when(attachment.getFilename()).thenReturn("fileName");
    String clearingTeam = "cl";
    final InputStream inputStream = mock(InputStream.class);
    doAnswer(new Answer() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            final Object[] arguments = invocation.getArguments();
            String command = (String) arguments[0];
            InputStream input = (InputStream) arguments[1];
            OutputStream outputStream = (OutputStream) arguments[2];
            assertThat(input, sameInstance(inputStream));
            assertThat(command, is("./uploadFromSW360 -i 'id' -g 'cl' -f 'fileName'"));
            outputStream.write("uploadId=60".getBytes());
            return 0;
        }
    }).when(sshConnector).runInFossologyViaSsh(anyString(), eq(inputStream), any(OutputStream.class));
    final long uploadId = fossologyUploader.uploadToFossology(inputStream, attachment, clearingTeam);
    verify(sshConnector).runInFossologyViaSsh(anyString(), eq(inputStream), any(OutputStream.class));
    assertThat(uploadId, is((long) 60));
}