@Test public void testDownloadIfHashCalculationFails() { SW360SparseAttachment attachment = createAttachment(1, 1); attachment.setSha1(TEST_FILE_SHA1); Set<SW360SparseAttachment> attachments = Collections.singleton(attachment); SW360Release release = createReleaseWithAttachments(1, attachments); ReleaseWithSources releaseWithSources = createReleaseWithSources(release, attachments); createTestFile(sourcePath.resolve(attachment.getFilename())); expectDownloads(release, attachments); sourcesExporter = new SourcesExporter(sourcePath) { @Override String calculateLocalAttachmentHash(Path localPath) { throw new SW360ClientException("Hash failure"); } }; Collection<ReleaseWithSources> result = sourcesExporter.downloadSources(releaseAdapter, Collections.singleton(release)); assertThat(result).containsOnly(releaseWithSources); verify(releaseAdapter).processAttachment(eq(release), eq(attachment.getAttachmentId()), any(SW360AttachmentUtils.AttachmentDownloadProcessorCreateDownloadFolderWithParents.class)); }
public Collection<ReleaseWithSources> downloadSources(SW360ReleaseClientAdapterAsync releaseAdapter, Collection<SW360Release> releases) { List<CompletableFuture<ReleaseWithSources>> downloadFutures = releases.stream() .map(release -> downloadSourcesForRelease(releaseAdapter, release)) .collect(Collectors.toList()); return FutureUtils.sequence(downloadFutures, ex -> false).join(); }
SourcesExporter { public Collection<ReleaseWithSources> downloadSources(SW360ReleaseClientAdapterAsync releaseAdapter, Collection<SW360Release> releases) { List<CompletableFuture<ReleaseWithSources>> downloadFutures = releases.stream() .map(release -> downloadSourcesForRelease(releaseAdapter, release)) .collect(Collectors.toList()); return FutureUtils.sequence(downloadFutures, ex -> false).join(); } }
SourcesExporter { public Collection<ReleaseWithSources> downloadSources(SW360ReleaseClientAdapterAsync releaseAdapter, Collection<SW360Release> releases) { List<CompletableFuture<ReleaseWithSources>> downloadFutures = releases.stream() .map(release -> downloadSourcesForRelease(releaseAdapter, release)) .collect(Collectors.toList()); return FutureUtils.sequence(downloadFutures, ex -> false).join(); } SourcesExporter(Path sourcePath); }
SourcesExporter { public Collection<ReleaseWithSources> downloadSources(SW360ReleaseClientAdapterAsync releaseAdapter, Collection<SW360Release> releases) { List<CompletableFuture<ReleaseWithSources>> downloadFutures = releases.stream() .map(release -> downloadSourcesForRelease(releaseAdapter, release)) .collect(Collectors.toList()); return FutureUtils.sequence(downloadFutures, ex -> false).join(); } SourcesExporter(Path sourcePath); Collection<ReleaseWithSources> downloadSources(SW360ReleaseClientAdapterAsync releaseAdapter,
                                                          Collection<SW360Release> releases); void removeUnreferencedFiles(Collection<ReleaseWithSources> releases); }
SourcesExporter { public Collection<ReleaseWithSources> downloadSources(SW360ReleaseClientAdapterAsync releaseAdapter, Collection<SW360Release> releases) { List<CompletableFuture<ReleaseWithSources>> downloadFutures = releases.stream() .map(release -> downloadSourcesForRelease(releaseAdapter, release)) .collect(Collectors.toList()); return FutureUtils.sequence(downloadFutures, ex -> false).join(); } SourcesExporter(Path sourcePath); Collection<ReleaseWithSources> downloadSources(SW360ReleaseClientAdapterAsync releaseAdapter,
                                                          Collection<SW360Release> releases); void removeUnreferencedFiles(Collection<ReleaseWithSources> releases);  }