DependencyResolver { public Collection<Node<?>> resolve(Collection<Class<?>> pluginClasses) { final Graph graph = new Graph(); for (Class<?> pluginClass : pluginClasses) { final Collection<Node<?>> deps = processor.getDependencies(pluginClass); final Node<?> node = new Node<>(pluginClass); if (deps.isEmpty()) { graph.addLeaf(node); } else { graph.addEdges(node, deps); } } return graph.resolve(); } DependencyResolver(AnnotationProcessor processor); Collection<Node<?>> resolve(Collection<Class<?>> pluginClasses);  }
@Test public void shouldResolveComplexDependencies() throws Exception { List<Class<?>> plugins = newArrayList(DeepDependencyPlugin.class, DependencyPlugin.class, TestPlugin.class, OptionalPlugin.class, SingleDependencyPlugin.class ); Collection<Node<?>> nodes = sut.resolve(plugins); assertEquals(plugins.size(), nodes.size()); for (Node node : nodes) { assertTrue(plugins.contains(node.getRefClass())); } }
@Test public void shouldResolvePluginsWithoutDependencies() { List<Class<?>> plugins = newArrayList(TestPlugin.class, OptionalPlugin.class); final Collection<Node<?>> nodes = sut.resolve(plugins); assertEquals(plugins.size(), nodes.size()); for (Node<?> node : nodes) { assertTrue(plugins.contains(node.getRefClass())); } }