### Question:
PluginManager { public void loadPlugins() { Collection<TimoCloudPluginDescription> pluginDescriptions = new HashSet<>(); for (File file : TimoCloudCore.getInstance().getFileManager().getPluginsDirectory().listFiles()) { if (file.isDirectory()) continue; if (!file.getName().endsWith(".jar")) continue; try { TimoCloudPluginDescription plugin = loadPlugin(file); pluginDescriptions.add(plugin); } catch (Exception e) { TimoCloudCore.getInstance().severe("Error while loading plugin '" + file.getName() + "': "); TimoCloudCore.getInstance().severe(e); } } loadPlugins(pluginDescriptions); } PluginManager(); void loadPlugins(); void loadPlugins(Collection<TimoCloudPluginDescription> pluginDescriptions); void load(TimoCloudPluginDescription plugin, Collection<TimoCloudPluginDescription> order, Stack<TimoCloudPluginDescription> dependStack, Map<String, TimoCloudPluginDescription> descriptionsByName); TimoCloudPluginDescription loadPlugin(File file); Collection<TimoCloudPlugin> getPlugins();  }### Answer:
@Test public void testDependency1() throws Exception { TimoCloudPluginDescription plugin1 = generatePluginDescriptionWithDepends("Plugin1", "Plugin2"); TimoCloudPluginDescription plugin2 = generatePluginDescriptionWithDepends("Plugin2"); InOrder inOrder = Mockito.inOrder(pluginClassLoader); pluginManager.loadPlugins(Arrays.asList(plugin1, plugin2)); inOrder.verify(pluginClassLoader).loadClass(eq(plugin2.getMainClass())); inOrder.verify(pluginClassLoader).loadClass(eq(plugin1.getMainClass())); }
@Test public void testDependency2() throws Exception { TimoCloudPluginDescription plugin1 = generatePluginDescriptionWithDepends("Plugin1", "Plugin2", "Plugin3"); TimoCloudPluginDescription plugin2 = generatePluginDescriptionWithDepends("Plugin2", "Plugin3"); TimoCloudPluginDescription plugin3 = generatePluginDescriptionWithDepends("Plugin3"); InOrder inOrder = Mockito.inOrder(pluginClassLoader); pluginManager.loadPlugins(Arrays.asList(plugin1, plugin2, plugin3)); inOrder.verify(pluginClassLoader).loadClass(eq(plugin3.getMainClass())); inOrder.verify(pluginClassLoader).loadClass(eq(plugin2.getMainClass())); inOrder.verify(pluginClassLoader).loadClass(eq(plugin1.getMainClass())); }
@Test public void testDependencyFail1() { TimoCloudPluginDescription plugin1 = generatePluginDescriptionWithDepends("Plugin1", "Plugin2"); TimoCloudPluginDescription plugin2 = generatePluginDescriptionWithDepends("Plugin2", "Plugin1"); pluginManager.loadPlugins(Arrays.asList(plugin1, plugin2)); expectCoreExeption(); }
@Test public void testDependencyFail2() { TimoCloudPluginDescription plugin1 = generatePluginDescriptionWithDepends("Plugin1", "Plugin2"); TimoCloudPluginDescription plugin2 = generatePluginDescriptionWithDepends("Plugin2", "Plugin3"); TimoCloudPluginDescription plugin3 = generatePluginDescriptionWithDepends("Plugin3", "Plugin1"); pluginManager.loadPlugins(Arrays.asList(plugin1, plugin2, plugin3)); expectCoreExeption(); }
@Test public void testSoftDependency1() { TimoCloudPluginDescription plugin1 = generatePluginDescriptionWithSoftDepends("Plugin1", "Plugin2", "Plugin3"); TimoCloudPluginDescription plugin2 = generatePluginDescriptionWithSoftDepends("Plugin2", "Plugin3"); pluginManager.loadPlugins(Arrays.asList(plugin1, plugin2)); expectNoException(); }