From f0ef947bf42e873b4d8b9be5f557f957eff75f70 Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Sun, 3 May 2020 22:39:09 +0200 Subject: [PATCH] Make this a list to allow direct element access --- core/src/main/java/hudson/PluginWrapper.java | 4 ++-- .../resources/hudson/PluginManager/installed.jelly | 1 + test/src/test/java/hudson/PluginManagerTest.java | 11 ++++------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/hudson/PluginWrapper.java b/core/src/main/java/hudson/PluginWrapper.java index 32c67e771d..0442248c2d 100644 --- a/core/src/main/java/hudson/PluginWrapper.java +++ b/core/src/main/java/hudson/PluginWrapper.java @@ -1303,9 +1303,9 @@ public class PluginWrapper implements Comparable, ModelObject { } @Restricted(NoExternalUse.class) - public Set getDeprecations() { + public List getDeprecations() { /* Would be much nicer to go through getInfoFromAllSites but that only works for currently published plugins */ - Set deprecations = new HashSet<>(); + List deprecations = new ArrayList<>(); for (UpdateSite site : Jenkins.get().getUpdateCenter().getSites()) { for (Map.Entry entry : site.getData().getDeprecations().entrySet()) { if (entry.getKey().equals(this.shortName)) { diff --git a/core/src/main/resources/hudson/PluginManager/installed.jelly b/core/src/main/resources/hudson/PluginManager/installed.jelly index e8b169de09..c911933422 100644 --- a/core/src/main/resources/hudson/PluginManager/installed.jelly +++ b/core/src/main/resources/hudson/PluginManager/installed.jelly @@ -134,6 +134,7 @@ THE SOFTWARE.
+ ${%deprecationWarning(p.getDeprecations().get(0).url)}
diff --git a/test/src/test/java/hudson/PluginManagerTest.java b/test/src/test/java/hudson/PluginManagerTest.java index 41d842d755..684f0ef55c 100644 --- a/test/src/test/java/hudson/PluginManagerTest.java +++ b/test/src/test/java/hudson/PluginManagerTest.java @@ -645,10 +645,9 @@ public class PluginManagerTest { final PluginWrapper iconShim = pm.getPlugin("icon-shim"); Objects.requireNonNull(iconShim); assertTrue(iconShim.isDeprecated()); - Set deprecations = iconShim.getDeprecations(); + List deprecations = iconShim.getDeprecations(); assertEquals(1, deprecations.size()); - List deprecationList = new ArrayList<>(deprecations); - assertEquals("https://jenkins.io/deprecations/icon-shim/", deprecationList.get(0).url); + assertEquals("https://jenkins.io/deprecations/icon-shim/", deprecations.get(0).url); assertEquals("https://wiki.jenkins-ci.org/display/JENKINS/Icon+Shim+Plugin", iconShim.getInfo().wiki); final PluginWrapper tokenMacro = pm.getPlugin("token-macro"); @@ -656,16 +655,14 @@ public class PluginManagerTest { assertTrue(tokenMacro.isDeprecated()); deprecations = tokenMacro.getDeprecations(); assertEquals(1, deprecations.size()); - deprecationList = new ArrayList<>(deprecations); - assertEquals("https://wiki.jenkins-ci.org/display/JENKINS/Token+Macro+Plugin", deprecationList.get(0).url); + assertEquals("https://wiki.jenkins-ci.org/display/JENKINS/Token+Macro+Plugin", deprecations.get(0).url); final PluginWrapper variant = pm.getPlugin("variant"); Objects.requireNonNull(variant); assertTrue(variant.isDeprecated()); deprecations = variant.getDeprecations(); assertEquals(1, deprecations.size()); - deprecationList = new ArrayList<>(deprecations); - assertEquals("https://jenkins.io/deprecations/variant/", deprecationList.get(0).url); + assertEquals("https://jenkins.io/deprecations/variant/", deprecations.get(0).url); assertNull(variant.getInfo()); } }