Search in sources :

Example 1 with PipfileLockDependency

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

the class PipfileLockDependencyTransformerTest method testTransform.

@Test
public void testTransform() {
    List<PipfileLockDependency> dependencies = Arrays.asList(new PipfileLockDependency("comp1", "1.0"), new PipfileLockDependency("comp2", "2.0"));
    PipfileLockDependencyTransformer transformer = new PipfileLockDependencyTransformer();
    DependencyGraph dependencyGraph = transformer.transform(dependencies);
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PYPI, dependencyGraph);
    graphAssert.hasRootSize(2);
    graphAssert.hasRootDependency("comp1", "1.0");
    graphAssert.hasRootDependency("comp2", "2.0");
}
Also used : PipfileLockDependency(com.synopsys.integration.detectable.detectables.pipenv.parse.model.PipfileLockDependency) PipfileLockDependencyTransformer(com.synopsys.integration.detectable.detectables.pipenv.parse.PipfileLockDependencyTransformer) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.jupiter.api.Test)

Example 2 with PipfileLockDependency

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

use of com.synopsys.integration.detectable.detectables.pipenv.parse.model.PipfileLockDependency 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 4 with PipfileLockDependency

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

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