@Test public void testGetReleaseByExternalIdsNotFound() { Map<String, String> externalIds = new HashMap<>(); when(releaseClient.getReleasesByExternalIds(externalIds)) .thenReturn(CompletableFuture.completedFuture(Collections.emptyList())); Optional<SW360SparseRelease> releaseByExternalIds = block(releaseClientAdapter.getSparseReleaseByExternalIds(externalIds)); assertThat(releaseByExternalIds).isEmpty(); }
@Override public CompletableFuture<Optional<SW360SparseRelease>> getSparseReleaseByExternalIds(Map<String, ?> externalIds) { return getReleaseClient().getReleasesByExternalIds(externalIds) .thenApply(releases -> { if (releases.isEmpty()) { return Optional.empty(); } else if (releases.size() == 1) { return Optional.of(releases.get(0)); } else { throw new SW360ClientException("Multiple releases in SW360 matched by externalIDs: " + externalIds); } }); }
SW360ReleaseClientAdapterAsyncImpl implements SW360ReleaseClientAdapterAsync { @Override public CompletableFuture<Optional<SW360SparseRelease>> getSparseReleaseByExternalIds(Map<String, ?> externalIds) { return getReleaseClient().getReleasesByExternalIds(externalIds) .thenApply(releases -> { if (releases.isEmpty()) { return Optional.empty(); } else if (releases.size() == 1) { return Optional.of(releases.get(0)); } else { throw new SW360ClientException("Multiple releases in SW360 matched by externalIDs: " + externalIds); } }); } }
SW360ReleaseClientAdapterAsyncImpl implements SW360ReleaseClientAdapterAsync { @Override public CompletableFuture<Optional<SW360SparseRelease>> getSparseReleaseByExternalIds(Map<String, ?> externalIds) { return getReleaseClient().getReleasesByExternalIds(externalIds) .thenApply(releases -> { if (releases.isEmpty()) { return Optional.empty(); } else if (releases.size() == 1) { return Optional.of(releases.get(0)); } else { throw new SW360ClientException("Multiple releases in SW360 matched by externalIDs: " + externalIds); } }); } SW360ReleaseClientAdapterAsyncImpl(SW360ReleaseClient client,
                                              SW360ComponentClientAdapterAsync componentClientAdapter); }
SW360ReleaseClientAdapterAsyncImpl implements SW360ReleaseClientAdapterAsync { @Override public CompletableFuture<Optional<SW360SparseRelease>> getSparseReleaseByExternalIds(Map<String, ?> externalIds) { return getReleaseClient().getReleasesByExternalIds(externalIds) .thenApply(releases -> { if (releases.isEmpty()) { return Optional.empty(); } else if (releases.size() == 1) { return Optional.of(releases.get(0)); } else { throw new SW360ClientException("Multiple releases in SW360 matched by externalIDs: " + externalIds); } }); } 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); }
SW360ReleaseClientAdapterAsyncImpl implements SW360ReleaseClientAdapterAsync { @Override public CompletableFuture<Optional<SW360SparseRelease>> getSparseReleaseByExternalIds(Map<String, ?> externalIds) { return getReleaseClient().getReleasesByExternalIds(externalIds) .thenApply(releases -> { if (releases.isEmpty()) { return Optional.empty(); } else if (releases.size() == 1) { return Optional.of(releases.get(0)); } else { throw new SW360ClientException("Multiple releases in SW360 matched by externalIDs: " + externalIds); } }); } 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);  }