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 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 diff --git a/src/test/java/hudson/plugins/im/IMPublisherTest.java b/src/test/java/hudson/plugins/im/IMPublisherTest.java index 92afed1..9fed79d 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 @@ -60,19 +61,26 @@ 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()); - 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); + when(this.previousBuildUpstreamBuild.toString()).thenReturn("mock.previousBuildUpstreamBuild"); + 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.getDownstreamRelationship(this.project)).thenReturn(rangeset); + when(this.upstreamBuildBetweenPreviousAndCurrent.toString()).thenReturn("mock.upstreamBuildBetweenPreviousAndCurrent"); + 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.toString()).thenReturn("mock.upstreamBuild"); + when(this.upstreamBuild.getDownstreamRelationship(this.project)).thenReturn(this.rangeset); createPreviousNextRelationShip(this.previousBuildUpstreamBuild, this.upstreamBuildBetweenPreviousAndCurrent, this.upstreamBuild); @@ -98,16 +106,19 @@ 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(); 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); 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); }