Search in sources :

Example 1 with DetectableEnvironment

use of com.synopsys.integration.detectable.DetectableEnvironment in project synopsys-detect by blackducksoftware.

the class NugetSolutionDetectableTest method testApplicableForSolution.

@Test
public void testApplicableForSolution() {
    NugetInspectorResolver nugetInspectorManager = null;
    NugetInspectorExtractor nugetInspectorExtractor = null;
    NugetInspectorOptions nugetInspectorOptions = null;
    DetectableEnvironment environment = MockDetectableEnvironment.empty();
    FileFinder fileFinder = MockFileFinder.withFileNamed("test.sln");
    NugetSolutionDetectable detectable = new NugetSolutionDetectable(environment, fileFinder, nugetInspectorManager, nugetInspectorExtractor, nugetInspectorOptions);
    assertTrue(detectable.applicable().getPassed());
}
Also used : NugetInspectorExtractor(com.synopsys.integration.detectable.detectables.nuget.NugetInspectorExtractor) NugetSolutionDetectable(com.synopsys.integration.detectable.detectables.nuget.NugetSolutionDetectable) NugetInspectorResolver(com.synopsys.integration.detectable.detectable.inspector.nuget.NugetInspectorResolver) MockFileFinder(com.synopsys.integration.detectable.util.MockFileFinder) FileFinder(com.synopsys.integration.common.util.finder.FileFinder) NugetInspectorOptions(com.synopsys.integration.detectable.detectables.nuget.NugetInspectorOptions) DetectableEnvironment(com.synopsys.integration.detectable.DetectableEnvironment) MockDetectableEnvironment(com.synopsys.integration.detectable.util.MockDetectableEnvironment) Test(org.junit.jupiter.api.Test)

Example 2 with DetectableEnvironment

use of com.synopsys.integration.detectable.DetectableEnvironment in project synopsys-detect by blackducksoftware.

the class ComposerLockDetectableTest method testApplicable.

@Test
public void testApplicable() {
    ComposerLockExtractor composerLockExtractor = null;
    DetectableEnvironment environment = MockDetectableEnvironment.empty();
    FileFinder fileFinder = MockFileFinder.withFilesNamed("composer.lock", "composer.json");
    ComposerLockDetectable detectable = new ComposerLockDetectable(environment, fileFinder, composerLockExtractor);
    assertTrue(detectable.applicable().getPassed());
}
Also used : MockFileFinder(com.synopsys.integration.detectable.util.MockFileFinder) FileFinder(com.synopsys.integration.common.util.finder.FileFinder) ComposerLockExtractor(com.synopsys.integration.detectable.detectables.packagist.ComposerLockExtractor) DetectableEnvironment(com.synopsys.integration.detectable.DetectableEnvironment) MockDetectableEnvironment(com.synopsys.integration.detectable.util.MockDetectableEnvironment) ComposerLockDetectable(com.synopsys.integration.detectable.detectables.packagist.ComposerLockDetectable) Test(org.junit.jupiter.api.Test)

Example 3 with DetectableEnvironment

use of com.synopsys.integration.detectable.DetectableEnvironment in project synopsys-detect by blackducksoftware.

the class GemspecParseDetectableTest method testApplicable.

@Test
public void testApplicable() {
    GemspecParseExtractor gemspecParseExtractor = null;
    GemspecParseDetectableOptions gemspecParseDetectableOptions = null;
    DetectableEnvironment environment = MockDetectableEnvironment.empty();
    FileFinder fileFinder = MockFileFinder.withFileNamed("test.gemspec");
    GemspecParseDetectable detectable = new GemspecParseDetectable(environment, fileFinder, gemspecParseExtractor);
    assertTrue(detectable.applicable().getPassed());
}
Also used : GemspecParseDetectable(com.synopsys.integration.detectable.detectables.rubygems.gemspec.GemspecParseDetectable) MockFileFinder(com.synopsys.integration.detectable.util.MockFileFinder) FileFinder(com.synopsys.integration.common.util.finder.FileFinder) GemspecParseExtractor(com.synopsys.integration.detectable.detectables.rubygems.gemspec.GemspecParseExtractor) DetectableEnvironment(com.synopsys.integration.detectable.DetectableEnvironment) MockDetectableEnvironment(com.synopsys.integration.detectable.util.MockDetectableEnvironment) GemspecParseDetectableOptions(com.synopsys.integration.detectable.detectables.rubygems.gemspec.GemspecParseDetectableOptions) Test(org.junit.jupiter.api.Test)

Example 4 with DetectableEnvironment

use of com.synopsys.integration.detectable.DetectableEnvironment in project synopsys-detect by blackducksoftware.

the class DetectableTool method initializeAndCheckForApplicable.

public boolean initializeAndCheckForApplicable(File sourcePath) {
    // TODO: Move docker/bazel out of detectable and drop this notion of a detctable tool. Will simplify this logic and make this unneccessary.
    logger.trace("Starting a detectable tool.");
    this.sourcePath = sourcePath;
    DetectableEnvironment detectableEnvironment = new DetectableEnvironment(sourcePath);
    detectable = detectableCreatable.createDetectable(detectableEnvironment);
    DetectableResult applicable = detectable.applicable();
    if (!applicable.getPassed()) {
        logger.debug("Was not applicable.");
        return false;
    }
    logger.debug("Applicable passed.");
    return true;
}
Also used : DetectableResult(com.synopsys.integration.detectable.detectable.result.DetectableResult) ExceptionDetectableResult(com.synopsys.integration.detectable.detectable.result.ExceptionDetectableResult) DetectableEnvironment(com.synopsys.integration.detectable.DetectableEnvironment)

