ModelGraph { List<ModelNode> getNodes() { return modelNodes; } ModelGraph(List<ModelNode> modelNodes, List<ModelNode> roots); List<ModelNode> topologicalSort();  }
@Test public void require_that_dependencies_are_correctly_set() { ModelGraphBuilder builder = new ModelGraphBuilder(); builder.addBuilder(new GraphMock.BC()).addBuilder(new GraphMock.BB()).addBuilder(new GraphMock.BA()); ModelGraph graph = builder.build(); List<ModelNode> nodes = graph.getNodes(); assertThat(graph.getNodes().size(), is(3)); assertTrue(nodes.get(0).hasDependencies()); assertTrue(nodes.get(1).hasDependencies()); assertFalse(nodes.get(2).hasDependencies()); assertTrue(nodes.get(0).dependsOn(nodes.get(1))); assertTrue(nodes.get(1).dependsOn(nodes.get(2))); assertFalse(nodes.get(2).dependsOn(nodes.get(0))); }