SW360ProjectClientAdapterAsyncImpl implements SW360ProjectClientAdapterAsync { @Override public CompletableFuture<Optional<SW360Project>> getProjectByNameAndVersion(String projectName, String projectVersion) { ProjectSearchParams nameSearchParams = ProjectSearchParams.builder() .withName(projectName) .build(); return getProjectClient().search(nameSearchParams) .thenApply(projects -> projects.stream() .filter(pr -> SW360ProjectAdapterUtils.hasEqualCoordinates(pr, projectName, projectVersion)) .findAny()); } 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);  }
@Test public void testGetProjectByNameAndVersion() { ProjectSearchParams searchParams = ProjectSearchParams.builder() .withName(PROJECT_NAME) .build(); when(projectClient.search(searchParams)) .thenReturn(CompletableFuture.completedFuture(Collections.singletonList(projectWithLink))); Optional<SW360Project> projectIdByNameAndVersion = block(projectClientAdapter.getProjectByNameAndVersion(PROJECT_NAME, PROJECT_VERSION)); assertThat(projectIdByNameAndVersion).isPresent(); assertThat(projectIdByNameAndVersion).contains(projectWithLink); }