@Test public void findEffectivePluginsTest() { Map<String, Plugin> bundledPlugins = new HashMap<>(); Map<String, Plugin> installedPlugins = new HashMap<>(); bundledPlugins.put("git", new Plugin("git", "1.2", null, null)); bundledPlugins.put("aws-credentials", new Plugin("aws-credentials", "1.24", null, null)); bundledPlugins.put("p4", new Plugin("p4", "1.3.3", null, null)); installedPlugins.put("script-security", new Plugin("script-security", "1.26", null, null)); installedPlugins.put("credentials", new Plugin("credentials", "2.1.11", null, null)); installedPlugins.put("ace-editor", new Plugin("ace-editor", "1.0.1", null, null)); installedPlugins.put("p4", new Plugin("p4", "1.3.0", null, null)); pm.setBundledPluginVersions(bundledPlugins); pm.setInstalledPluginVersions(installedPlugins); List<Plugin> requestedPlugins = Arrays.asList( new Plugin("git", "1.3", null, null), new Plugin("script-security", "1.25", null, null), new Plugin("scm-api", "2.2.3", null, null)); Map<String, Plugin> effectivePlugins = pm.findEffectivePlugins(requestedPlugins); assertThat(effectivePlugins.get("git").getVersion()) .hasToString("1.3"); assertThat(effectivePlugins.get("scm-api").getVersion()) .hasToString("2.2.3"); assertThat(effectivePlugins.get("aws-credentials").getVersion()) .hasToString("1.24"); assertThat(effectivePlugins.get("p4").getVersion()) .hasToString("1.3.3"); assertThat(effectivePlugins.get("script-security").getVersion()) .hasToString("1.26"); assertThat(effectivePlugins.get("credentials").getVersion()) .hasToString("2.1.11"); assertThat(effectivePlugins.get("ace-editor").getVersion()) .hasToString("1.0.1"); }
public Map<String, Plugin> findEffectivePlugins(List<Plugin> pluginsToBeDownloaded) { Map<String, Plugin> effectivePlugins = new HashMap<>(); for (Plugin plugin : pluginsToBeDownloaded) { effectivePlugins.put(plugin.getName(), plugin); } sortEffectivePlugins(effectivePlugins, installedPluginVersions); sortEffectivePlugins(effectivePlugins, bundledPluginVersions); return effectivePlugins; }
PluginManager { public Map<String, Plugin> findEffectivePlugins(List<Plugin> pluginsToBeDownloaded) { Map<String, Plugin> effectivePlugins = new HashMap<>(); for (Plugin plugin : pluginsToBeDownloaded) { effectivePlugins.put(plugin.getName(), plugin); } sortEffectivePlugins(effectivePlugins, installedPluginVersions); sortEffectivePlugins(effectivePlugins, bundledPluginVersions); return effectivePlugins; } }
PluginManager { public Map<String, Plugin> findEffectivePlugins(List<Plugin> pluginsToBeDownloaded) { Map<String, Plugin> effectivePlugins = new HashMap<>(); for (Plugin plugin : pluginsToBeDownloaded) { effectivePlugins.put(plugin.getName(), plugin); } sortEffectivePlugins(effectivePlugins, installedPluginVersions); sortEffectivePlugins(effectivePlugins, bundledPluginVersions); return effectivePlugins; } @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> findEffectivePlugins(List<Plugin> pluginsToBeDownloaded) { Map<String, Plugin> effectivePlugins = new HashMap<>(); for (Plugin plugin : pluginsToBeDownloaded) { effectivePlugins.put(plugin.getName(), plugin); } sortEffectivePlugins(effectivePlugins, installedPluginVersions); sortEffectivePlugins(effectivePlugins, bundledPluginVersions); return effectivePlugins; } @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> findEffectivePlugins(List<Plugin> pluginsToBeDownloaded) { Map<String, Plugin> effectivePlugins = new HashMap<>(); for (Plugin plugin : pluginsToBeDownloaded) { effectivePlugins.put(plugin.getName(), plugin); } sortEffectivePlugins(effectivePlugins, installedPluginVersions); sortEffectivePlugins(effectivePlugins, bundledPluginVersions); return effectivePlugins; } @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();  }