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<>());
}
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());
}
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());
}
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());
}
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());
}
Aggregations