Skip to content

Commit

Permalink
Merge pull request #171 from jenkinsci/dependabot/maven/org.jenkins-c…
Browse files Browse the repository at this point in the history
…i.plugins-plugin-4.64

build(deps): bump plugin from 4.54 to 4.64
  • Loading branch information
jimklimov authored May 24, 2023
2 parents 8b1df67 + bf50da8 commit e71a06c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.54</version>
<version>4.64</version>
<relativePath />
</parent>

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/hudson/plugins/im/IMPublisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,8 @@ private List<AbstractBuild> 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
Expand Down
21 changes: 16 additions & 5 deletions src/test/java/hudson/plugins/im/IMPublisherTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class IMPublisherTest {
private AbstractProject project;
private AbstractProject upstreamProject;
private BuildListener listener;
private RangeSet rangeset;

@SuppressWarnings("unchecked")
@Before
Expand All @@ -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);
Expand All @@ -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<AbstractProject, Integer> 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);
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/hudson/plugins/im/MatrixNotificationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit e71a06c

Please sign in to comment.