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());
}
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;
}
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.*"));
}
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());
}
Aggregations