Search in sources :

Example 1 with DetectResult

use of com.synopsys.integration.detect.workflow.result.DetectResult in project synopsys-detect by blackducksoftware.

the class DetectStatusLogger method logDetectResults.

private void logDetectResults(IntLogger logger, List<DetectResult> detectResults) {
    if (!detectResults.isEmpty()) {
        logger.info("======== Detect Result ========");
        logger.info("");
        for (DetectResult detectResult : detectResults) {
            logger.info(detectResult.getResultMessage());
            if (!detectResult.getResultSubMessages().isEmpty()) {
                detectResult.getResultSubMessages().forEach(subMessage -> logger.info(String.format("\t%s", subMessage)));
            }
        }
        logger.info("");
    }
}
Also used : DetectResult(com.synopsys.integration.detect.workflow.result.DetectResult)

Example 2 with DetectResult

use of com.synopsys.integration.detect.workflow.result.DetectResult in project synopsys-detect by blackducksoftware.

the class DetectStatusLoggerTest method createResults.

private List<DetectResult> createResults() {
    ArrayList<DetectResult> detectResults = new ArrayList<>();
    DetectResult result = new BlackDuckBomDetectResult("https://example.com/api/projects/project_1");
    detectResults.add(result);
    result = new BlackDuckBomDetectResult("https://example.com/api/projects/project_2");
    detectResults.add(result);
    result = new AirGapDetectResult("./air_gap/directory");
    detectResults.add(result);
    result = new ReportDetectResult("report_1", "./report/1/report_file");
    detectResults.add(result);
    return detectResults;
}
Also used : AirGapDetectResult(com.synopsys.integration.detect.workflow.result.AirGapDetectResult) ReportDetectResult(com.synopsys.integration.detect.workflow.result.ReportDetectResult) ArrayList(java.util.ArrayList) BlackDuckBomDetectResult(com.synopsys.integration.detect.workflow.result.BlackDuckBomDetectResult) AirGapDetectResult(com.synopsys.integration.detect.workflow.result.AirGapDetectResult) DetectResult(com.synopsys.integration.detect.workflow.result.DetectResult) ReportDetectResult(com.synopsys.integration.detect.workflow.result.ReportDetectResult) BlackDuckBomDetectResult(com.synopsys.integration.detect.workflow.result.BlackDuckBomDetectResult)

Example 3 with DetectResult

use of com.synopsys.integration.detect.workflow.result.DetectResult in project synopsys-detect by blackducksoftware.

the class IntelligentModeStepRunner method publishPostResults.

private void publishPostResults(BdioResult bdioResult, ProjectVersionWrapper projectVersionWrapper, DetectToolFilter detectToolFilter) {
    if ((!bdioResult.getUploadTargets().isEmpty() || detectToolFilter.shouldInclude(DetectTool.SIGNATURE_SCAN))) {
        Optional<String> componentsLink = Optional.ofNullable(projectVersionWrapper).map(ProjectVersionWrapper::getProjectVersionView).flatMap(projectVersionView -> projectVersionView.getFirstLinkSafely(ProjectVersionView.COMPONENTS_LINK)).map(HttpUrl::string);
        if (componentsLink.isPresent()) {
            DetectResult detectResult = new BlackDuckBomDetectResult(componentsLink.get());
            operationFactory.publishResult(detectResult);
        }
    }
}
Also used : BlackDuckRunData(com.synopsys.integration.detect.lifecycle.run.data.BlackDuckRunData) OperationFactory(com.synopsys.integration.detect.lifecycle.run.operation.OperationFactory) ImpactAnalysisBatchOutput(com.synopsys.integration.detect.tool.impactanalysis.service.ImpactAnalysisBatchOutput) LoggerFactory(org.slf4j.LoggerFactory) DetectToolFilter(com.synopsys.integration.detect.util.filter.DetectToolFilter) BdioResult(com.synopsys.integration.detect.workflow.bdio.BdioResult) ReportConstants(com.synopsys.integration.detect.workflow.report.util.ReportConstants) DockerTargetData(com.synopsys.integration.detect.lifecycle.run.data.DockerTargetData) HttpUrl(com.synopsys.integration.rest.HttpUrl) HashSet(java.util.HashSet) StepHelper(com.synopsys.integration.detect.lifecycle.run.step.utility.StepHelper) NameVersion(com.synopsys.integration.util.NameVersion) SignatureScannerCodeLocationResult(com.synopsys.integration.detect.tool.signaturescanner.SignatureScannerCodeLocationResult) BlackDuckServicesFactory(com.synopsys.integration.blackduck.service.BlackDuckServicesFactory) BlackDuckBomDetectResult(com.synopsys.integration.detect.workflow.result.BlackDuckBomDetectResult) OperationType(com.synopsys.integration.detect.workflow.status.OperationType) Path(java.nio.file.Path) Logger(org.slf4j.Logger) DetectResult(com.synopsys.integration.detect.workflow.result.DetectResult) Set(java.util.Set) IOException(java.io.IOException) CodeLocationResults(com.synopsys.integration.detect.workflow.blackduck.codelocation.CodeLocationResults) ProjectVersionView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView) BdioUploadResult(com.synopsys.integration.detect.lifecycle.run.operation.blackduck.BdioUploadResult) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) CodeLocationAccumulator(com.synopsys.integration.detect.workflow.blackduck.codelocation.CodeLocationAccumulator) File(java.io.File) DetectTool(com.synopsys.integration.detect.configuration.enumeration.DetectTool) ReportDetectResult(com.synopsys.integration.detect.workflow.result.ReportDetectResult) CodeLocationWaitData(com.synopsys.integration.detect.workflow.blackduck.codelocation.CodeLocationWaitData) CodeLocationCreationData(com.synopsys.integration.blackduck.codelocation.CodeLocationCreationData) Optional(java.util.Optional) OperationException(com.synopsys.integration.detect.lifecycle.OperationException) BlackDuckBomDetectResult(com.synopsys.integration.detect.workflow.result.BlackDuckBomDetectResult) BlackDuckBomDetectResult(com.synopsys.integration.detect.workflow.result.BlackDuckBomDetectResult) DetectResult(com.synopsys.integration.detect.workflow.result.DetectResult) ReportDetectResult(com.synopsys.integration.detect.workflow.result.ReportDetectResult) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) HttpUrl(com.synopsys.integration.rest.HttpUrl)

