Search in sources :

Example 1 with DetectorFinder

use of com.synopsys.integration.detector.finder.DetectorFinder in project synopsys-detect by blackducksoftware.

the class OperationFactory method executeDetectors.

public final DetectorToolResult executeDetectors() throws OperationException {
    return auditLog.namedPublic("Execute Detectors", "Detectors", () -> {
        DetectorToolOptions detectorToolOptions = detectConfigurationFactory.createDetectorToolOptions();
        DetectorRuleFactory detectorRuleFactory = new DetectorRuleFactory();
        DetectorRuleSet detectRuleSet = detectorRuleFactory.createRules(detectDetectableFactory, detectorToolOptions.isBuildless());
        DetectorTool detectorTool = new DetectorTool(new DetectorFinder(), extractionEnvironmentProvider, eventSystem, codeLocationConverter, new DetectorIssuePublisher(), statusEventPublisher, exitCodePublisher, detectorEventPublisher);
        return detectorTool.performDetectors(directoryManager.getSourceDirectory(), detectRuleSet, detectConfigurationFactory.createDetectorFinderOptions(), detectConfigurationFactory.createDetectorEvaluationOptions(), detectorToolOptions.getProjectBomTool(), detectorToolOptions.getRequiredDetectors(), fileFinder);
    });
}
Also used : DetectorToolOptions(com.synopsys.integration.detect.configuration.DetectorToolOptions) DetectorFinder(com.synopsys.integration.detector.finder.DetectorFinder) DetectorIssuePublisher(com.synopsys.integration.detect.tool.detector.DetectorIssuePublisher) DetectorRuleFactory(com.synopsys.integration.detect.tool.detector.DetectorRuleFactory) DetectorTool(com.synopsys.integration.detect.tool.detector.DetectorTool) DetectorRuleSet(com.synopsys.integration.detector.rule.DetectorRuleSet)

Example 2 with DetectorFinder

use of com.synopsys.integration.detector.finder.DetectorFinder 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());
}
Also used : DetectorEvaluationOptions(com.synopsys.integration.detector.evaluation.DetectorEvaluationOptions) GoModCliDetectable(com.synopsys.integration.detectable.detectables.go.gomod.GoModCliDetectable) DetectorFinderOptions(com.synopsys.integration.detector.finder.DetectorFinderOptions) ExtractionEnvironmentProvider(com.synopsys.integration.detect.tool.detector.extraction.ExtractionEnvironmentProvider) ExitCodePublisher(com.synopsys.integration.detect.lifecycle.shutdown.ExitCodePublisher) DetectorRuleSet(com.synopsys.integration.detector.rule.DetectorRuleSet) DetectorEvaluationTree(com.synopsys.integration.detector.base.DetectorEvaluationTree) SimpleFileFinder(com.synopsys.integration.common.util.finder.SimpleFileFinder) DetectorFinder(com.synopsys.integration.detector.finder.DetectorFinder) StatusEventPublisher(com.synopsys.integration.detect.workflow.status.StatusEventPublisher) EventSystem(com.synopsys.integration.detect.workflow.event.EventSystem) File(java.io.File)

Example 3 with DetectorFinder

use of com.synopsys.integration.detector.finder.DetectorFinder 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());
}
Also used : DetectorEvaluationOptions(com.synopsys.integration.detector.evaluation.DetectorEvaluationOptions) DetectorFinderOptions(com.synopsys.integration.detector.finder.DetectorFinderOptions) ExtractionEnvironmentProvider(com.synopsys.integration.detect.tool.detector.extraction.ExtractionEnvironmentProvider) ExitCodePublisher(com.synopsys.integration.detect.lifecycle.shutdown.ExitCodePublisher) DetectorRuleSet(com.synopsys.integration.detector.rule.DetectorRuleSet) ExitCodeType(com.synopsys.integration.detect.configuration.enumeration.ExitCodeType) SimpleFileFinder(com.synopsys.integration.common.util.finder.SimpleFileFinder) DetectorFinder(com.synopsys.integration.detector.finder.DetectorFinder) StatusEventPublisher(com.synopsys.integration.detect.workflow.status.StatusEventPublisher) EventSystem(com.synopsys.integration.detect.workflow.event.EventSystem) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

DetectorFinder (com.synopsys.integration.detector.finder.DetectorFinder)3 DetectorRuleSet (com.synopsys.integration.detector.rule.DetectorRuleSet)3 SimpleFileFinder (com.synopsys.integration.common.util.finder.SimpleFileFinder)2 ExitCodePublisher (com.synopsys.integration.detect.lifecycle.shutdown.ExitCodePublisher)2 ExtractionEnvironmentProvider (com.synopsys.integration.detect.tool.detector.extraction.ExtractionEnvironmentProvider)2 EventSystem (com.synopsys.integration.detect.workflow.event.EventSystem)2 StatusEventPublisher (com.synopsys.integration.detect.workflow.status.StatusEventPublisher)2 DetectorEvaluationOptions (com.synopsys.integration.detector.evaluation.DetectorEvaluationOptions)2 DetectorFinderOptions (com.synopsys.integration.detector.finder.DetectorFinderOptions)2 File (java.io.File)2 DetectorToolOptions (com.synopsys.integration.detect.configuration.DetectorToolOptions)1 ExitCodeType (com.synopsys.integration.detect.configuration.enumeration.ExitCodeType)1 DetectorIssuePublisher (com.synopsys.integration.detect.tool.detector.DetectorIssuePublisher)1 DetectorRuleFactory (com.synopsys.integration.detect.tool.detector.DetectorRuleFactory)1 DetectorTool (com.synopsys.integration.detect.tool.detector.DetectorTool)1 GoModCliDetectable (com.synopsys.integration.detectable.detectables.go.gomod.GoModCliDetectable)1 DetectorEvaluationTree (com.synopsys.integration.detector.base.DetectorEvaluationTree)1 Test (org.junit.jupiter.api.Test)1