From 2b07e56f117004b261b28ccd0e20df4014f29325 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 May 2023 18:49:57 +0000 Subject: [PATCH 1/6] build(deps): bump plugin from 4.54 to 4.64 Bumps [plugin](https://github.com/jenkinsci/plugin-pom) from 4.54 to 4.64. - [Release notes](https://github.com/jenkinsci/plugin-pom/releases) - [Changelog](https://github.com/jenkinsci/plugin-pom/blob/master/CHANGELOG.md) - [Commits](https://github.com/jenkinsci/plugin-pom/compare/plugin-4.54...plugin-4.64) --- updated-dependencies: - dependency-name: org.jenkins-ci.plugins:plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 457d741..f7ee5d8 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.jenkins-ci.plugins plugin - 4.54 + 4.64 From 04440ebb5bf01a120fd6968ef03a09b78b6f14eb Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 24 May 2023 12:10:53 +0200 Subject: [PATCH 2/6] IMPublisherTest: before(): rectify use of "this.rangeset" in mock - persist it as a class propery --- src/test/java/hudson/plugins/im/IMPublisherTest.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/test/java/hudson/plugins/im/IMPublisherTest.java b/src/test/java/hudson/plugins/im/IMPublisherTest.java index 92afed1..092a3c6 100644 --- a/src/test/java/hudson/plugins/im/IMPublisherTest.java +++ b/src/test/java/hudson/plugins/im/IMPublisherTest.java @@ -51,6 +51,7 @@ public class IMPublisherTest { private AbstractProject project; private AbstractProject upstreamProject; private BuildListener listener; + private RangeSet rangeset; @SuppressWarnings("unchecked") @Before @@ -63,16 +64,16 @@ public void before() throws IOException { this.project = mock(AbstractProject.class); when(project.getScm()).thenReturn(new NullSCM()); - RangeSet rangeset = RangeSet.fromString(buildNumber + "-" + (buildNumber + 2), false); + this.rangeset = RangeSet.fromString(buildNumber + "-" + (buildNumber + 2), false); this.previousBuildUpstreamBuild = mock(AbstractBuild.class); when(this.previousBuildUpstreamBuild.getParent()).thenReturn(project); this.upstreamBuildBetweenPreviousAndCurrent = mock(AbstractBuild.class); - when(this.upstreamBuildBetweenPreviousAndCurrent.getDownstreamRelationship(this.project)).thenReturn(rangeset); + when(this.upstreamBuildBetweenPreviousAndCurrent.getDownstreamRelationship(this.project)).thenReturn(this.rangeset); this.upstreamBuild = mock(AbstractBuild.class); - when(this.upstreamBuild.getDownstreamRelationship(this.project)).thenReturn(rangeset); + when(this.upstreamBuild.getDownstreamRelationship(this.project)).thenReturn(this.rangeset); createPreviousNextRelationShip(this.previousBuildUpstreamBuild, this.upstreamBuildBetweenPreviousAndCurrent, this.upstreamBuild); From fbff13b09a2b4a790d56bc36a34a5ff4867e4622 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 24 May 2023 12:45:07 +0200 Subject: [PATCH 3/6] IMPublisherTest: before(): mock toString() of projects and builds to help make sense of them in debugger --- src/test/java/hudson/plugins/im/IMPublisherTest.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/test/java/hudson/plugins/im/IMPublisherTest.java b/src/test/java/hudson/plugins/im/IMPublisherTest.java index 092a3c6..a371a7a 100644 --- a/src/test/java/hudson/plugins/im/IMPublisherTest.java +++ b/src/test/java/hudson/plugins/im/IMPublisherTest.java @@ -61,18 +61,23 @@ public void before() throws IOException { this.imPublisher = new IMTestPublisher(); this.upstreamProject = mock(AbstractProject.class); + when(this.upstreamProject.toString()).thenReturn("mock.upstreamProject"); this.project = mock(AbstractProject.class); + when(this.project.toString()).thenReturn("mock.project"); when(project.getScm()).thenReturn(new NullSCM()); this.rangeset = RangeSet.fromString(buildNumber + "-" + (buildNumber + 2), false); this.previousBuildUpstreamBuild = mock(AbstractBuild.class); + when(this.previousBuildUpstreamBuild.toString()).thenReturn("mock.previousBuildUpstreamBuild"); when(this.previousBuildUpstreamBuild.getParent()).thenReturn(project); this.upstreamBuildBetweenPreviousAndCurrent = mock(AbstractBuild.class); + when(this.upstreamBuildBetweenPreviousAndCurrent.toString()).thenReturn("mock.upstreamBuildBetweenPreviousAndCurrent"); when(this.upstreamBuildBetweenPreviousAndCurrent.getDownstreamRelationship(this.project)).thenReturn(this.rangeset); this.upstreamBuild = mock(AbstractBuild.class); + when(this.upstreamBuild.toString()).thenReturn("mock.upstreamBuild"); when(this.upstreamBuild.getDownstreamRelationship(this.project)).thenReturn(this.rangeset); createPreviousNextRelationShip(this.previousBuildUpstreamBuild, this.upstreamBuildBetweenPreviousAndCurrent, @@ -99,10 +104,12 @@ public void before() throws IOException { this.previousBuild = mock(AbstractBuild.class); + when(this.previousBuild.toString()).thenReturn("mock.previousBuild"); when(this.previousBuild.getResult()).thenReturn(Result.SUCCESS); when(this.previousBuild.getUpstreamRelationshipBuild(this.upstreamProject)).thenReturn(this.previousBuildUpstreamBuild); this.build = mock(AbstractBuild.class); + when(this.build.toString()).thenReturn("mock.build"); when(this.build.getResult()).thenReturn(Result.FAILURE); when(this.build.getUpstreamRelationshipBuild(this.upstreamProject)).thenReturn(this.upstreamBuild); Map upstreamBuilds = Maps.newHashMap(); From 0f86c2784aa53f0f56fd9c0dc6ab058ef1f7b36c Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 24 May 2023 13:11:17 +0200 Subject: [PATCH 4/6] IMPublisherTest: before(): mock getProject() explicitly where we earlier mocked just getParent() --- src/test/java/hudson/plugins/im/IMPublisherTest.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/test/java/hudson/plugins/im/IMPublisherTest.java b/src/test/java/hudson/plugins/im/IMPublisherTest.java index a371a7a..9fed79d 100644 --- a/src/test/java/hudson/plugins/im/IMPublisherTest.java +++ b/src/test/java/hudson/plugins/im/IMPublisherTest.java @@ -62,6 +62,7 @@ public void before() throws IOException { this.upstreamProject = mock(AbstractProject.class); when(this.upstreamProject.toString()).thenReturn("mock.upstreamProject"); + this.project = mock(AbstractProject.class); when(this.project.toString()).thenReturn("mock.project"); when(project.getScm()).thenReturn(new NullSCM()); @@ -70,7 +71,8 @@ public void before() throws IOException { this.previousBuildUpstreamBuild = mock(AbstractBuild.class); when(this.previousBuildUpstreamBuild.toString()).thenReturn("mock.previousBuildUpstreamBuild"); - when(this.previousBuildUpstreamBuild.getParent()).thenReturn(project); + when(this.previousBuildUpstreamBuild.getProject()).thenReturn(this.project); // Seems required since https://github.com/jenkinsci/instant-messaging-plugin/pull/171 bump + when(this.previousBuildUpstreamBuild.getParent()).thenReturn(this.project); // => should pop out in AbstractBuild.getProject() this.upstreamBuildBetweenPreviousAndCurrent = mock(AbstractBuild.class); when(this.upstreamBuildBetweenPreviousAndCurrent.toString()).thenReturn("mock.upstreamBuildBetweenPreviousAndCurrent"); @@ -115,7 +117,8 @@ public void before() throws IOException { Map upstreamBuilds = Maps.newHashMap(); upstreamBuilds.put(this.upstreamProject, -1); // number is unimportant, just needed to get the upstream projects when(this.build.getUpstreamBuilds()).thenReturn(upstreamBuilds); - when(this.build.getParent()).thenReturn(this.project); + when(this.build.getProject()).thenReturn(this.project); // Seems required since https://github.com/jenkinsci/instant-messaging-plugin/pull/171 bump + when(this.build.getParent()).thenReturn(this.project); // => should pop out in AbstractBuild.getProject() when(this.build.getNumber()).thenReturn(this.buildNumber); createPreviousNextRelationShip(this.previousBuild, this.build); From 05abb720f9a725308da7c7aba2df1ed7eb9d8fe0 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 24 May 2023 13:11:58 +0200 Subject: [PATCH 5/6] IMPublisher: downstreamIsFirstInRangeTriggeredByUpstream(): separate downstreamProject to pass mocked self-tests --- src/main/java/hudson/plugins/im/IMPublisher.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/hudson/plugins/im/IMPublisher.java b/src/main/java/hudson/plugins/im/IMPublisher.java index 899eb80..89913a5 100644 --- a/src/main/java/hudson/plugins/im/IMPublisher.java +++ b/src/main/java/hudson/plugins/im/IMPublisher.java @@ -629,7 +629,8 @@ private List getUpstreamBuilds( //@Bug(6712) private boolean downstreamIsFirstInRangeTriggeredByUpstream( AbstractBuild upstreamBuild, AbstractBuild downstreamBuild) { - RangeSet rangeSet = upstreamBuild.getDownstreamRelationship(downstreamBuild.getProject()); + AbstractProject downstreamProject = downstreamBuild.getProject(); + RangeSet rangeSet = upstreamBuild.getDownstreamRelationship(downstreamProject); if (rangeSet == null || rangeSet.isEmpty()) { // should not happen From bf50da8fd5e18da676b7f96488a385ed3fca5d86 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 24 May 2023 13:22:02 +0200 Subject: [PATCH 6/6] MatrixNotificationTest: before(): mock getProject() explicitly where we earlier mocked just getParent() --- src/test/java/hudson/plugins/im/MatrixNotificationTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/hudson/plugins/im/MatrixNotificationTest.java b/src/test/java/hudson/plugins/im/MatrixNotificationTest.java index 4f7808b..a69d341 100644 --- a/src/test/java/hudson/plugins/im/MatrixNotificationTest.java +++ b/src/test/java/hudson/plugins/im/MatrixNotificationTest.java @@ -48,7 +48,8 @@ public void before() throws InterruptedException, IOException { this.configurationBuild = mock(AbstractBuild.class); AbstractProject project = mock(MatrixConfiguration.class); - when(configurationBuild.getParent()).thenReturn(project); + when(configurationBuild.getProject()).thenReturn(project); // Seems required since https://github.com/jenkinsci/instant-messaging-plugin/pull/171 bump + when(configurationBuild.getParent()).thenReturn(project); // => should pop out in AbstractBuild.getProject() this.parentBuild = mock(MatrixBuild.class); }