Search in sources :

Example 6 with NameVersionGraphAssert

use of com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert 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 7 with NameVersionGraphAssert

use of com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert 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 8 with NameVersionGraphAssert

use of com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert in project synopsys-detect by blackducksoftware.

the class PoetryLockParserTest method testParseComplexDependencyHierarchy.

@Test
public void testParseComplexDependencyHierarchy() throws IOException {
    String input = String.join(System.lineSeparator(), Arrays.asList("[[package]]", "name = \"test1\"", "version = \"1.0.0\"", "", "[package.dependencies]", "test2 = \">=1.0\"", "", "[[package]]", "name = \"test2\"", "version = \"2.0\"", "", "[package.dependencies]", "test4 = \"<4.4\"", "", "[[package]]", "name = \"test3\"", "version = \"3.0\"", "", "[[package]]", "name = \"test4\"", "version = \"4.0\"", "", "[package.dependencies]", "test1 = \"~1.0.0\""));
    PoetryLockParser poetryLockParser = new PoetryLockParser();
    DependencyGraph graph = poetryLockParser.parseLockFile(input);
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PYPI, graph);
    graphAssert.hasRootSize(1);
    graphAssert.hasRootDependency("test3", "3.0");
    graphAssert.hasParentChildRelationship("test1", "1.0.0", "test2", "2.0");
    graphAssert.hasParentChildRelationship("test2", "2.0", "test4", "4.0");
    graphAssert.hasParentChildRelationship("test4", "4.0", "test1", "1.0.0");
}
Also used : NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) PoetryLockParser(com.synopsys.integration.detectable.detectables.poetry.parser.PoetryLockParser) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.jupiter.api.Test)

Example 9 with NameVersionGraphAssert

use of com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert in project synopsys-detect by blackducksoftware.

the class PoetryLockParserTest method testParseNameAndVersionSimple.

@Test
public void testParseNameAndVersionSimple() {
    String input = String.join(System.lineSeparator(), Arrays.asList("[[package]]", "name = \"pytest-cov\"", "version = \"2.8.1\"", "", "[[package]]", "name = \"pytest-mock\"", "version = \"2.0.0\""));
    PoetryLockParser poetryLockParser = new PoetryLockParser();
    DependencyGraph graph = poetryLockParser.parseLockFile(input);
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PYPI, graph);
    graphAssert.hasRootSize(2);
    graphAssert.hasRootDependency("pytest-cov", "2.8.1");
    graphAssert.hasRootDependency("pytest-mock", "2.0.0");
}
Also used : NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) PoetryLockParser(com.synopsys.integration.detectable.detectables.poetry.parser.PoetryLockParser) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.jupiter.api.Test)

Example 10 with NameVersionGraphAssert

use of com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert in project synopsys-detect by blackducksoftware.

the class PoetryLockParserTest method testEmptyGraphWhenNoPackageObjects.

@Test
public void testEmptyGraphWhenNoPackageObjects() throws IOException {
    String input = String.join(System.lineSeparator(), Arrays.asList("package", "name = \"pytest\"", "version = \"1.0.0\"", "", "package", "name = \"python\"", "version = \"3.0\""));
    PoetryLockParser poetryLockParser = new PoetryLockParser();
    DependencyGraph graph = poetryLockParser.parseLockFile(input);
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PYPI, graph);
    graphAssert.hasRootSize(0);
}
Also used : NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) PoetryLockParser(com.synopsys.integration.detectable.detectables.poetry.parser.PoetryLockParser) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.jupiter.api.Test)

Aggregations

NameVersionGraphAssert (com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert)76 Test (org.junit.jupiter.api.Test)35 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)32 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)18 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)10 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)10 UnitTest (com.synopsys.integration.detectable.annotations.UnitTest)7 ArrayList (java.util.ArrayList)6 PnpmLockYaml (com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmLockYaml)5 PnpmYamlTransformer (com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmYamlTransformer)5 PipFreeze (com.synopsys.integration.detectable.detectables.pipenv.build.model.PipFreeze)4 PipenvGraph (com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraph)4 PipenvGraphEntry (com.synopsys.integration.detectable.detectables.pipenv.build.model.PipenvGraphEntry)4 PipenvTransformer (com.synopsys.integration.detectable.detectables.pipenv.build.parser.PipenvTransformer)4 PoetryLockParser (com.synopsys.integration.detectable.detectables.poetry.parser.PoetryLockParser)4 FunctionalTest (com.synopsys.integration.detectable.annotations.FunctionalTest)3 GemlockParser (com.synopsys.integration.detectable.detectables.rubygems.gemlock.parse.GemlockParser)3 BitbakeGraph (com.synopsys.integration.detectable.detectables.bitbake.model.BitbakeGraph)2 BitbakeDependencyGraphTransformer (com.synopsys.integration.detectable.detectables.bitbake.transform.BitbakeDependencyGraphTransformer)2 CargoLockPackage (com.synopsys.integration.detectable.detectables.cargo.model.CargoLockPackage)2