Search in sources :

Example 11 with DetectableEnvironment

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

the class DetectorToolTest method createEvaluationTree.

private DetectorEvaluationTree createEvaluationTree(Extraction extraction, DetectableResult extractionResult, File directory, DetectorRule<GoModCliDetectable> rule, DetectorRuleSet detectorRuleSet) {
    DetectorEvaluation detectorEvaluation = new DetectorEvaluation(rule);
    DetectorResult extractableResult = new DetectorResult(extractionResult.getPassed(), extractionResult.toDescription(), extractionResult.getClass(), Collections.emptyList(), Collections.emptyList());
    detectorEvaluation.setExtractable(extractableResult);
    detectorEvaluation.setExtraction(extraction);
    detectorEvaluation.setApplicable(new DetectorResult(true, "", Collections.emptyList(), Collections.emptyList()));
    detectorEvaluation.setSearchable(new DetectorResult(true, "", Collections.emptyList(), Collections.emptyList()));
    detectorEvaluation.setDetectableEnvironment(new DetectableEnvironment(new File("")));
    return new DetectorEvaluationTree(directory, 0, detectorRuleSet, Collections.singletonList(detectorEvaluation), new HashSet<>());
}
Also used : DetectorEvaluationTree(com.synopsys.integration.detector.base.DetectorEvaluationTree) DetectorResult(com.synopsys.integration.detector.result.DetectorResult) DetectorEvaluation(com.synopsys.integration.detector.base.DetectorEvaluation) File(java.io.File) DetectableEnvironment(com.synopsys.integration.detectable.DetectableEnvironment)

Example 12 with DetectableEnvironment

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

the class PoetryFalsePositiveTest method testApplicableNoFalsePositive.

@Test
public void testApplicableNoFalsePositive() throws URISyntaxException {
    FileFinder fileFinder = Mockito.mock(SimpleFileFinder.class);
    File currentDirectory = new File(System.getProperty("user.dir"));
    File pyprojectToml = new File(getClass().getClassLoader().getResource("detectables/unit/pip/poetry/false_positive_pyproject.toml").toURI());
    Mockito.when(fileFinder.findFile(currentDirectory, "pyproject.toml")).thenReturn(pyprojectToml);
    PoetryDetectable poetryDetectable = new PoetryDetectable(new DetectableEnvironment(currentDirectory), fileFinder, new PoetryExtractor(new PoetryLockParser()), new ToolPoetrySectionParser());
    Assertions.assertFalse(poetryDetectable.applicable().getPassed());
}
Also used : PoetryExtractor(com.synopsys.integration.detectable.detectables.poetry.PoetryExtractor) PoetryDetectable(com.synopsys.integration.detectable.detectables.poetry.PoetryDetectable) PoetryLockParser(com.synopsys.integration.detectable.detectables.poetry.parser.PoetryLockParser) FileFinder(com.synopsys.integration.common.util.finder.FileFinder) SimpleFileFinder(com.synopsys.integration.common.util.finder.SimpleFileFinder) ToolPoetrySectionParser(com.synopsys.integration.detectable.detectables.poetry.parser.ToolPoetrySectionParser) File(java.io.File) DetectableEnvironment(com.synopsys.integration.detectable.DetectableEnvironment) Test(org.junit.jupiter.api.Test)

Example 13 with DetectableEnvironment

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

the class NugetProjectDetectableTest method testApplicableForRproj.

@Test
public void testApplicableForRproj() {
    NugetInspectorOptions nugetInspectorOptions = null;
    NugetInspectorResolver nugetInspectorResolver = null;
    NugetInspectorExtractor nugetInspectorExtractor = null;
    DetectableEnvironment environment = MockDetectableEnvironment.empty();
    FileFinder fileFinder = MockFileFinder.withFileNamed("example.rproj");
    NugetProjectDetectable detectable = new NugetProjectDetectable(environment, fileFinder, nugetInspectorOptions, nugetInspectorResolver, nugetInspectorExtractor);
    assertTrue(detectable.applicable().getPassed());
}
Also used : NugetInspectorExtractor(com.synopsys.integration.detectable.detectables.nuget.NugetInspectorExtractor) NugetProjectDetectable(com.synopsys.integration.detectable.detectables.nuget.NugetProjectDetectable) 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 14 with DetectableEnvironment

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

the class NugetSolutionDetectableTest method notApplicableForPodfile.

@Test
public void notApplicableForPodfile() {
    NugetInspectorResolver nugetInspectorManager = null;
    NugetInspectorExtractor nugetInspectorExtractor = null;
    NugetInspectorOptions nugetInspectorOptions = null;
    DetectableEnvironment environment = MockDetectableEnvironment.empty();
    FileFinder fileFinder = MockFileFinder.withFileNamed("podfile.lock");
    NugetSolutionDetectable detectable = new NugetSolutionDetectable(environment, fileFinder, nugetInspectorManager, nugetInspectorExtractor, nugetInspectorOptions);
    assertFalse(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 15 with DetectableEnvironment

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

the class DetectableFunctionalTest method run.

@Test
public void run() throws IOException, DetectableException, ExecutableFailedException, MissingExternalIdException, CycleDetectedException, ExecutableRunnerException, ParserConfigurationException, SAXException {
    System.out.println(String.format("Function Test (%s) is using temp directory: %s", name, tempDirectory.toAbsolutePath().toString()));
    setup();
    DetectableEnvironment detectableEnvironment = new DetectableEnvironment(sourceDirectory.toFile());
    Detectable detectable = create(detectableEnvironment);
    DetectableResult applicable = detectable.applicable();
    Assertions.assertTrue(applicable.getPassed(), String.format("Applicable should have passed but was: %s", applicable.toDescription()));
    DetectableResult extractable = detectable.extractable();
    Assertions.assertTrue(extractable.getPassed(), String.format("Extractable should have passed but was: %s", extractable.toDescription()));
    ExtractionEnvironment extractionEnvironment = new ExtractionEnvironment(outputDirectory.toFile());
    Extraction extraction = detectable.extract(extractionEnvironment);
    Assertions.assertNotNull(extraction, "Detectable did not return an extraction!");
    assertExtraction(extraction);
    FileUtils.deleteDirectory(tempDirectory.toFile());
}
Also used : Detectable(com.synopsys.integration.detectable.Detectable) ExtractionEnvironment(com.synopsys.integration.detectable.extraction.ExtractionEnvironment) DetectableResult(com.synopsys.integration.detectable.detectable.result.DetectableResult) Extraction(com.synopsys.integration.detectable.extraction.Extraction) DetectableEnvironment(com.synopsys.integration.detectable.DetectableEnvironment) 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