@Test public void testAddSW360ReleasesToSW360Project() { SW360ReleaseLinkObjects releaseLinkObjects = new SW360ReleaseLinkObjects(); releaseLinkObjects.setSelf(linkObjects.getSelf()); SW360Release release = new SW360Release(); release.setLinks(releaseLinkObjects); when(projectClient.addReleasesToProject(eq(PROJECT_LAST_INDEX), any())) .thenReturn(CompletableFuture.completedFuture(null)); Collection<SW360Release> releases = Collections.singletonList(release); block(projectClientAdapter.addSW360ReleasesToSW360Project(PROJECT_LAST_INDEX, releases)); verify(projectClient, atLeastOnce()).addReleasesToProject(eq(PROJECT_LAST_INDEX), any()); }
@Override public CompletableFuture<Void> addSW360ReleasesToSW360Project(String id, Collection<SW360Release> releases) { List<String> releaseLinks = releases.stream() .map(SW360Release::getLinks) .filter(Objects::nonNull) .map(LinkObjects::getSelf) .filter(Objects::nonNull) .map(Self::getHref) .collect(Collectors.toList()); return getProjectClient().addReleasesToProject(id, releaseLinks); }
SW360ProjectClientAdapterAsyncImpl implements SW360ProjectClientAdapterAsync { @Override public CompletableFuture<Void> addSW360ReleasesToSW360Project(String id, Collection<SW360Release> releases) { List<String> releaseLinks = releases.stream() .map(SW360Release::getLinks) .filter(Objects::nonNull) .map(LinkObjects::getSelf) .filter(Objects::nonNull) .map(Self::getHref) .collect(Collectors.toList()); return getProjectClient().addReleasesToProject(id, releaseLinks); } }
SW360ProjectClientAdapterAsyncImpl implements SW360ProjectClientAdapterAsync { @Override public CompletableFuture<Void> addSW360ReleasesToSW360Project(String id, Collection<SW360Release> releases) { List<String> releaseLinks = releases.stream() .map(SW360Release::getLinks) .filter(Objects::nonNull) .map(LinkObjects::getSelf) .filter(Objects::nonNull) .map(Self::getHref) .collect(Collectors.toList()); return getProjectClient().addReleasesToProject(id, releaseLinks); } SW360ProjectClientAdapterAsyncImpl(SW360ProjectClient client); }
SW360ProjectClientAdapterAsyncImpl implements SW360ProjectClientAdapterAsync { @Override public CompletableFuture<Void> addSW360ReleasesToSW360Project(String id, Collection<SW360Release> releases) { List<String> releaseLinks = releases.stream() .map(SW360Release::getLinks) .filter(Objects::nonNull) .map(LinkObjects::getSelf) .filter(Objects::nonNull) .map(Self::getHref) .collect(Collectors.toList()); return getProjectClient().addReleasesToProject(id, releaseLinks); } SW360ProjectClientAdapterAsyncImpl(SW360ProjectClient client); @Override SW360ProjectClient getProjectClient(); @Override CompletableFuture<Optional<SW360Project>> getProjectByNameAndVersion(String projectName, String projectVersion); @Override CompletableFuture<List<SW360Project>> search(ProjectSearchParams params); @Override CompletableFuture<SW360Project> createProject(SW360Project project); @Override CompletableFuture<SW360Project> updateProject(SW360Project project); @Override CompletableFuture<Void> addSW360ReleasesToSW360Project(String id, Collection<SW360Release> releases); @Override CompletableFuture<List<SW360SparseRelease>> getLinkedReleases(String projectId, boolean transitive); }
SW360ProjectClientAdapterAsyncImpl implements SW360ProjectClientAdapterAsync { @Override public CompletableFuture<Void> addSW360ReleasesToSW360Project(String id, Collection<SW360Release> releases) { List<String> releaseLinks = releases.stream() .map(SW360Release::getLinks) .filter(Objects::nonNull) .map(LinkObjects::getSelf) .filter(Objects::nonNull) .map(Self::getHref) .collect(Collectors.toList()); return getProjectClient().addReleasesToProject(id, releaseLinks); } SW360ProjectClientAdapterAsyncImpl(SW360ProjectClient client); @Override SW360ProjectClient getProjectClient(); @Override CompletableFuture<Optional<SW360Project>> getProjectByNameAndVersion(String projectName, String projectVersion); @Override CompletableFuture<List<SW360Project>> search(ProjectSearchParams params); @Override CompletableFuture<SW360Project> createProject(SW360Project project); @Override CompletableFuture<SW360Project> updateProject(SW360Project project); @Override CompletableFuture<Void> addSW360ReleasesToSW360Project(String id, Collection<SW360Release> releases); @Override CompletableFuture<List<SW360SparseRelease>> getLinkedReleases(String projectId, boolean transitive);  }