Search in sources :

Example 1 with GoModCliDetectable

use of com.synopsys.integration.detectable.detectables.go.gomod.GoModCliDetectable 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 2 with GoModCliDetectable

use of com.synopsys.integration.detectable.detectables.go.gomod.GoModCliDetectable in project synopsys-detect by blackducksoftware.

the class DetectorToolTest method createDetectable.

private GoModCliDetectable createDetectable(Extraction extraction, DetectableResult extractionResult) throws DetectableException, ExecutableFailedException {
    File relevantFile = new File("go.mod");
    List<File> relevantFiles = Collections.singletonList(relevantFile);
    GoModCliDetectable detectable = Mockito.mock(GoModCliDetectable.class);
    Mockito.when(detectable.extractable()).thenReturn(extractionResult);
    Mockito.when(detectable.applicable()).thenReturn(new PassedDetectableResult(Collections.emptyList(), relevantFiles));
    Mockito.when(detectable.extract(Mockito.any())).thenReturn(extraction);
    return detectable;
}
Also used : GoModCliDetectable(com.synopsys.integration.detectable.detectables.go.gomod.GoModCliDetectable) File(java.io.File) PassedDetectableResult(com.synopsys.integration.detectable.detectable.result.PassedDetectableResult)

Aggregations

GoModCliDetectable (com.synopsys.integration.detectable.detectables.go.gomod.GoModCliDetectable)2 File (java.io.File)2 SimpleFileFinder (com.synopsys.integration.common.util.finder.SimpleFileFinder)1 ExitCodePublisher (com.synopsys.integration.detect.lifecycle.shutdown.ExitCodePublisher)1 ExtractionEnvironmentProvider (com.synopsys.integration.detect.tool.detector.extraction.ExtractionEnvironmentProvider)1 EventSystem (com.synopsys.integration.detect.workflow.event.EventSystem)1 StatusEventPublisher (com.synopsys.integration.detect.workflow.status.StatusEventPublisher)1 PassedDetectableResult (com.synopsys.integration.detectable.detectable.result.PassedDetectableResult)1 DetectorEvaluationTree (com.synopsys.integration.detector.base.DetectorEvaluationTree)1 DetectorEvaluationOptions (com.synopsys.integration.detector.evaluation.DetectorEvaluationOptions)1 DetectorFinder (com.synopsys.integration.detector.finder.DetectorFinder)1 DetectorFinderOptions (com.synopsys.integration.detector.finder.DetectorFinderOptions)1 DetectorRuleSet (com.synopsys.integration.detector.rule.DetectorRuleSet)1