use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class RootPruningGraphUtilTests method cyclicalGraphPruned.
@Test()
public void cyclicalGraphPruned() {
Dependency parent = dependencyFactory.createNameVersionDependency(anyForge, "parent", "version");
Dependency child = dependencyFactory.createNameVersionDependency(anyForge, "child", "version");
DependencyGraph graph = new BasicDependencyGraph();
graph.addChildrenToRoot(parent);
graph.addParentWithChild(parent, child);
graph.addParentWithChild(child, parent);
Assertions.assertThrows(CycleDetectedException.class, () -> RootPruningGraphUtil.prune(graph));
}
use of com.synopsys.integration.bdio.graph.BasicDependencyGraph 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.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class GraphDeserializer method deserialize.
public static DependencyGraph deserialize(String text) {
DependencyGraph graph = new BasicDependencyGraph();
// three sections
List<String> lines = Arrays.asList(text.split("\n"));
int currentLineIndex = 0;
String currentLine = lines.get(0);
while (!currentLine.startsWith("Root Dependencies")) {
currentLineIndex++;
currentLine = lines.get(currentLineIndex);
}
while (!currentLine.startsWith("Relationships")) {
// In Root
currentLineIndex++;
currentLine = lines.get(currentLineIndex);
if (!currentLine.startsWith("Relationships")) {
graph.addChildToRoot(make(currentLine));
}
}
Dependency parent = null;
while (currentLineIndex + 1 < lines.size()) {
// In Relationships
currentLineIndex++;
currentLine = lines.get(currentLineIndex);
if (currentLine.startsWith("\t\t")) {
graph.addChildWithParent(make(currentLine), parent);
} else if (currentLine.startsWith("\t")) {
parent = make(currentLine);
}
}
return graph;
}
use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class CarthageDeclarationTransformer method transform.
public DependencyGraph transform(List<CarthageDeclaration> carthageDeclarations) {
DependencyGraph graph = new BasicDependencyGraph();
carthageDeclarations.stream().filter(this::isGitHubOrigin).map(this::createGitHubDependencyFromDeclaration).forEach(graph::addChildToRoot);
return graph;
}
use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class BitbakeDependencyGraphTransformer method buildGraph.
@NotNull
private DependencyGraph buildGraph(BitbakeGraph bitbakeGraph, Map<String, Dependency> namesToExternalIds) {
DependencyGraph dependencyGraph = new BasicDependencyGraph();
for (BitbakeNode bitbakeNode : bitbakeGraph.getNodes()) {
String name = bitbakeNode.getName();
if (namesToExternalIds.containsKey(name)) {
Dependency dependency = namesToExternalIds.get(bitbakeNode.getName());
dependencyGraph.addChildToRoot(dependency);
for (String child : bitbakeNode.getChildren()) {
if (namesToExternalIds.containsKey(child)) {
Dependency childDependency = namesToExternalIds.get(child);
dependencyGraph.addParentWithChild(dependency, childDependency);
}
}
}
}
return dependencyGraph;
}
Aggregations