Search in sources :

Example 1 with PipenvGraph

use of com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraph 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");
}
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) 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) PipFreezeEntry(com.synopsys.integration.detectable.detectables.pipenv.build.model.PipFreezeEntry) PipFreeze(com.synopsys.integration.detectable.detectables.pipenv.build.model.PipFreeze) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Example 2 with PipenvGraph

use of com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraph 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 3 with PipenvGraph

use of com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraph 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");
}
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) 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) PipFreezeEntry(com.synopsys.integration.detectable.detectables.pipenv.build.model.PipFreezeEntry) PipFreeze(com.synopsys.integration.detectable.detectables.pipenv.build.model.PipFreeze) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Example 4 with PipenvGraph

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

the class PipenvExtractor method extract.

public Extraction extract(File directory, ExecutableTarget pythonExe, ExecutableTarget pipenvExe, File setupFile, String providedProjectName, String providedProjectVersionName, boolean includeOnlyProjectTree) {
    Extraction extraction;
    try {
        String projectName = resolveProjectName(directory, pythonExe, setupFile, providedProjectName);
        String projectVersionName = resolveProjectVersionName(directory, pythonExe, setupFile, providedProjectVersionName);
        ExecutableOutput pipFreezeOutput = executableRunner.execute(ExecutableUtils.createFromTarget(directory, pipenvExe, Arrays.asList("run", "pip", "freeze")));
        ExecutableOutput graphOutput = executableRunner.execute(ExecutableUtils.createFromTarget(directory, pipenvExe, Arrays.asList("graph", "--bare", "--json-tree")));
        PipFreeze pipFreeze = pipenvFreezeParser.parse(pipFreezeOutput.getStandardOutputAsList());
        PipenvGraph pipenvGraph = pipEnvJsonGraphParser.parse(graphOutput.getStandardOutput());
        CodeLocation codeLocation = pipenvTransformer.transform(projectName, projectVersionName, pipFreeze, pipenvGraph, includeOnlyProjectTree);
        return new Extraction.Builder().projectName(projectName).projectVersion(projectVersionName).success(codeLocation).build();
    } catch (Exception e) {
        extraction = new Extraction.Builder().exception(e).build();
    }
    return extraction;
}
Also used : ExecutableOutput(com.synopsys.integration.executable.ExecutableOutput) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) Extraction(com.synopsys.integration.detectable.extraction.Extraction) PipenvGraph(com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraph) ExecutableRunnerException(com.synopsys.integration.executable.ExecutableRunnerException) PipFreeze(com.synopsys.integration.detectable.detectables.pipenv.build.model.PipFreeze)

Example 5 with PipenvGraph

use of com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraph 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

CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)5 PipFreeze (com.synopsys.integration.detectable.detectables.pipenv.build.model.PipFreeze)5 PipenvGraph (com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraph)5 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)4 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)4 UnitTest (com.synopsys.integration.detectable.annotations.UnitTest)4 PipenvGraphEntry (com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraphEntry)4 PipenvTransformer (com.synopsys.integration.detectable.detectables.pipenv.build.parser.PipenvTransformer)4 NameVersionGraphAssert (com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert)4 ArrayList (java.util.ArrayList)4 Test (org.junit.jupiter.api.Test)4 PipFreezeEntry (com.synopsys.integration.detectable.detectables.pipenv.build.model.PipFreezeEntry)2 PipenvGraphDependency (com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraphDependency)2 Extraction (com.synopsys.integration.detectable.extraction.Extraction)1 ExecutableOutput (com.synopsys.integration.executable.ExecutableOutput)1 ExecutableRunnerException (com.synopsys.integration.executable.ExecutableRunnerException)1