Search in sources :

Example 1 with NameVersionGraphAssert

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

the class BitbakeDependencyGraphTransformerTest method parentHasChild.

@Test
public void parentHasChild() {
    ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    BitbakeGraph bitbakeGraph = new BitbakeGraph();
    bitbakeGraph.addNode("example", "1:75-r50", "meta");
    bitbakeGraph.addNode("foobar", "12", "meta");
    bitbakeGraph.addChild("example", "foobar");
    Map<String, List<String>> recipeToLayerMap = new HashMap<>();
    recipeToLayerMap.put("example", Collections.singletonList("meta"));
    recipeToLayerMap.put("foobar", Collections.singletonList("meta"));
    BitbakeDependencyGraphTransformer bitbakeDependencyGraphTransformer = new BitbakeDependencyGraphTransformer(EnumListFilter.excludeNone());
    DependencyGraph dependencyGraph = bitbakeDependencyGraphTransformer.transform(bitbakeGraph, recipeToLayerMap, null);
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.YOCTO, dependencyGraph);
    ExternalId example = graphAssert.hasDependency(externalIdFactory.createYoctoExternalId("meta", "example", "1:75-r50"));
    ExternalId foobar = graphAssert.hasDependency(externalIdFactory.createYoctoExternalId("meta", "foobar", "12"));
    graphAssert.hasParentChildRelationship(example, foobar);
}
Also used : HashMap(java.util.HashMap) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) BitbakeDependencyGraphTransformer(com.synopsys.integration.detectable.detectables.bitbake.transform.BitbakeDependencyGraphTransformer) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) List(java.util.List) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BitbakeGraph(com.synopsys.integration.detectable.detectables.bitbake.model.BitbakeGraph) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Example 2 with NameVersionGraphAssert

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

the class BitbakeDetectableTest method assertExtraction.

@Override
public void assertExtraction(@NotNull Extraction extraction) {
    Assertions.assertEquals(1, extraction.getCodeLocations().size());
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.YOCTO, extraction.getCodeLocations().get(0).getDependencyGraph());
    ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    ExternalId aclExternalId = externalIdFactory.createYoctoExternalId("meta", "acl", "2.2.52-r0");
    ExternalId attrExternalId = externalIdFactory.createYoctoExternalId("meta", "attr", "2.4.47-r0");
    ExternalId baseFilesExternalId = externalIdFactory.createYoctoExternalId("meta", "base-files", "3.0.14-r89");
    ExternalId basePasswdExternalId = externalIdFactory.createYoctoExternalId("meta", "base-passwd", "3.5.29-r0");
    graphAssert.hasNoDependency(aclExternalId);
    graphAssert.hasRootDependency(attrExternalId);
    graphAssert.hasRootDependency(baseFilesExternalId);
    graphAssert.hasRootDependency(basePasswdExternalId);
    graphAssert.hasParentChildRelationship(attrExternalId, baseFilesExternalId);
    graphAssert.hasParentChildRelationship(attrExternalId, basePasswdExternalId);
    graphAssert.hasRootSize(3);
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert)

Example 3 with NameVersionGraphAssert

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

the class RootPruningGraphUtilTests method simpleTwoRootIsPruned.

@Test
public void simpleTwoRootIsPruned() throws CycleDetectedException {
    Dependency root1 = dependencyFactory.createNameVersionDependency(anyForge, "root1", "version");
    Dependency root2 = dependencyFactory.createNameVersionDependency(anyForge, "root2", "version");
    Dependency child = dependencyFactory.createNameVersionDependency(anyForge, "child", "version");
    DependencyGraph graph = new BasicDependencyGraph();
    graph.addChildrenToRoot(root1, root2);
    graph.addParentWithChild(root1, child);
    graph.addParentWithChild(child, root2);
    DependencyGraph prunedGraph = RootPruningGraphUtil.prune(graph);
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(anyForge, prunedGraph);
    graphAssert.hasRootSize(1);
    graphAssert.hasRootDependency("root1", "version");
    graphAssert.hasParentChildRelationship("root1", "version", "child", "version");
    graphAssert.hasParentChildRelationship("child", "version", "root2", "version");
}
Also used : NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) Test(org.junit.jupiter.api.Test)

Example 4 with NameVersionGraphAssert

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

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

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