use of com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraphEntry in project synopsys-detect by blackducksoftware.
the class PipenvTransformerTest method resolvesLowercaseNameWithFreezeCapital.
@Test
void resolvesLowercaseNameWithFreezeCapital() {
List<PipFreezeEntry> pipFreezeEntries = new ArrayList<>();
pipFreezeEntries.add(new PipFreezeEntry("Example", "2.0.0"));
PipFreeze pipFreeze = new PipFreeze(pipFreezeEntries);
List<PipenvGraphEntry> pipenvGraphEntries = new ArrayList<>();
pipenvGraphEntries.add(new PipenvGraphEntry("example", "fuzzy", new ArrayList<>()));
PipenvGraph pipenvGraph = new PipenvGraph(pipenvGraphEntries);
PipenvTransformer pipenvTransformer = new PipenvTransformer(new ExternalIdFactory());
CodeLocation codeLocation = pipenvTransformer.transform("", "", pipFreeze, pipenvGraph, false);
DependencyGraph graph = codeLocation.getDependencyGraph();
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PYPI, graph);
graphAssert.hasDependency("Example", "2.0.0");
}
use of com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraphEntry in project synopsys-detect by blackducksoftware.
the class PipenvTransformerTest method usesProjectDependencyAsRoot.
@Test
void usesProjectDependencyAsRoot() {
PipFreeze pipFreeze = new PipFreeze(new ArrayList<>());
List<PipenvGraphEntry> pipenvGraphEntries = new ArrayList<>();
List<PipenvGraphDependency> children = new ArrayList<>();
children.add(new PipenvGraphDependency("shouldBeAtRoot", "shouldbeAtRootVersion", new ArrayList<>()));
pipenvGraphEntries.add(new PipenvGraphEntry("projectName", "projectVersion", children));
PipenvGraph pipenvGraph = new PipenvGraph(pipenvGraphEntries);
PipenvTransformer pipenvTransformer = new PipenvTransformer(new ExternalIdFactory());
CodeLocation codeLocation = pipenvTransformer.transform("projectName", "projectVersion", pipFreeze, pipenvGraph, false);
DependencyGraph graph = codeLocation.getDependencyGraph();
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PYPI, graph);
graphAssert.hasRootDependency("shouldBeAtRoot", "shouldbeAtRootVersion");
}
use of com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraphEntry in project synopsys-detect by blackducksoftware.
the class PipenvTransformerTest method resolvesFuzzyVersion.
@Test
void resolvesFuzzyVersion() {
List<PipFreezeEntry> pipFreezeEntries = new ArrayList<>();
pipFreezeEntries.add(new PipFreezeEntry("example", "2.0.0"));
PipFreeze pipFreeze = new PipFreeze(pipFreezeEntries);
List<PipenvGraphEntry> pipenvGraphEntries = new ArrayList<>();
pipenvGraphEntries.add(new PipenvGraphEntry("example", "fuzzy", new ArrayList<>()));
PipenvGraph pipenvGraph = new PipenvGraph(pipenvGraphEntries);
PipenvTransformer pipenvTransformer = new PipenvTransformer(new ExternalIdFactory());
CodeLocation codeLocation = pipenvTransformer.transform("", "", pipFreeze, pipenvGraph, false);
DependencyGraph graph = codeLocation.getDependencyGraph();
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PYPI, graph);
graphAssert.hasDependency("example", "2.0.0");
}
use of com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraphEntry in project synopsys-detect by blackducksoftware.
the class PipenvTransformer method transform.
public CodeLocation transform(String projectName, String projectVersionName, PipFreeze pipFreeze, PipenvGraph pipenvGraph, boolean includeOnlyProjectTree) {
DependencyGraph dependencyGraph = new BasicDependencyGraph();
for (PipenvGraphEntry entry : pipenvGraph.getEntries()) {
Dependency entryDependency = nameVersionToDependency(entry.getName(), entry.getVersion(), pipFreeze);
List<Dependency> children = addDependenciesToGraph(entry.getChildren(), dependencyGraph, pipFreeze);
if (matchesProject(entryDependency, projectName, projectVersionName)) {
// The project appears as an entry, we don't want the project to be a dependency of itself.
dependencyGraph.addChildrenToRoot(children);
} else if (!includeOnlyProjectTree) {
// Only add non-project matches if we are not project tree only.
dependencyGraph.addChildToRoot(entryDependency);
dependencyGraph.addParentWithChildren(entryDependency, children);
}
}
ExternalId projectExternalId = externalIdFactory.createNameVersionExternalId(Forge.PYPI, projectName, projectVersionName);
return new CodeLocation(dependencyGraph, projectExternalId);
}
use of com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraphEntry 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");
}
Aggregations