use of com.synopsys.integration.detect.lifecycle.shutdown.ExitCodePublisher in project synopsys-detect by blackducksoftware.
the class SingletonFactory method createEventSingletons.
public EventSingletons createEventSingletons() {
StatusEventPublisher statusEventPublisher = new StatusEventPublisher(eventSystem);
ExitCodePublisher exitCodePublisher = new ExitCodePublisher(eventSystem);
DetectorEventPublisher detectorEventPublisher = new DetectorEventPublisher(eventSystem);
CodeLocationEventPublisher codeLocationEventPublisher = new CodeLocationEventPublisher(eventSystem);
ProjectEventPublisher projectEventPublisher = new ProjectEventPublisher(eventSystem);
return new EventSingletons(statusEventPublisher, exitCodePublisher, detectorEventPublisher, codeLocationEventPublisher, projectEventPublisher);
}
use of com.synopsys.integration.detect.lifecycle.shutdown.ExitCodePublisher in project synopsys-detect by blackducksoftware.
the class DetectorToolTest method executeToolTest.
private DetectorToolResult executeToolTest(Extraction extraction, DetectableResult extractionResult, String projectBomTool) throws DetectableException, ExecutableFailedException {
ExtractionEnvironmentProvider extractionEnvironmentProvider = Mockito.mock(ExtractionEnvironmentProvider.class);
DetectorFinder detectorFinder = Mockito.mock(DetectorFinder.class);
EventSystem eventSystem = Mockito.mock(EventSystem.class);
CodeLocationConverter codeLocationConverter = Mockito.mock(CodeLocationConverter.class);
DetectorIssuePublisher detectorIssuePublisher = Mockito.mock(DetectorIssuePublisher.class);
StatusEventPublisher statusEventPublisher = Mockito.mock(StatusEventPublisher.class);
ExitCodePublisher exitCodePublisher = Mockito.mock(ExitCodePublisher.class);
DetectorEventPublisher detectorEventPublisher = Mockito.mock(DetectorEventPublisher.class);
DetectorTool tool = new DetectorTool(detectorFinder, extractionEnvironmentProvider, eventSystem, codeLocationConverter, detectorIssuePublisher, statusEventPublisher, exitCodePublisher, detectorEventPublisher);
File directory = new File(".");
GoModCliDetectable detectable = createDetectable(extraction, extractionResult);
DetectorRule<GoModCliDetectable> rule = createRule(detectable);
DetectorRuleSet detectorRuleSet = createRuleSet(rule);
DetectorFinderOptions detectorFinderOptions = createFinderOptions();
DetectorEvaluationOptions evaluationOptions = createEvaluationOptions();
DetectorEvaluationTree evaluationTree = createEvaluationTree(extraction, extractionResult, directory, rule, detectorRuleSet);
Mockito.when(detectorFinder.findDetectors(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(Optional.of(evaluationTree));
return tool.performDetectors(directory, detectorRuleSet, detectorFinderOptions, evaluationOptions, projectBomTool, new ArrayList<>(), new SimpleFileFinder());
}
use of com.synopsys.integration.detect.lifecycle.shutdown.ExitCodePublisher 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.lifecycle.shutdown.ExitCodePublisher in project synopsys-detect by blackducksoftware.
the class DetectorToolTest method testFailWhenMisConfigured.
@Test
public void testFailWhenMisConfigured() throws DetectUserFriendlyException {
ExtractionEnvironmentProvider extractionEnvironmentProvider = Mockito.mock(ExtractionEnvironmentProvider.class);
DetectorFinder detectorFinder = Mockito.mock(DetectorFinder.class);
EventSystem eventSystem = Mockito.mock(EventSystem.class);
CodeLocationConverter codeLocationConverter = Mockito.mock(CodeLocationConverter.class);
DetectorIssuePublisher detectorIssuePublisher = Mockito.mock(DetectorIssuePublisher.class);
StatusEventPublisher statusEventPublisher = Mockito.mock(StatusEventPublisher.class);
ExitCodePublisher exitCodePublisher = Mockito.mock(ExitCodePublisher.class);
DetectorEventPublisher detectorEventPublisher = Mockito.mock(DetectorEventPublisher.class);
DetectorTool tool = new DetectorTool(detectorFinder, extractionEnvironmentProvider, eventSystem, codeLocationConverter, detectorIssuePublisher, statusEventPublisher, exitCodePublisher, detectorEventPublisher);
File directory = new File(".");
DetectorRuleSet detectorRuleSet = Mockito.mock(DetectorRuleSet.class);
DetectorFinderOptions detectorFinderOptions = Mockito.mock(DetectorFinderOptions.class);
DetectorEvaluationOptions evaluationOptions = Mockito.mock(DetectorEvaluationOptions.class);
String projectBomTool = "testBomTool";
tool.performDetectors(directory, detectorRuleSet, detectorFinderOptions, evaluationOptions, projectBomTool, new ArrayList<>(), new SimpleFileFinder());
Mockito.verify(exitCodePublisher).publishExitCode(Mockito.any(ExitCodeType.class), Mockito.anyString());
}
Aggregations