ChainBuilder { public Chain<T> build() { DirectedGraph graph = buildGraph(); List<Vertex> sortedVertices = graph.topologicalSort(); return new Chain<>(chainId, components(sortedVertices)); } ChainBuilder(String chainId); @SafeVarargs final ChainBuilder<T> add(T component, Dependencies<? extends T>... dependenciesList); Chain<T> build();  }
@Test public void build_empty_chain() { Chain<Filter> chain = getChain().build(); assertTrue(chain.isEmpty()); assertEquals("myChain", chain.id()); }