@Test public void resolveRecursiveDependenciesTest() { PluginManager pluginManagerSpy = spy(pm); doReturn(new ArrayList<Plugin>()).when(pluginManagerSpy).resolveDirectDependencies(any(Plugin.class)); Plugin grandParent = new Plugin("grandparent", "1.0", null, null); Plugin parent1 = new Plugin("parent1", "1.0", null, null); Plugin parent2 = new Plugin("replaced1", "1.0", null, null); Plugin parent3= new Plugin("parent3", "1.2", null, null); Plugin child1 = new Plugin("replaced1", "1.3", null, null); Plugin child2 = new Plugin("child2", "3.2.1", null, null); Plugin child3 = new Plugin("child3", "0.9", null, null); Plugin child4 = new Plugin("replaced1", "1.5.1", null, null); Plugin child5 = new Plugin("child5", "2.2.8", null, null); Plugin child6 = new Plugin("child6", "2.1.1", null, null); Plugin child7 = new Plugin("replaced2", "1.1.0", null, null); Plugin child8 = new Plugin("replaced2", "2.3", null, null); Plugin child9 = new Plugin("child9", "1.0.3", null, null); List<Plugin> grandParentDependencies = Arrays.asList( parent1, parent2, parent3); grandParent.setDependencies(grandParentDependencies); parent1.setDependencies(Arrays.asList(child1, child2, child7, child3)); parent2.setDependencies(Arrays.asList(child3, child8)); parent3.setDependencies(singletonList(child9)); child9.setDependencies(singletonList(child4)); child1.setDependencies(singletonList(child6)); child8.setDependencies(singletonList(child5)); Map<String, Plugin> recursiveDependencies = pluginManagerSpy.resolveRecursiveDependencies(grandParent); assertThat(recursiveDependencies) .hasSize(10) .containsValues( grandParent, parent1, child4, parent3, child2, child3, child8, child9, child5, child6); }
public Map<String, Plugin> resolveRecursiveDependencies(Plugin plugin) { return resolveRecursiveDependencies(plugin, null); }
PluginManager { public Map<String, Plugin> resolveRecursiveDependencies(Plugin plugin) { return resolveRecursiveDependencies(plugin, null); } }
PluginManager { public Map<String, Plugin> resolveRecursiveDependencies(Plugin plugin) { return resolveRecursiveDependencies(plugin, null); } @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "we want the user to be able to specify a path")  PluginManager(Config cfg); }
PluginManager { public Map<String, Plugin> resolveRecursiveDependencies(Plugin plugin) { return resolveRecursiveDependencies(plugin, null); } @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "we want the user to be able to specify a path")  PluginManager(Config cfg); void start(); void start(boolean downloadUc); List<Plugin> findPluginsToDownload(Map<String, Plugin> requestedPlugins); Map<String, Plugin> findEffectivePlugins(List<Plugin> pluginsToBeDownloaded); void listPlugins(); void logPlugins(String description, List<Plugin> plugins); Map<String, List<SecurityWarning>> getSecurityWarnings(); void showAllSecurityWarnings(); void showSpecificSecurityWarnings(List<Plugin> plugins); List<Plugin> getLatestVersionsOfPlugins(List<Plugin> plugins); boolean warningExists(Plugin plugin); void checkVersionCompatibility(VersionNumber jenkinsVersion, List<Plugin> pluginsToBeDownloaded); void downloadPlugins(List<Plugin> plugins); Map<String, Plugin> findPluginsAndDependencies(List<Plugin> requestedPlugins); void outputPluginReplacementInfo(Plugin lowerVersion, Plugin higherVersion); @Deprecated JSONObject getJson(String urlString); JSONObject getJson(URL url, String cacheKey); void getUCJson(VersionNumber jenkinsVersion); JSONArray getPluginDependencyJsonArray(Plugin plugin, JSONObject ucJson); VersionNumber getLatestPluginVersion(String pluginName); List<Plugin> resolveDependenciesFromManifest(Plugin plugin); List<Plugin> resolveDependenciesFromJson(Plugin plugin, JSONObject pluginJson); List<Plugin> resolveDirectDependencies(Plugin plugin); Map<String, Plugin> resolveRecursiveDependencies(Plugin plugin); boolean downloadPlugin(Plugin plugin, File location); String getPluginDownloadUrl(Plugin plugin); boolean downloadToFile(String urlString, Plugin plugin, File fileLocation); @SuppressFBWarnings({"RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE", "PATH_TRAVERSAL_IN"}) boolean downloadToFile(String urlString, Plugin plugin, File fileLocation, int maxRetries); String getAttributeFromManifest(File file, String key); VersionNumber getJenkinsVersionFromWar(); String getPluginVersion(File file); Map<String, Plugin> installedPlugins(); @SuppressFBWarnings({"RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE", "PATH_TRAVERSAL_IN"}) Map<String, Plugin> bundledPlugins(); String getJenkinsUCLatest(); void setJenkinsUCLatest(String updateCenterLatest); void setInstalledPluginVersions(Map<String, Plugin> installedPlugins); void setBundledPluginVersions(Map<String, Plugin> bundledPlugins); void setAllPluginsAndDependencies(Map<String, Plugin> allPluginsAndDependencies); void setEffectivePlugins(Map<String, Plugin> effectivePlugins); void setPluginsToBeDownloaded(List<Plugin> pluginsToBeDownloaded); void logVerbose(String message); void setLatestUcJson(JSONObject latestUcJson); void setLatestUcPlugins(JSONObject latestPlugins); void setExperimentalUcJson(JSONObject experimentalUcJson); void setAllSecurityWarnings(Map<String, List<SecurityWarning>> securityWarnings); void setPluginInfoJson(JSONObject pluginInfoJson); void setCm(CacheManager cm); List<Plugin> getFailedPlugins(); }
PluginManager { public Map<String, Plugin> resolveRecursiveDependencies(Plugin plugin) { return resolveRecursiveDependencies(plugin, null); } @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "we want the user to be able to specify a path")  PluginManager(Config cfg); void start(); void start(boolean downloadUc); List<Plugin> findPluginsToDownload(Map<String, Plugin> requestedPlugins); Map<String, Plugin> findEffectivePlugins(List<Plugin> pluginsToBeDownloaded); void listPlugins(); void logPlugins(String description, List<Plugin> plugins); Map<String, List<SecurityWarning>> getSecurityWarnings(); void showAllSecurityWarnings(); void showSpecificSecurityWarnings(List<Plugin> plugins); List<Plugin> getLatestVersionsOfPlugins(List<Plugin> plugins); boolean warningExists(Plugin plugin); void checkVersionCompatibility(VersionNumber jenkinsVersion, List<Plugin> pluginsToBeDownloaded); void downloadPlugins(List<Plugin> plugins); Map<String, Plugin> findPluginsAndDependencies(List<Plugin> requestedPlugins); void outputPluginReplacementInfo(Plugin lowerVersion, Plugin higherVersion); @Deprecated JSONObject getJson(String urlString); JSONObject getJson(URL url, String cacheKey); void getUCJson(VersionNumber jenkinsVersion); JSONArray getPluginDependencyJsonArray(Plugin plugin, JSONObject ucJson); VersionNumber getLatestPluginVersion(String pluginName); List<Plugin> resolveDependenciesFromManifest(Plugin plugin); List<Plugin> resolveDependenciesFromJson(Plugin plugin, JSONObject pluginJson); List<Plugin> resolveDirectDependencies(Plugin plugin); Map<String, Plugin> resolveRecursiveDependencies(Plugin plugin); boolean downloadPlugin(Plugin plugin, File location); String getPluginDownloadUrl(Plugin plugin); boolean downloadToFile(String urlString, Plugin plugin, File fileLocation); @SuppressFBWarnings({"RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE", "PATH_TRAVERSAL_IN"}) boolean downloadToFile(String urlString, Plugin plugin, File fileLocation, int maxRetries); String getAttributeFromManifest(File file, String key); VersionNumber getJenkinsVersionFromWar(); String getPluginVersion(File file); Map<String, Plugin> installedPlugins(); @SuppressFBWarnings({"RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE", "PATH_TRAVERSAL_IN"}) Map<String, Plugin> bundledPlugins(); String getJenkinsUCLatest(); void setJenkinsUCLatest(String updateCenterLatest); void setInstalledPluginVersions(Map<String, Plugin> installedPlugins); void setBundledPluginVersions(Map<String, Plugin> bundledPlugins); void setAllPluginsAndDependencies(Map<String, Plugin> allPluginsAndDependencies); void setEffectivePlugins(Map<String, Plugin> effectivePlugins); void setPluginsToBeDownloaded(List<Plugin> pluginsToBeDownloaded); void logVerbose(String message); void setLatestUcJson(JSONObject latestUcJson); void setLatestUcPlugins(JSONObject latestPlugins); void setExperimentalUcJson(JSONObject experimentalUcJson); void setAllSecurityWarnings(Map<String, List<SecurityWarning>> securityWarnings); void setPluginInfoJson(JSONObject pluginInfoJson); void setCm(CacheManager cm); List<Plugin> getFailedPlugins();  }