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);
}
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);
}
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");
}
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");
}
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");
}
Aggregations