Example 4 with DetectResult

use of com.synopsys.integration.detect.workflow.result.DetectResult in project synopsys-detect by blackducksoftware.

the class DetectStatusLoggerTest method testContent.

@Test
public void testContent() throws IOException {
    File expectedOutputFile = new File("src/test/resources/workflow/status/expectedStatusLoggerOutput.txt");
    String expectedOutput = FileUtils.readFileToString(expectedOutputFile, StandardCharsets.UTF_8);
    BufferedIntLogger loggerActual = new BufferedIntLogger();
    DetectStatusLogger statusLogger = new DetectStatusLogger();
    List<Status> statusSummaries = createStatus();
    List<DetectResult> detectResults = createResults();
    List<DetectIssue> detectIssues = createIssues();
    List<Operation> detectOperations = createOperations();
    statusLogger.logDetectStatus(loggerActual, statusSummaries, detectResults, detectIssues, detectOperations, ExitCodeType.SUCCESS);
    String actualOutput = loggerActual.getOutputString(LogLevel.INFO);
    assertEquals(expectedOutput.trim().replaceAll("\r?\n", "\n"), actualOutput.trim().replaceAll("\r?\n", "\n"));
}
Also used : AirGapDetectResult(com.synopsys.integration.detect.workflow.result.AirGapDetectResult) DetectResult(com.synopsys.integration.detect.workflow.result.DetectResult) ReportDetectResult(com.synopsys.integration.detect.workflow.result.ReportDetectResult) BlackDuckBomDetectResult(com.synopsys.integration.detect.workflow.result.BlackDuckBomDetectResult) BufferedIntLogger(com.synopsys.integration.log.BufferedIntLogger) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 5 with DetectResult

use of com.synopsys.integration.detect.workflow.result.DetectResult in project synopsys-detect by blackducksoftware.

the class DetectStatusLoggerTest method testDebugContent.

@Test
public void testDebugContent() throws IOException {
    File expectedOutputFile = new File("src/test/resources/workflow/status/expectedDebugStatusLoggerOutput.txt");
    String expectedOutput = FileUtils.readFileToString(expectedOutputFile, StandardCharsets.UTF_8);
    BufferedIntLogger loggerActual = new BufferedIntLogger();
    DetectStatusLogger statusLogger = new DetectStatusLogger();
    List<Status> statusSummaries = createStatus();
    List<DetectResult> detectResults = createResults();
    List<DetectIssue> detectIssues = createIssues();
    List<Operation> detectOperations = createOperations();
    statusLogger.logDetectStatus(loggerActual, statusSummaries, detectResults, detectIssues, detectOperations, ExitCodeType.SUCCESS);
    String actualOutput = loggerActual.getOutputString(LogLevel.DEBUG);
    assertEquals(expectedOutput.trim().replaceAll("\r?\n", "\n"), actualOutput.trim().replaceAll("\r?\n", "\n"));
}
Also used : AirGapDetectResult(com.synopsys.integration.detect.workflow.result.AirGapDetectResult) DetectResult(com.synopsys.integration.detect.workflow.result.DetectResult) ReportDetectResult(com.synopsys.integration.detect.workflow.result.ReportDetectResult) BlackDuckBomDetectResult(com.synopsys.integration.detect.workflow.result.BlackDuckBomDetectResult) BufferedIntLogger(com.synopsys.integration.log.BufferedIntLogger) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

DetectResult (com.synopsys.integration.detect.workflow.result.DetectResult)5 BlackDuckBomDetectResult (com.synopsys.integration.detect.workflow.result.BlackDuckBomDetectResult)4 ReportDetectResult (com.synopsys.integration.detect.workflow.result.ReportDetectResult)4 AirGapDetectResult (com.synopsys.integration.detect.workflow.result.AirGapDetectResult)3 File (java.io.File)3 BufferedIntLogger (com.synopsys.integration.log.BufferedIntLogger)2 Test (org.junit.jupiter.api.Test)2 ProjectVersionView (com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView)1 CodeLocationCreationData (com.synopsys.integration.blackduck.codelocation.CodeLocationCreationData)1 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)1 ProjectVersionWrapper (com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper)1 DetectTool (com.synopsys.integration.detect.configuration.enumeration.DetectTool)1 OperationException (com.synopsys.integration.detect.lifecycle.OperationException)1 BlackDuckRunData (com.synopsys.integration.detect.lifecycle.run.data.BlackDuckRunData)1 DockerTargetData (com.synopsys.integration.detect.lifecycle.run.data.DockerTargetData)1 OperationFactory (com.synopsys.integration.detect.lifecycle.run.operation.OperationFactory)1 BdioUploadResult (com.synopsys.integration.detect.lifecycle.run.operation.blackduck.BdioUploadResult)1 StepHelper (com.synopsys.integration.detect.lifecycle.run.step.utility.StepHelper)1 ImpactAnalysisBatchOutput (com.synopsys.integration.detect.tool.impactanalysis.service.ImpactAnalysisBatchOutput)1 SignatureScannerCodeLocationResult (com.synopsys.integration.detect.tool.signaturescanner.SignatureScannerCodeLocationResult)1