Search in sources :

Example 1 with RapidScanAggregateResult

use of com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanAggregateResult in project synopsys-detect by blackducksoftware.

the class RapidScanResultAggregatorTest method testEmptyResults.

@Test
public void testEmptyResults() {
    List<DeveloperScanComponentResultView> results = Collections.emptyList();
    RapidScanResultAggregator aggregator = new RapidScanResultAggregator();
    RapidScanAggregateResult aggregateResult = aggregator.aggregateData(results);
    BufferedIntLogger logger = new BufferedIntLogger();
    aggregateResult.logResult(logger);
    RapidScanResultSummary summary = aggregateResult.getSummary();
    assertEquals(0, summary.getPolicyErrorCount());
    assertEquals(0, summary.getPolicyWarningCount());
    assertEquals(0, summary.getSecurityErrorCount());
    assertEquals(0, summary.getSecurityWarningCount());
    assertEquals(0, summary.getLicenseErrorCount());
    assertEquals(0, summary.getLicenseWarningCount());
    assertFalse(logger.getOutputList(LogLevel.INFO).isEmpty());
}
Also used : DeveloperScanComponentResultView(com.synopsys.integration.blackduck.api.manual.view.DeveloperScanComponentResultView) RapidScanResultAggregator(com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanResultAggregator) RapidScanResultSummary(com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanResultSummary) BufferedIntLogger(com.synopsys.integration.log.BufferedIntLogger) RapidScanAggregateResult(com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanAggregateResult) Test(org.junit.jupiter.api.Test)

Example 2 with RapidScanAggregateResult

use of com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanAggregateResult in project synopsys-detect by blackducksoftware.

the class RapidModeLogReportOperation method perform.

public RapidScanResultSummary perform(List<DeveloperScanComponentResultView> results) throws DetectUserFriendlyException {
    RapidScanAggregateResult aggregateResult = rapidScanResultAggregator.aggregateData(results);
    logger.info(String.format("%s:", RapidScanDetectResult.RAPID_SCAN_RESULT_DETAILS_HEADING));
    aggregateResult.logResult(new Slf4jIntLogger(logger));
    RapidScanResultSummary summary = aggregateResult.getSummary();
    if (summary.hasErrors()) {
        exitCodePublisher.publishExitCode(ExitCodeType.FAILURE_POLICY_VIOLATION, createViolationMessage(summary.getPolicyViolationNames()));
    }
    return summary;
}
Also used : Slf4jIntLogger(com.synopsys.integration.log.Slf4jIntLogger) RapidScanResultSummary(com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanResultSummary) RapidScanAggregateResult(com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanAggregateResult)

Example 3 with RapidScanAggregateResult

use of com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanAggregateResult in project synopsys-detect by blackducksoftware.

the class RapidModeLogReportOperationTest method testPublishesPolicyViolation.

@Test
void testPublishesPolicyViolation() throws DetectUserFriendlyException {
    ExitCodePublisher exitCodePublisher = Mockito.mock(ExitCodePublisher.class);
    RapidScanResultAggregator rapidScanResultAggregator = Mockito.mock(RapidScanResultAggregator.class);
    RapidModeLogReportOperation op = new RapidModeLogReportOperation(exitCodePublisher, rapidScanResultAggregator);
    List<DeveloperScanComponentResultView> results = new LinkedList<>();
    DeveloperScanComponentResultView resultView = Mockito.mock(DeveloperScanComponentResultView.class);
    results.add(resultView);
    RapidScanAggregateResult aggregateResult = Mockito.mock(RapidScanAggregateResult.class);
    Mockito.when(rapidScanResultAggregator.aggregateData(results)).thenReturn(aggregateResult);
    RapidScanResultSummary summary = Mockito.mock(RapidScanResultSummary.class);
    Mockito.when(summary.hasErrors()).thenReturn(true);
    Mockito.when(aggregateResult.getSummary()).thenReturn(summary);
    Set<String> policyViolationNames = new HashSet<>();
    policyViolationNames.add("testPolicy1");
    policyViolationNames.add("testPolicy2");
    Mockito.when(summary.getPolicyViolationNames()).thenReturn(policyViolationNames);
    RapidScanResultSummary returnedSummary = op.perform(results);
    assertEquals(summary, returnedSummary);
    Mockito.verify(exitCodePublisher, Mockito.times(1)).publishExitCode(Mockito.eq(ExitCodeType.FAILURE_POLICY_VIOLATION), org.mockito.AdditionalMatchers.find(".* 2.*violation.*"));
}
Also used : RapidScanResultAggregator(com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanResultAggregator) DeveloperScanComponentResultView(com.synopsys.integration.blackduck.api.manual.view.DeveloperScanComponentResultView) RapidScanResultSummary(com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanResultSummary) RapidScanAggregateResult(com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanAggregateResult) ExitCodePublisher(com.synopsys.integration.detect.lifecycle.shutdown.ExitCodePublisher) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 4 with RapidScanAggregateResult

use of com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanAggregateResult in project synopsys-detect by blackducksoftware.

the class RapidScanResultAggregatorTest method testResults.

@Test
public void testResults() {
    List<DeveloperScanComponentResultView> results = createResultList();
    RapidScanResultAggregator aggregator = new RapidScanResultAggregator();
    RapidScanAggregateResult aggregateResult = aggregator.aggregateData(results);
    BufferedIntLogger logger = new BufferedIntLogger();
    aggregateResult.logResult(logger);
    RapidScanResultSummary summary = aggregateResult.getSummary();
    assertEquals(1, summary.getPolicyErrorCount());
    assertEquals(1, summary.getPolicyWarningCount());
    assertEquals(1, summary.getSecurityErrorCount());
    assertEquals(1, summary.getSecurityWarningCount());
    assertEquals(1, summary.getLicenseErrorCount());
    assertEquals(1, summary.getLicenseWarningCount());
    assertFalse(logger.getOutputList(LogLevel.INFO).isEmpty());
}
Also used : DeveloperScanComponentResultView(com.synopsys.integration.blackduck.api.manual.view.DeveloperScanComponentResultView) RapidScanResultAggregator(com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanResultAggregator) RapidScanResultSummary(com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanResultSummary) BufferedIntLogger(com.synopsys.integration.log.BufferedIntLogger) RapidScanAggregateResult(com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanAggregateResult) Test(org.junit.jupiter.api.Test)

Aggregations

RapidScanAggregateResult (com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanAggregateResult)4 RapidScanResultSummary (com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanResultSummary)4 DeveloperScanComponentResultView (com.synopsys.integration.blackduck.api.manual.view.DeveloperScanComponentResultView)3 RapidScanResultAggregator (com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanResultAggregator)3 Test (org.junit.jupiter.api.Test)3 BufferedIntLogger (com.synopsys.integration.log.BufferedIntLogger)2 ExitCodePublisher (com.synopsys.integration.detect.lifecycle.shutdown.ExitCodePublisher)1 Slf4jIntLogger (com.synopsys.integration.log.Slf4jIntLogger)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1