use of com.synopsys.integration.detectable.extraction.Extraction in project synopsys-detect by blackducksoftware.
the class MavenParsePluginDependenciesTest method testIncludingPluginDependencies.
@Test
public void testIncludingPluginDependencies() throws Exception {
MavenParseExtractor pomXmlParser = new MavenParseExtractor(SAXParserFactory.newInstance().newSAXParser());
Extraction extraction = pomXmlParser.extract(getInput(), new MavenParseOptions(true, true));
DependencyGraph dependencyGraph = extraction.getCodeLocations().get(0).getDependencyGraph();
Set<String> externalIds = dependencyGraph.getRootDependencies().stream().map(dependency -> dependency.getExternalId().createExternalId()).collect(Collectors.toSet());
assertTrue(externalIds.containsAll(getPluginDependencies()));
}
use of com.synopsys.integration.detectable.extraction.Extraction 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());
}
use of com.synopsys.integration.detectable.extraction.Extraction in project synopsys-detect by blackducksoftware.
the class BitbakeExtractor method extract.
public Extraction extract(File sourceDirectory, ExecutableTarget bashExecutable, File buildEnvironmentFile) throws ExecutableFailedException, IOException {
toolVersionLogger.log(() -> bitbakeCommandRunner.runBitbakeVersion(sourceDirectory, bashExecutable, buildEnvironmentFile));
File buildDirectory = determineBuildDirectory(sourceDirectory, bashExecutable, buildEnvironmentFile);
BitbakeEnvironment bitbakeEnvironment = executeBitbakeForEnvironment(sourceDirectory, bashExecutable, buildEnvironmentFile);
ShowRecipesResults showRecipesResults = executeBitbakeForRecipeLayerCatalog(sourceDirectory, bashExecutable, buildEnvironmentFile);
List<CodeLocation> codeLocations = packageNames.stream().map(targetPackage -> generateCodeLocationForTargetPackage(targetPackage, sourceDirectory, bashExecutable, buildEnvironmentFile, buildDirectory, showRecipesResults, bitbakeEnvironment)).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
if (codeLocations.isEmpty()) {
return Extraction.failure("No Code Locations were generated during extraction");
} else {
return Extraction.success(codeLocations);
}
}
use of com.synopsys.integration.detectable.extraction.Extraction in project synopsys-detect by blackducksoftware.
the class PubDepsExtractorTest method testGracefulFailure.
private void testGracefulFailure(ExecutableOutput mockExecutableOutput) throws ExecutableRunnerException {
DetectableExecutableRunner executableRunner = Mockito.mock(DetectableExecutableRunner.class);
Mockito.when(executableRunner.execute(Mockito.any())).thenReturn(mockExecutableOutput);
PubDepsExtractor extractor = new PubDepsExtractor(executableRunner, new PubDepsParser(), null, new ToolVersionLogger(executableRunner));
Extraction extraction = extractor.extract(null, null, null, new DartPubDepsDetectableOptions(EnumListFilter.excludeNone()), null);
Assertions.assertFalse(extraction.isSuccess() && null == extraction.getError());
}
use of com.synopsys.integration.detectable.extraction.Extraction in project synopsys-detect by blackducksoftware.
the class DockerExtractorTest method testExtractImageReturningContainerFileSystem.
@Test
@DisabledOnOs(WINDOWS)
public void testExtractImageReturningContainerFileSystem() throws ExecutableRunnerException, IOException {
final String image = "ubuntu:latest";
String imageId = null;
String tar = null;
DetectableExecutableRunner executableRunner = getDetectableExecutableRunner();
Extraction extraction = extract(image, imageId, tar, fakeContainerFileSystemFile, null, fakeResultsFile, executableRunner);
assertEquals("ubuntu:latest", extraction.getMetaData(DockerExtractor.DOCKER_IMAGE_NAME_META_DATA).get());
assertTrue(extraction.getMetaData(DockerExtractor.CONTAINER_FILESYSTEM_META_DATA).get().getName().endsWith("_containerfilesystem.tar.gz"));
ArgumentCaptor<Executable> executableArgumentCaptor = ArgumentCaptor.forClass(Executable.class);
Mockito.verify(executableRunner).execute(executableArgumentCaptor.capture());
Executable executableToVerify = executableArgumentCaptor.getValue();
List<String> command = executableToVerify.getCommandWithArguments();
assertTrue(command.get(0).endsWith("/fake/test/java"));
assertEquals("-jar", command.get(1));
assertTrue(command.get(2).endsWith("/fake/test/dockerinspector.jar"));
assertTrue(command.get(3).startsWith("--spring.config.location="));
assertTrue(command.get(3).endsWith("/application.properties"));
assertEquals("--docker.image=ubuntu:latest", command.get(4));
}
Aggregations