Search in sources :

Example 1 with ReportService

use of com.synopsys.integration.detect.workflow.blackduck.report.service.ReportService in project synopsys-detect by blackducksoftware.

the class RiskReportServiceTestIT method createReportPdfFileTest.

@Test
@ExtendWith(TempDirectory.class)
public void createReportPdfFileTest(@TempDirectory.TempDir Path folderForReport) throws IntegrationException {
    BlackDuckTestConnection blackDuckTestConnection = BlackDuckTestConnection.fromEnvironment();
    ReportService reportService = blackDuckTestConnection.createReportService();
    ProjectVersionWrapper projectVersionWrapper = blackDuckTestConnection.projectVersionAssertions(PROJECT_NAME, PROJECT_VERSION_NAME).retrieveProjectVersionWrapper();
    File folder = folderForReport.toFile();
    File pdfFile = reportService.createReportPdfFile(folder, projectVersionWrapper.getProjectView(), projectVersionWrapper.getProjectVersionView());
    Assertions.assertNotNull(pdfFile);
    Assertions.assertTrue(pdfFile.exists());
}
Also used : ReportService(com.synopsys.integration.detect.workflow.blackduck.report.service.ReportService) BlackDuckTestConnection(com.synopsys.integration.detect.battery.docker.integration.BlackDuckTestConnection) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) File(java.io.File) Test(org.junit.jupiter.api.Test) ExtendWith(org.junit.jupiter.api.extension.ExtendWith)

Example 2 with ReportService

use of com.synopsys.integration.detect.workflow.blackduck.report.service.ReportService in project synopsys-detect by blackducksoftware.

the class RiskReportServiceTestIT method createNoticesReportFileTest.

@Test
@ExtendWith(TempDirectory.class)
public void createNoticesReportFileTest(@TempDirectory.TempDir Path folderForReport) throws IntegrationException, InterruptedException {
    BlackDuckTestConnection blackDuckTestConnection = BlackDuckTestConnection.fromEnvironment();
    ReportService reportService = blackDuckTestConnection.createReportService();
    ProjectVersionWrapper projectVersionWrapper = blackDuckTestConnection.projectVersionAssertions(PROJECT_NAME, PROJECT_VERSION_NAME).retrieveProjectVersionWrapper();
    File noticeReportFile = reportService.createNoticesReportFile(folderForReport.toFile(), projectVersionWrapper.getProjectView(), projectVersionWrapper.getProjectVersionView());
    Assertions.assertNotNull(noticeReportFile);
    Assertions.assertTrue(noticeReportFile.exists());
}
Also used : ReportService(com.synopsys.integration.detect.workflow.blackduck.report.service.ReportService) BlackDuckTestConnection(com.synopsys.integration.detect.battery.docker.integration.BlackDuckTestConnection) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) File(java.io.File) Test(org.junit.jupiter.api.Test) ExtendWith(org.junit.jupiter.api.extension.ExtendWith)

Example 3 with ReportService

use of com.synopsys.integration.detect.workflow.blackduck.report.service.ReportService in project synopsys-detect by blackducksoftware.

the class OperationFactory method creatReportService.

private ReportService creatReportService(BlackDuckRunData blackDuckRunData) throws OperationException {
    return auditLog.namedInternal("Create Report Service", () -> {
        BlackDuckServicesFactory blackDuckServicesFactory = blackDuckRunData.getBlackDuckServicesFactory();
        Gson gson = blackDuckServicesFactory.getGson();
        HttpUrl blackDuckUrl = blackDuckRunData.getBlackDuckServerConfig().getBlackDuckUrl();
        BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
        ApiDiscovery apiDiscovery = blackDuckServicesFactory.getApiDiscovery();
        IntLogger reportServiceLogger = blackDuckServicesFactory.getLogger();
        IntegrationEscapeUtil integrationEscapeUtil = blackDuckServicesFactory.createIntegrationEscapeUtil();
        long reportServiceTimeout = detectConfigurationFactory.findTimeoutInSeconds() * 1000;
        return new ReportService(gson, blackDuckUrl, blackDuckApiClient, apiDiscovery, reportServiceLogger, integrationEscapeUtil, reportServiceTimeout);
    });
}
Also used : IntegrationEscapeUtil(com.synopsys.integration.util.IntegrationEscapeUtil) ReportService(com.synopsys.integration.detect.workflow.blackduck.report.service.ReportService) ApiDiscovery(com.synopsys.integration.blackduck.api.generated.discovery.ApiDiscovery) Gson(com.google.gson.Gson) BlackDuckApiClient(com.synopsys.integration.blackduck.service.BlackDuckApiClient) BlackDuckServicesFactory(com.synopsys.integration.blackduck.service.BlackDuckServicesFactory) IntLogger(com.synopsys.integration.log.IntLogger) Slf4jIntLogger(com.synopsys.integration.log.Slf4jIntLogger) HttpUrl(com.synopsys.integration.rest.HttpUrl)

Example 4 with ReportService

use of com.synopsys.integration.detect.workflow.blackduck.report.service.ReportService in project synopsys-detect by blackducksoftware.

the class BlackDuckTestConnection method createReportService.

