Search in sources :

Example 1 with PipfileLock

use of com.synopsys.integration.detectable.detectables.pipenv.parse.data.PipfileLock in project synopsys-detect by blackducksoftware.

the class PipfileLockParserTest method testParse.

@Test
public void testParse() {
    PipfileLock pipfileLock = pipfileLock();
    PipfileLockDependencyVersionParser dependencyVersionParser = new PipfileLockDependencyVersionParser();
    PipfileLockTransformer parser = new PipfileLockTransformer(dependencyVersionParser, EnumListFilter.excludeNone());
    List<PipfileLockDependency> dependencies = parser.transform(pipfileLock);
    Assertions.assertEquals(3, dependencies.size());
    Assertions.assertTrue(containsDependency(dependencies, "comp1", "1.0"));
    Assertions.assertTrue(containsDependency(dependencies, "comp2", null));
    Assertions.assertTrue(containsDependency(dependencies, "comp3", "3.0"));
}
Also used : PipfileLock(com.synopsys.integration.detectable.detectables.pipenv.parse.data.PipfileLock) PipfileLockDependencyVersionParser(com.synopsys.integration.detectable.detectables.pipenv.parse.PipfileLockDependencyVersionParser) PipfileLockTransformer(com.synopsys.integration.detectable.detectables.pipenv.parse.PipfileLockTransformer) PipfileLockDependency(com.synopsys.integration.detectable.detectables.pipenv.parse.model.PipfileLockDependency) Test(org.junit.jupiter.api.Test)

Example 2 with PipfileLock

use of com.synopsys.integration.detectable.detectables.pipenv.parse.data.PipfileLock in project synopsys-detect by blackducksoftware.

the class PipfileLockParserTest method testExcludeDevelopDependencies.

@Test
public void testExcludeDevelopDependencies() {
    PipfileLock pipfileLock = pipfileLock();
    PipfileLockDependencyVersionParser dependencyVersionParser = new PipfileLockDependencyVersionParser();
    PipfileLockTransformer parser = new PipfileLockTransformer(dependencyVersionParser, EnumListFilter.fromExcluded(PipenvDependencyType.DEV));
    List<PipfileLockDependency> dependencies = parser.transform(pipfileLock);
    Assertions.assertEquals(2, dependencies.size());
    Assertions.assertTrue(containsDependency(dependencies, "comp1", "1.0"));
    Assertions.assertTrue(containsDependency(dependencies, "comp2", null));
    Assertions.assertFalse(containsDependency(dependencies, "comp3", "3.0"));
}
Also used : PipfileLock(com.synopsys.integration.detectable.detectables.pipenv.parse.data.PipfileLock) PipfileLockDependencyVersionParser(com.synopsys.integration.detectable.detectables.pipenv.parse.PipfileLockDependencyVersionParser) PipfileLockTransformer(com.synopsys.integration.detectable.detectables.pipenv.parse.PipfileLockTransformer) PipfileLockDependency(com.synopsys.integration.detectable.detectables.pipenv.parse.model.PipfileLockDependency) Test(org.junit.jupiter.api.Test)

Example 3 with PipfileLock

use of com.synopsys.integration.detectable.detectables.pipenv.parse.data.PipfileLock in project synopsys-detect by blackducksoftware.

the class PipfileLockParserTest method pipfileLock.

private PipfileLock pipfileLock() {
    PipfileLock pipfileLock = new PipfileLock();
    Map<String, PipfileLockDependencyEntry> dependencies = new HashMap<>();
    dependencies.put("comp1", createEntry("==1.0"));
    dependencies.put("comp2", createEntry(null));
    pipfileLock.dependencies = dependencies;
    Map<String, PipfileLockDependencyEntry> devDependencies = new HashMap<>();
    devDependencies.put("comp3", createEntry("==3.0"));
    pipfileLock.devDependencies = devDependencies;
    return pipfileLock;
}
Also used : PipfileLock(com.synopsys.integration.detectable.detectables.pipenv.parse.data.PipfileLock) HashMap(java.util.HashMap) PipfileLockDependencyEntry(com.synopsys.integration.detectable.detectables.pipenv.parse.data.PipfileLockDependencyEntry)

Example 4 with PipfileLock

use of com.synopsys.integration.detectable.detectables.pipenv.parse.data.PipfileLock in project synopsys-detect by blackducksoftware.

the class PipfileLockExtractor method extract.

public Extraction extract(File pipfileLockFile) throws IOException {
    String pipfileLockText = FileUtils.readFileToString(pipfileLockFile, StandardCharsets.UTF_8);
    PipfileLock pipfileLock = gson.fromJson(pipfileLockText, PipfileLock.class);
    List<PipfileLockDependency> dependencies = pipfileLockTransformer.transform(pipfileLock);
    DependencyGraph dependencyGraph = pipfileLockDependencyTransformer.transform(dependencies);
    CodeLocation codeLocation = new CodeLocation(dependencyGraph);
    // No project info - hoping git can help with that.
    return Extraction.success(codeLocation);
}
Also used : PipfileLock(com.synopsys.integration.detectable.detectables.pipenv.parse.data.PipfileLock) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) PipfileLockDependency(com.synopsys.integration.detectable.detectables.pipenv.parse.model.PipfileLockDependency) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph)

Aggregations

PipfileLock (com.synopsys.integration.detectable.detectables.pipenv.parse.data.PipfileLock)4 PipfileLockDependency (com.synopsys.integration.detectable.detectables.pipenv.parse.model.PipfileLockDependency)3 PipfileLockDependencyVersionParser (com.synopsys.integration.detectable.detectables.pipenv.parse.PipfileLockDependencyVersionParser)2 PipfileLockTransformer (com.synopsys.integration.detectable.detectables.pipenv.parse.PipfileLockTransformer)2 Test (org.junit.jupiter.api.Test)2 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)1 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)1 PipfileLockDependencyEntry (com.synopsys.integration.detectable.detectables.pipenv.parse.data.PipfileLockDependencyEntry)1 HashMap (java.util.HashMap)1