Search in sources :

Example 1 with PipenvGraphDependency

use of com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraphDependency 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");
}
Also used : CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) PipenvGraphDependency(com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraphDependency) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ArrayList(java.util.ArrayList) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) PipFreeze(com.synopsys.integration.detectable.detectables.pipenv.build.model.PipFreeze) PipenvTransformer(com.synopsys.integration.detectable.detectables.pipenv.build.parser.PipenvTransformer) PipenvGraphEntry(com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraphEntry) PipenvGraph(com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraph) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Example 2 with PipenvGraphDependency

use of com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraphDependency in project synopsys-detect by blackducksoftware.

the class PipenvTransformer method addDependenciesToGraph.

private List<Dependency> addDependenciesToGraph(List<PipenvGraphDependency> graphDependencies, DependencyGraph graph, PipFreeze pipFreeze) {
    List<Dependency> dependencies = new ArrayList<>();
    for (PipenvGraphDependency graphDependency : graphDependencies) {
        Dependency dependency = nameVersionToDependency(graphDependency.getName(), graphDependency.getInstalledVersion(), pipFreeze);
        List<Dependency> children = addDependenciesToGraph(graphDependency.getChildren(), graph, pipFreeze);
        graph.addParentWithChildren(dependency, children);
        dependencies.add(dependency);
    }
    return dependencies;
}
Also used : PipenvGraphDependency(com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraphDependency) ArrayList(java.util.ArrayList) PipenvGraphDependency(com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraphDependency) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 3 with PipenvGraphDependency

use of com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraphDependency 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");
}
Also used : PipenvTransformer(com.synopsys.integration.detectable.detectables.pipenv.build.parser.PipenvTransformer) PipenvGraphEntry(com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraphEntry) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) PipenvGraphDependency(com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraphDependency) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ArrayList(java.util.ArrayList) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) PipenvGraph(com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraph) PipFreeze(com.synopsys.integration.detectable.detectables.pipenv.build.model.PipFreeze) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Aggregations

PipenvGraphDependency (com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraphDependency)3 ArrayList (java.util.ArrayList)3 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)2 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)2 UnitTest (com.synopsys.integration.detectable.annotations.UnitTest)2 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)2 PipFreeze (com.synopsys.integration.detectable.detectables.pipenv.build.model.PipFreeze)2 PipenvGraph (com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraph)2 PipenvGraphEntry (com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraphEntry)2 PipenvTransformer (com.synopsys.integration.detectable.detectables.pipenv.build.parser.PipenvTransformer)2 NameVersionGraphAssert (com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert)2 Test (org.junit.jupiter.api.Test)2 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)1