NodePrinter { public void printNodes() { StringBuilder sb = new StringBuilder(); dependencyGraph.getAllNodes().forEach(n -> printNode(n, sb)); FileSystemUtil.writeStringToFile(sb.toString(), filename); } NodePrinter(DependencyGraph dependencyGraph, String filename); void printNodes();  }
@Test public void printNodes() { DependencyGraph graph = GraphReaderWriter.read("src/test/resources/graphs/testGraph1.json"); new NodePrinter(graph, "build/nodes.txt").printNodes(); String written = FileSystemUtil.readFileAsText("build/nodes.txt").trim().replaceAll("\\r\\n", "\n"); String expected = FileSystemUtil.readFileAsText("src/test/resources/graphs/expected_nodes1.txt").trim().replaceAll("\\r\\n", "\n"); assertThat(written, is(expected)); }