Search in sources :

Example 1 with LinkMultipleResponses

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()));
}
Also used : BlackDuckServerConfigBuilder(com.synopsys.integration.blackduck.configuration.BlackDuckServerConfigBuilder) PrintStreamIntLogger(com.synopsys.integration.log.PrintStreamIntLogger) BlackDuckApiClient(com.synopsys.integration.blackduck.service.BlackDuckApiClient) ProjectService(com.synopsys.integration.blackduck.service.dataservice.ProjectService) BlackDuckServicesFactory(com.synopsys.integration.blackduck.service.BlackDuckServicesFactory) BlackDuckServerConfig(com.synopsys.integration.blackduck.configuration.BlackDuckServerConfig) GradleException(org.gradle.api.GradleException) LinkMultipleResponses(com.synopsys.integration.blackduck.api.core.response.LinkMultipleResponses) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) ProjectVersionComponentVersionView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionComponentVersionView) TaskAction(org.gradle.api.tasks.TaskAction)

Example 2 with LinkMultipleResponses

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);
}
Also used : LinkSingleResponse(com.synopsys.integration.blackduck.api.core.response.LinkSingleResponse) LinkMultipleResponses(com.synopsys.integration.blackduck.api.core.response.LinkMultipleResponses) LinkBlackDuckResponse(com.synopsys.integration.blackduck.api.core.response.LinkBlackDuckResponse) Test(org.junit.jupiter.api.Test)

Aggregations

LinkMultipleResponses (com.synopsys.integration.blackduck.api.core.response.LinkMultipleResponses)2 LinkBlackDuckResponse (com.synopsys.integration.blackduck.api.core.response.LinkBlackDuckResponse)1 LinkSingleResponse (com.synopsys.integration.blackduck.api.core.response.LinkSingleResponse)1 ProjectVersionComponentVersionView (com.synopsys.integration.blackduck.api.generated.view.ProjectVersionComponentVersionView)1 BlackDuckServerConfig (com.synopsys.integration.blackduck.configuration.BlackDuckServerConfig)1 BlackDuckServerConfigBuilder (com.synopsys.integration.blackduck.configuration.BlackDuckServerConfigBuilder)1 BlackDuckApiClient (com.synopsys.integration.blackduck.service.BlackDuckApiClient)1 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)1 ProjectService (com.synopsys.integration.blackduck.service.dataservice.ProjectService)1 ProjectVersionWrapper (com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper)1 PrintStreamIntLogger (com.synopsys.integration.log.PrintStreamIntLogger)1 GradleException (org.gradle.api.GradleException)1 TaskAction (org.gradle.api.tasks.TaskAction)1 Test (org.junit.jupiter.api.Test)1