@Test(expected = CycleDetectedException.class) public void getBuildChainOnTreeWithLoopShouldFail() { Commit a = new Commit("A"); Commit b = new Commit("B", a); a.setParent(b); DependencyGraph<Commit> testee = new DependencyGraph<>(Commit::getParent); Stream.of(a, b) .forEach(testee::registerItem); testee.getBuildChain(); }
public Stream<T> getBuildChain() throws CycleDetectedException { DefaultDirectedGraph<T, DefaultEdge> graph = builder.build(); ensureNoCycle(graph); return Iterators.toStream(new TopologicalOrderIterator<>(graph)); }
DependencyGraph { public Stream<T> getBuildChain() throws CycleDetectedException { DefaultDirectedGraph<T, DefaultEdge> graph = builder.build(); ensureNoCycle(graph); return Iterators.toStream(new TopologicalOrderIterator<>(graph)); } }
DependencyGraph { public Stream<T> getBuildChain() throws CycleDetectedException { DefaultDirectedGraph<T, DefaultEdge> graph = builder.build(); ensureNoCycle(graph); return Iterators.toStream(new TopologicalOrderIterator<>(graph)); } DependencyGraph(Function<T, Optional<T>> getParent); }
DependencyGraph { public Stream<T> getBuildChain() throws CycleDetectedException { DefaultDirectedGraph<T, DefaultEdge> graph = builder.build(); ensureNoCycle(graph); return Iterators.toStream(new TopologicalOrderIterator<>(graph)); } DependencyGraph(Function<T, Optional<T>> getParent); void registerItem(T item); Stream<T> getBuildChain(); String toString(); }
DependencyGraph { public Stream<T> getBuildChain() throws CycleDetectedException { DefaultDirectedGraph<T, DefaultEdge> graph = builder.build(); ensureNoCycle(graph); return Iterators.toStream(new TopologicalOrderIterator<>(graph)); } DependencyGraph(Function<T, Optional<T>> getParent); void registerItem(T item); Stream<T> getBuildChain(); String toString();  }