use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class PipenvTransformerTest method ignoresNonProject.
@Test
void ignoresNonProject() {
PipFreeze pipFreeze = new PipFreeze(new ArrayList<>());
List<PipenvGraphEntry> pipenvGraphEntries = new ArrayList<>();
pipenvGraphEntries.add(new PipenvGraphEntry("projectName", "projectVersion", Collections.singletonList(new PipenvGraphDependency("child", "childVersion", Collections.emptyList()))));
pipenvGraphEntries.add(new PipenvGraphEntry("non-projectName", "non-projectVersion", new ArrayList<>()));
PipenvGraph pipenvGraph = new PipenvGraph(pipenvGraphEntries);
PipenvTransformer pipenvTransformer = new PipenvTransformer(new ExternalIdFactory());
CodeLocation codeLocation = pipenvTransformer.transform("projectName", "projectVersion", pipFreeze, pipenvGraph, true);
DependencyGraph graph = codeLocation.getDependencyGraph();
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PYPI, graph);
graphAssert.hasRootDependency("child", "childVersion");
graphAssert.hasNoDependency("non-projectName", "non-projectVersion");
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class PnpmLockYamlParserTest method testParse.
@Test
public void testParse() throws IOException, IntegrationException {
File pnpmLockYaml = FunctionalTestFiles.asFile("/pnpm/pnpm-lock.yaml");
EnumListFilter<PnpmDependencyType> dependencyTypeFilter = EnumListFilter.excludeNone();
PnpmLockYamlParser pnpmLockYamlParser = new PnpmLockYamlParser(new PnpmYamlTransformer(dependencyTypeFilter));
PnpmLinkedPackageResolver pnpmLinkedPackageResolver = new PnpmLinkedPackageResolver(FunctionalTestFiles.asFile("/pnpm"), new PackageJsonFiles(new PackageJsonReader(new Gson())));
List<CodeLocation> codeLocations = pnpmLockYamlParser.parse(pnpmLockYaml, new NameVersion("project", "version"), pnpmLinkedPackageResolver);
Assertions.assertEquals(2, codeLocations.size());
// Did we correctly identify root project package in "importers"?
Assertions.assertTrue(codeLocations.stream().map(CodeLocation::getExternalId).filter(Optional::isPresent).map(Optional::get).anyMatch(externalId -> externalId.getName().equals("project") && externalId.getVersion().equals("version")));
// Do all code locations have a source path?
Assertions.assertAll(codeLocations.stream().map(codeLocation -> () -> Assertions.assertTrue(codeLocation.getSourcePath().isPresent(), String.format("Expected source path to be present for all code locations. But code location with id %s does not have one set.", codeLocation.getExternalId().map(ExternalId::createExternalId).orElse("N/A")))));
// Did we generate a unique source path for each code location?
Map<String, List<File>> collect = codeLocations.stream().map(CodeLocation::getSourcePath).filter(Optional::isPresent).map(Optional::get).collect(Collectors.groupingBy(File::getAbsolutePath));
Assertions.assertAll(collect.entrySet().stream().map(codeLocationGrouping -> () -> {
int numberOfCodeLocations = codeLocationGrouping.getValue().size();
Assertions.assertEquals(1, numberOfCodeLocations, String.format("Expected unique code locations paths. But found %d with that same path of %s", numberOfCodeLocations, codeLocationGrouping.getKey()));
}));
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class PackageJsonExtractorFunctionalTest method extractWithPeerDependencies.
@Test
void extractWithPeerDependencies() {
Extraction extraction = createExtractor(NpmDependencyType.DEV).extract(packageJsonInputStream);
assertEquals(1, extraction.getCodeLocations().size());
CodeLocation codeLocation = extraction.getCodeLocations().get(0);
DependencyGraph dependencyGraph = codeLocation.getDependencyGraph();
GraphAssert graphAssert = new GraphAssert(Forge.RUBYGEMS, dependencyGraph);
graphAssert.hasRootDependency(testDep1);
graphAssert.hasRootDependency(testDep2);
graphAssert.hasRootDependency(testPeerDep1);
graphAssert.hasRootDependency(testPeerDep2);
graphAssert.hasNoDependency(testDevDep1);
graphAssert.hasNoDependency(testDevDep2);
graphAssert.hasRootSize(4);
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation 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.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class CarthageExtractor method extract.
public Extraction extract(File cartfileResolved) throws IOException {
List<String> dependencyDeclarations = Files.readAllLines(cartfileResolved.toPath());
List<CarthageDeclaration> carthageDeclarations = cartfileResolvedParser.parseDependencies(dependencyDeclarations);
DependencyGraph dependencyGraph = declarationTransformer.transform(carthageDeclarations);
CodeLocation codeLocation = new CodeLocation(dependencyGraph);
// No project info - hoping git can help with that.
return Extraction.success(codeLocation);
}
Aggregations