use of com.synopsys.integration.blackduck.api.core.response.LinkMultipleResponses in project synopsys-detect by blackducksoftware.
the class VerifyBlackDuckDetectTask method verifyBlackDuckAction.
@TaskAction
public void verifyBlackDuckAction() throws IntegrationException {
BlackDuckServerConfigBuilder blackDuckServerConfigBuilder = BlackDuckServerConfig.newApiTokenBuilder();
Set<String> environmentKeys = blackDuckServerConfigBuilder.getEnvironmentVariableKeys();
environmentKeys.forEach(it -> {
String value = System.getenv().get(it);
if (value != null) {
blackDuckServerConfigBuilder.setProperty(it, value);
}
});
BlackDuckServerConfig blackDuckServerConfig = blackDuckServerConfigBuilder.build();
BlackDuckServicesFactory blackDuckServicesFactory = blackDuckServerConfig.createBlackDuckServicesFactory(new PrintStreamIntLogger(System.out, com.synopsys.integration.log.LogLevel.INFO));
BlackDuckApiClient blackDuckService = blackDuckServicesFactory.getBlackDuckApiClient();
ProjectService projectService = blackDuckServicesFactory.createProjectService();
ProjectVersionWrapper projectVersionWrapper = projectService.getProjectVersion(getProject().getName(), getProject().getVersion().toString()).get();
// TODO: ProjectVersionView::metaComponentsLink appears to return the incorrect type. I had to manually construct the correct COMPONENTS_LINK. -JM 07/2021
LinkMultipleResponses<ProjectVersionComponentVersionView> linkMultipleResponses = new LinkMultipleResponses<>(COMPONENTS_LINK, ProjectVersionComponentVersionView.class);
UrlMultipleResponses<ProjectVersionComponentVersionView> urlMultipleResponses = projectVersionWrapper.getProjectVersionView().metaMultipleResponses(linkMultipleResponses);
List<ProjectVersionComponentVersionView> bomComponents = blackDuckService.getAllResponses(urlMultipleResponses);
if (bomComponents.isEmpty()) {
throw new GradleException("No bom components were found for ${project.name} - ${version}");
}
bomComponents.forEach(it -> System.out.println(it.getComponentName() + " - " + it.getComponentVersionName()));
}
use of com.synopsys.integration.blackduck.api.core.response.LinkMultipleResponses in project blackduck-common-api by blackducksoftware.
the class LinkBlackDuckResponseTest method testLinkResponseEquality.
@Test
public void testLinkResponseEquality() {
final LinkBlackDuckResponse linkResponse1 = new LinkSingleResponse<>("uri", ProjectView.class);
final LinkBlackDuckResponse linkResponse2 = new LinkMultipleResponses<>("uri", ProjectView.class);
final LinkBlackDuckResponse linkResponse3 = new LinkSingleResponse<>("uri", ProjectView.class);
assertNotEquals(linkResponse1, linkResponse2);
assertEquals(linkResponse1, linkResponse3);
}
Aggregations