Example 5 with DetectableEnvironment

use of com.synopsys.integration.detectable.DetectableEnvironment in project synopsys-detect by blackducksoftware.

the class FormattedOutputManagerTest method detectorOutputStatusDataTest.

@Test
public <T extends Detectable> void detectorOutputStatusDataTest() throws IllegalAccessException {
    EventSystem eventSystem = new EventSystem();
    FormattedOutputManager formattedOutputManager = new FormattedOutputManager(eventSystem);
    DetectorRule rule = Mockito.mock(DetectorRule.class);
    Mockito.when(rule.getDescriptiveName()).thenReturn("");
    Mockito.when(rule.getName()).thenReturn("");
    Mockito.when(rule.getDetectorType()).thenReturn(DetectorType.GO_MOD);
    DetectorEvaluation detectorEvaluation = new DetectorEvaluation(rule);
    ExecutableNotFoundDetectableResult result = new ExecutableNotFoundDetectableResult("go");
    DetectorResult extractableResult = new DetectorResult(result.getPassed(), result.toDescription(), result.getClass(), Collections.emptyList(), Collections.emptyList());
    detectorEvaluation.setExtractable(extractableResult);
    detectorEvaluation.setApplicable(new DetectorResult(true, "", Collections.emptyList(), Collections.emptyList()));
    detectorEvaluation.setSearchable(new DetectorResult(true, "", Collections.emptyList(), Collections.emptyList()));
    detectorEvaluation.setDetectableEnvironment(new DetectableEnvironment(new File("")));
    DetectorToolResult detectorToolResult = new DetectorToolResult(null, null, null, new HashSet<>(), new DetectorEvaluationTree(null, 0, null, Collections.singletonList(detectorEvaluation), new HashSet<>()), null);
    eventSystem.publishEvent(Event.DetectorsComplete, detectorToolResult);
    DetectInfo detectInfo = new DetectInfo("", null, "");
    FormattedOutput formattedOutput = formattedOutputManager.createFormattedOutput(detectInfo);
    FormattedDetectorOutput detectorOutput = formattedOutput.detectors.get(0);
    Assertions.assertEquals("FAILURE", detectorOutput.status);
    Assertions.assertEquals(DetectorStatusCode.EXECUTABLE_NOT_FOUND, detectorOutput.statusCode);
    Assertions.assertEquals("No go executable was found.", detectorOutput.statusReason);
}
Also used : ExecutableNotFoundDetectableResult(com.synopsys.integration.detectable.detectable.result.ExecutableNotFoundDetectableResult) DetectInfo(com.synopsys.integration.detect.configuration.DetectInfo) DetectorEvaluation(com.synopsys.integration.detector.base.DetectorEvaluation) FormattedOutputManager(com.synopsys.integration.detect.workflow.report.output.FormattedOutputManager) DetectableEnvironment(com.synopsys.integration.detectable.DetectableEnvironment) FormattedOutput(com.synopsys.integration.detect.workflow.report.output.FormattedOutput) DetectorToolResult(com.synopsys.integration.detect.tool.detector.DetectorToolResult) DetectorEvaluationTree(com.synopsys.integration.detector.base.DetectorEvaluationTree) FormattedDetectorOutput(com.synopsys.integration.detect.workflow.report.output.FormattedDetectorOutput) DetectorRule(com.synopsys.integration.detector.rule.DetectorRule) EventSystem(com.synopsys.integration.detect.workflow.event.EventSystem) DetectorResult(com.synopsys.integration.detector.result.DetectorResult) File(java.io.File) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Aggregations

DetectableEnvironment (com.synopsys.integration.detectable.DetectableEnvironment)18 Test (org.junit.jupiter.api.Test)14 FileFinder (com.synopsys.integration.common.util.finder.FileFinder)11 MockDetectableEnvironment (com.synopsys.integration.detectable.util.MockDetectableEnvironment)9 MockFileFinder (com.synopsys.integration.detectable.util.MockFileFinder)8 File (java.io.File)6 DetectableResult (com.synopsys.integration.detectable.detectable.result.DetectableResult)5 NugetInspectorResolver (com.synopsys.integration.detectable.detectable.inspector.nuget.NugetInspectorResolver)3 NugetInspectorExtractor (com.synopsys.integration.detectable.detectables.nuget.NugetInspectorExtractor)3 NugetInspectorOptions (com.synopsys.integration.detectable.detectables.nuget.NugetInspectorOptions)3 DetectorEvaluation (com.synopsys.integration.detector.base.DetectorEvaluation)3 DetectorEvaluationTree (com.synopsys.integration.detector.base.DetectorEvaluationTree)3 DetectorResult (com.synopsys.integration.detector.result.DetectorResult)3 Detectable (com.synopsys.integration.detectable.Detectable)2 NugetSolutionDetectable (com.synopsys.integration.detectable.detectables.nuget.NugetSolutionDetectable)2 SimpleFileFinder (com.synopsys.integration.common.util.finder.SimpleFileFinder)1 DetectInfo (com.synopsys.integration.detect.configuration.DetectInfo)1 DetectUserFriendlyException (com.synopsys.integration.detect.configuration.DetectUserFriendlyException)1 DetectorToolResult (com.synopsys.integration.detect.tool.detector.DetectorToolResult)1 EventSystem (com.synopsys.integration.detect.workflow.event.EventSystem)1