SW360ProjectClientAdapterAsyncImpl implements SW360ProjectClientAdapterAsync { @Override public CompletableFuture<SW360Project> updateProject(SW360Project project) { return validateProjectAndProcess(project, getProjectClient()::updateProject); } 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 testUpdateProject() { SW360Project projectUpdated = new SW360Project(); projectUpdated.setName(PROJECT_NAME); projectUpdated.setVersion(PROJECT_VERSION); projectUpdated.setDescription("project that was updated"); when(projectClient.updateProject(projectWithLink)) .thenReturn(CompletableFuture.completedFuture(projectUpdated)); SW360Project result = block(projectClientAdapter.updateProject(projectWithLink)); assertThat(result).isEqualTo(projectUpdated); }
@Test public void testUpdateProjectInvalidNoVersion() throws InterruptedException { SW360Project project = new SW360Project(); project.setName(PROJECT_NAME); CompletableFuture<SW360Project> future = projectClientAdapter.updateProject(project); try { future.get(); fail("Invalid project not detected!"); } catch (ExecutionException e) { assertThat(e.getCause()).isInstanceOf(SW360ClientException.class); assertThat(e.getCause().getMessage()).contains("invalid project"); } }