### Question:
PluginEnabler { Collection<Plugin> enableAllRecursively(Collection<Plugin> plugins) { Collection<Plugin> pluginsToEnable = new ArrayList<Plugin>(); Set<String> dependentKeys = new HashSet<String>(); for (Plugin plugin : plugins) { scanDependencies(plugin, dependentKeys); } for (String key : dependentKeys) { pluginsToEnable.add(pluginAccessor.getPlugin(key)); } enable(pluginsToEnable); ImmutableList.Builder enabledPlugins = new ImmutableList.Builder(); for (Plugin plugin : pluginsToEnable) { if (plugin.getPluginState().equals(PluginState.ENABLED)) { enabledPlugins.add(plugin); } } return enabledPlugins.build(); } PluginEnabler(PluginAccessor pluginAccessor, PluginController pluginController);   }### Answer:
@Test public void testEnableAllRecursivelyEnablesDependencies() { Plugin plugin = new MyPlugin("foo", "foo2"); Plugin plugin2 = new MyPlugin("foo2", "foo3"); Plugin plugin3 = new MyPlugin("foo3"); MockPluginAccessor accessor = new MockPluginAccessor(); accessor.addPlugin(plugin); accessor.addPlugin(plugin2); accessor.addPlugin(plugin3); enabler = new PluginEnabler(accessor, mock(PluginController.class)); enabler.enableAllRecursively(Arrays.asList(plugin)); assertEquals(PluginState.ENABLED, plugin.getPluginState()); assertEquals(PluginState.ENABLED, plugin2.getPluginState()); assertEquals(PluginState.ENABLED, plugin3.getPluginState()); }