public ReportService createReportService() {
    HttpUrl blackDuckUrl = blackDuckServicesFactory.getBlackDuckHttpClient().getBlackDuckUrl();
    IntegrationEscapeUtil integrationEscapeUtil = blackDuckServicesFactory.createIntegrationEscapeUtil();
    long reportServiceTimeout = 120 * 1000;
    return new ReportService(blackDuckServicesFactory.getGson(), blackDuckUrl, blackDuckServicesFactory.getBlackDuckApiClient(), blackDuckServicesFactory.getApiDiscovery(), new BufferedIntLogger(), integrationEscapeUtil, reportServiceTimeout);
}
Also used : IntegrationEscapeUtil(com.synopsys.integration.util.IntegrationEscapeUtil) ReportService(com.synopsys.integration.detect.workflow.blackduck.report.service.ReportService) BufferedIntLogger(com.synopsys.integration.log.BufferedIntLogger) HttpUrl(com.synopsys.integration.rest.HttpUrl)

Example 5 with ReportService

use of com.synopsys.integration.detect.workflow.blackduck.report.service.ReportService in project synopsys-detect by blackducksoftware.

the class DetectOnDetectTest method riskReportPopulatedAtCustomPath.

@Test
public // Tests that a new project has an empty report, run detect to fill it, tests the report is filled, in a custom location
void riskReportPopulatedAtCustomPath() throws Exception {
    try (DetectDockerTestRunner test = new DetectDockerTestRunner("detect-on-detect-riskreport-custom", "detect-7.1.0:1.0.0")) {
        test.withImageProvider(BuildDockerImageProvider.forDockerfilResourceNamed("Detect-7.1.0.dockerfile"));
        BlackDuckTestConnection blackDuckTestConnection = BlackDuckTestConnection.fromEnvironment();
        ReportService reportService = blackDuckTestConnection.createReportService();
        BlackDuckAssertions blackDuckAssertions = blackDuckTestConnection.projectVersionAssertions("synopsys-detect-junit", "risk-report-custom");
        ProjectVersionWrapper projectVersionWrapper = blackDuckAssertions.emptyOnBlackDuck();
        String reportDirectoryImagePath = "/opt/report";
        File reportDirectory = test.directories().createResultDirectory("report");
        test.directories().withBinding(reportDirectory, reportDirectoryImagePath);
        long initialFileLength = assertEmptyRiskReport(reportDirectory, projectVersionWrapper, reportService);
        DetectCommandBuilder commandBuilder = new DetectCommandBuilder().defaults().defaultDirectories(test);
        commandBuilder.connectToBlackDuck(blackDuckTestConnection);
        commandBuilder.projectNameVersion(blackDuckAssertions.getProjectNameVersion());
        commandBuilder.property(DetectProperties.DETECT_RISK_REPORT_PDF, "true");
        commandBuilder.property(DetectProperties.DETECT_TIMEOUT, "1200");
        commandBuilder.property(DetectProperties.DETECT_RISK_REPORT_PDF_PATH, reportDirectoryImagePath);
        commandBuilder.tools(DetectTool.DETECTOR);
        DockerAssertions dockerAssertions = test.run(commandBuilder);
        dockerAssertions.resultProducedAtLocation("/opt/report/synopsys_detect_junit_risk_report_custom_BlackDuck_RiskReport.pdf");
        List<File> pdfFiles = getPdfFiles(reportDirectory);
        assertEquals(1, pdfFiles.size());
        long postLength = pdfFiles.get(0).length();
        assertTrue(postLength > initialFileLength);
    }
}
Also used : ReportService(com.synopsys.integration.detect.workflow.blackduck.report.service.ReportService) DockerAssertions(com.synopsys.integration.detect.battery.docker.util.DockerAssertions) DetectCommandBuilder(com.synopsys.integration.detect.battery.docker.util.DetectCommandBuilder) DetectDockerTestRunner(com.synopsys.integration.detect.battery.docker.util.DetectDockerTestRunner) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

ReportService (com.synopsys.integration.detect.workflow.blackduck.report.service.ReportService)7 ProjectVersionWrapper (com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper)4 File (java.io.File)4 Test (org.junit.jupiter.api.Test)4 BlackDuckTestConnection (com.synopsys.integration.detect.battery.docker.integration.BlackDuckTestConnection)3 HttpUrl (com.synopsys.integration.rest.HttpUrl)2 IntegrationEscapeUtil (com.synopsys.integration.util.IntegrationEscapeUtil)2 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)2 Gson (com.google.gson.Gson)1 ApiDiscovery (com.synopsys.integration.blackduck.api.generated.discovery.ApiDiscovery)1 BlackDuckApiClient (com.synopsys.integration.blackduck.service.BlackDuckApiClient)1 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)1 DetectCommandBuilder (com.synopsys.integration.detect.battery.docker.util.DetectCommandBuilder)1 DetectDockerTestRunner (com.synopsys.integration.detect.battery.docker.util.DetectDockerTestRunner)1 DockerAssertions (com.synopsys.integration.detect.battery.docker.util.DockerAssertions)1 DetectFontLoader (com.synopsys.integration.detect.workflow.blackduck.DetectFontLoader)1 BufferedIntLogger (com.synopsys.integration.log.BufferedIntLogger)1 IntLogger (com.synopsys.integration.log.IntLogger)1 Slf4jIntLogger (com.synopsys.integration.log.Slf4jIntLogger)1 Disabled (org.junit.jupiter.api.Disabled)1