Dag { public String print() throws DagConstructionException { detectCycles(); for (DagNode node : findRootNodes()) { node.findMaxIndentionLevel(2); } String prob = UUID.randomUUID().toString(); StringBuilder builder = new StringBuilder(); for (DagNode node : findRootNodes()) { builder.append("\n").append(node.printBfs(prob, "1|", 2)); } return builder.toString(); }  void addNode(String nodeId); void removeNode(DagNode parent); void addTask(DagTask task); boolean addDependency(String first, String next); void updateLabel(String nodeId, String label); void start(); void termiante(); boolean isFailed(); boolean isDone(); void validate(); void detectCycles(); Set<DagNode> findRootNodes(); String print(); boolean isRoot(String nodeId); boolean hasDependency(String first, String next); String asJson();  }
@Test public void testPrint() throws DagConstructionException { Dag dag = new Dag(); dag.addNode("task1"); dag.addDependency("task2", "task21"); dag.addDependency("task3", "task31"); dag.addDependency("task31", "task32"); dag.addDependency("task32", "task33"); dag.addDependency("task21", "task31"); System.out.println(dag.print()); }