SW360ReleaseClientAdapterAsyncImpl implements SW360ReleaseClientAdapterAsync { @Override public CompletableFuture<Optional<Path>> downloadAttachment(SW360Release release, SW360SparseAttachment attachment, Path downloadPath) { return SW360AttachmentUtils.downloadAttachment(getReleaseClient(), release, attachment, downloadPath); } SW360ReleaseClientAdapterAsyncImpl(SW360ReleaseClient client,
                                              SW360ComponentClientAdapterAsync componentClientAdapter); @Override SW360ReleaseClient getReleaseClient(); SW360ComponentClientAdapterAsync getComponentAdapter(); @Override CompletableFuture<SW360Release> createRelease(SW360Release release); @Override CompletableFuture<AttachmentUploadResult<SW360Release>> uploadAttachments(AttachmentUploadRequest<SW360Release> uploadRequest); @Override CompletableFuture<Optional<SW360Release>> getReleaseById(String releaseId); @Override CompletableFuture<Optional<SW360Release>> enrichSparseRelease(SW360SparseRelease sparseRelease); @Override CompletableFuture<Optional<SW360SparseRelease>> getSparseReleaseByExternalIds(Map<String, ?> externalIds); @Override CompletableFuture<Optional<SW360SparseRelease>> getSparseReleaseByNameAndVersion(String componentName,
                                                                                            String version); @Override CompletableFuture<Optional<SW360Release>> getReleaseByVersion(SW360Component component, String releaseVersion); @Override CompletableFuture<Optional<Path>> downloadAttachment(SW360Release release, SW360SparseAttachment attachment,
                                                                Path downloadPath); @Override CompletableFuture<T> processAttachment(SW360Release release, String attachmentId, SW360AttachmentAwareClient.AttachmentProcessor<? extends T> processor); @Override CompletableFuture<SW360Release> deleteAttachments(SW360Release release, Collection<String> attachmentIds); @Override CompletableFuture<SW360Release> updateRelease(SW360Release release); @Override CompletableFuture<MultiStatusResponse> deleteReleases(Collection<String> idsToDelete); @Override CompletableFuture<Void> deleteRelease(String releaseId);  }
@Test public void testDownloadAttachment() { addSelfLink(release); String attachmentId = "attach-9383764983"; String fileName = "theAttachmentFile.tst"; SW360SparseAttachment sparseAttachment = new SW360SparseAttachment(); sparseAttachment.getLinks().setSelf(new Self("https: sparseAttachment.setFilename(fileName); Path orgPath = Paths.get("download"); Path resultPath = Paths.get("downloadResult"); when(releaseClient.processAttachment(eq(RELEASE_HREF), eq(attachmentId), any())) .thenReturn(CompletableFuture.completedFuture(resultPath)); Optional<Path> downloadPath = block(releaseClientAdapter.downloadAttachment(release, sparseAttachment, orgPath)); assertThat(downloadPath).isPresent(); assertThat(downloadPath).hasValue(resultPath); ArgumentCaptor<SW360AttachmentUtils.AttachmentDownloadProcessorCreateDownloadFolder> captor = ArgumentCaptor.forClass(SW360AttachmentUtils.AttachmentDownloadProcessorCreateDownloadFolder.class); verify(releaseClient).processAttachment(eq(RELEASE_HREF), eq(attachmentId), captor.capture()); SW360AttachmentUtils.AttachmentDownloadProcessorCreateDownloadFolder processor = captor.getValue(); assertThat(processor.getDownloadPath()).isEqualTo(orgPath); assertThat(processor.getFileName()).isEqualTo(fileName); assertThat(processor.getCopyOptions()).contains(StandardCopyOption.REPLACE_EXISTING); }