Skip to content

Commit

Permalink
Upgrade plugin parent POM from 4.59 to 4.60 (#894)
Browse files Browse the repository at this point in the history
* Upgrade plugin parent POM from 4.59 to 4.60

* Fix NPE
  • Loading branch information
basil authored Apr 19, 2023
1 parent c9a90f8 commit 0afbfea
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 18 deletions.
4 changes: 2 additions & 2 deletions 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.59</version>
<version>4.60</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -175,7 +175,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
78 changes: 62 additions & 16 deletions src/test/java/jenkins/plugins/slack/workflow/SlackSendStepTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockedStatic;
import org.mockito.Mockito;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
Expand All @@ -37,7 +38,6 @@
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -109,7 +109,11 @@ public void testStepOverrides() throws Exception {
slackSendStep.setColor("good");
slackSendStep.setIconEmoji(":+1:");
slackSendStep.setUsername("slack");
SlackSendStep.SlackSendStepExecution stepExecution = spy(new SlackSendStep.SlackSendStepExecution(slackSendStep, stepContextMock));
SlackSendStep.SlackSendStepExecution stepExecution = mock(SlackSendStep.SlackSendStepExecution.class, Mockito.withSettings()
.spiedInstance(new SlackSendStep.SlackSendStepExecution(slackSendStep, stepContextMock))
.useConstructor(slackSendStep, stepContextMock)
.defaultAnswer(Mockito.CALLS_REAL_METHODS));


when(Jenkins.get()).thenReturn(jenkins);

Expand Down Expand Up @@ -149,7 +153,10 @@ public void testStepWithAttachments() throws Exception {
jsonObject.put("author_icon", "Avatar for author");
attachments.add(jsonObject);
step.setAttachments(attachments.toString());
SlackSendStep.SlackSendStepExecution stepExecution = spy(new SlackSendStep.SlackSendStepExecution(step, stepContextMock));
SlackSendStep.SlackSendStepExecution stepExecution = mock(SlackSendStep.SlackSendStepExecution.class, Mockito.withSettings()
.spiedInstance(new SlackSendStep.SlackSendStepExecution(step, stepContextMock))
.useConstructor(step, stepContextMock)
.defaultAnswer(Mockito.CALLS_REAL_METHODS));
((JSONObject) attachments.get(0)).put("fallback", "message");

when(Jenkins.get()).thenReturn(jenkins);
Expand Down Expand Up @@ -191,7 +198,10 @@ public void testStepWithBlocks() throws Exception {

step.setBlocks(Collections.singletonList(blocks));

SlackSendStep.SlackSendStepExecution stepExecution = spy(new SlackSendStep.SlackSendStepExecution(step, stepContextMock));
SlackSendStep.SlackSendStepExecution stepExecution = mock(SlackSendStep.SlackSendStepExecution.class, Mockito.withSettings()
.spiedInstance(new SlackSendStep.SlackSendStepExecution(step, stepContextMock))
.useConstructor(step, stepContextMock)
.defaultAnswer(Mockito.CALLS_REAL_METHODS));

when(Jenkins.get()).thenReturn(jenkins);

Expand Down Expand Up @@ -248,7 +258,10 @@ public void testStepWithAttachmentsAndBlocks() throws Exception {

step.setBlocks(Collections.singletonList(blocks));

SlackSendStep.SlackSendStepExecution stepExecution = spy(new SlackSendStep.SlackSendStepExecution(step, stepContextMock));
SlackSendStep.SlackSendStepExecution stepExecution = mock(SlackSendStep.SlackSendStepExecution.class, Mockito.withSettings()
.spiedInstance(new SlackSendStep.SlackSendStepExecution(step, stepContextMock))
.useConstructor(step, stepContextMock)
.defaultAnswer(Mockito.CALLS_REAL_METHODS));
((JSONObject) attachments.get(0)).put("fallback", "message");

when(Jenkins.get()).thenReturn(jenkins);
Expand Down Expand Up @@ -296,7 +309,10 @@ public void testStepWithAttachmentsAsListOfMap() throws Exception {
attachment1.put("author_icon", "Avatar for author");

step.setAttachments(Collections.singletonList(attachment1));
SlackSendStep.SlackSendStepExecution stepExecution = spy(new SlackSendStep.SlackSendStepExecution(step, stepContextMock));
SlackSendStep.SlackSendStepExecution stepExecution = mock(SlackSendStep.SlackSendStepExecution.class, Mockito.withSettings()
.spiedInstance(new SlackSendStep.SlackSendStepExecution(step, stepContextMock))
.useConstructor(step, stepContextMock)
.defaultAnswer(Mockito.CALLS_REAL_METHODS));

when(Jenkins.get()).thenReturn(jenkins);

Expand Down Expand Up @@ -333,7 +349,10 @@ public void testValuesForGlobalConfig() throws Exception {
SlackSendStep step = new SlackSendStep();
step.setMessage("message");

SlackSendStep.SlackSendStepExecution stepExecution = spy(new SlackSendStep.SlackSendStepExecution(step, stepContextMock));
SlackSendStep.SlackSendStepExecution stepExecution = mock(SlackSendStep.SlackSendStepExecution.class, Mockito.withSettings()
.spiedInstance(new SlackSendStep.SlackSendStepExecution(step, stepContextMock))
.useConstructor(step, stepContextMock)
.defaultAnswer(Mockito.CALLS_REAL_METHODS));

when(Jenkins.get()).thenReturn(jenkins);

Expand Down Expand Up @@ -369,7 +388,10 @@ public void testCanGetItemFromRun() throws Exception {
SlackSendStep step = new SlackSendStep();
step.setMessage("message");

SlackSendStep.SlackSendStepExecution stepExecution = spy(new SlackSendStep.SlackSendStepExecution(step, stepContextMock));
SlackSendStep.SlackSendStepExecution stepExecution = mock(SlackSendStep.SlackSendStepExecution.class, Mockito.withSettings()
.spiedInstance(new SlackSendStep.SlackSendStepExecution(step, stepContextMock))
.useConstructor(step, stepContextMock)
.defaultAnswer(Mockito.CALLS_REAL_METHODS));
when(Jenkins.get()).thenReturn(jenkins);
when(run.getParent()).thenReturn(project);

Expand Down Expand Up @@ -404,7 +426,10 @@ public void testReplyBroadcast() throws Exception {
step.setMessage("message");
step.setReplyBroadcast(true);

SlackSendStep.SlackSendStepExecution stepExecution = spy(new SlackSendStep.SlackSendStepExecution(step, stepContextMock));
SlackSendStep.SlackSendStepExecution stepExecution = mock(SlackSendStep.SlackSendStepExecution.class, Mockito.withSettings()
.spiedInstance(new SlackSendStep.SlackSendStepExecution(step, stepContextMock))
.useConstructor(step, stepContextMock)
.defaultAnswer(Mockito.CALLS_REAL_METHODS));

when(Jenkins.get()).thenReturn(jenkins);

Expand Down Expand Up @@ -440,7 +465,10 @@ public void testSendAsText() throws Exception {
step.setMessage("message");
step.setSendAsText(true);

SlackSendStep.SlackSendStepExecution stepExecution = spy(new SlackSendStep.SlackSendStepExecution(step, stepContextMock));
SlackSendStep.SlackSendStepExecution stepExecution = mock(SlackSendStep.SlackSendStepExecution.class, Mockito.withSettings()
.spiedInstance(new SlackSendStep.SlackSendStepExecution(step, stepContextMock))
.useConstructor(step, stepContextMock)
.defaultAnswer(Mockito.CALLS_REAL_METHODS));

when(Jenkins.get()).thenReturn(jenkins);

Expand Down Expand Up @@ -476,7 +504,10 @@ public void testIconEmoji() throws Exception {
step.setMessage("message");
step.setIconEmoji(":+1:");

SlackSendStep.SlackSendStepExecution stepExecution = spy(new SlackSendStep.SlackSendStepExecution(step, stepContextMock));
SlackSendStep.SlackSendStepExecution stepExecution = mock(SlackSendStep.SlackSendStepExecution.class, Mockito.withSettings()
.spiedInstance(new SlackSendStep.SlackSendStepExecution(step, stepContextMock))
.useConstructor(step, stepContextMock)
.defaultAnswer(Mockito.CALLS_REAL_METHODS));

when(Jenkins.get()).thenReturn(jenkins);

Expand Down Expand Up @@ -511,7 +542,10 @@ public void testUsername() throws Exception {
step.setMessage("message");
step.setUsername("username");

SlackSendStep.SlackSendStepExecution stepExecution = spy(new SlackSendStep.SlackSendStepExecution(step, stepContextMock));
SlackSendStep.SlackSendStepExecution stepExecution = mock(SlackSendStep.SlackSendStepExecution.class, Mockito.withSettings()
.spiedInstance(new SlackSendStep.SlackSendStepExecution(step, stepContextMock))
.useConstructor(step, stepContextMock)
.defaultAnswer(Mockito.CALLS_REAL_METHODS));

when(Jenkins.get()).thenReturn(jenkins);

Expand Down Expand Up @@ -547,7 +581,10 @@ public void testTimestamp() throws Exception {
step.setUsername("username");
step.setTimestamp("1241242.124124");

SlackSendStep.SlackSendStepExecution stepExecution = spy(new SlackSendStep.SlackSendStepExecution(step, stepContextMock));
SlackSendStep.SlackSendStepExecution stepExecution = mock(SlackSendStep.SlackSendStepExecution.class, Mockito.withSettings()
.spiedInstance(new SlackSendStep.SlackSendStepExecution(step, stepContextMock))
.useConstructor(step, stepContextMock)
.defaultAnswer(Mockito.CALLS_REAL_METHODS));

when(Jenkins.get()).thenReturn(jenkins);

Expand Down Expand Up @@ -586,7 +623,10 @@ public void testNonNullEmptyColor() throws Exception {
step.setTeamDomain("teamDomain");
step.setChannel("channel");

SlackSendStep.SlackSendStepExecution stepExecution = spy(new SlackSendStep.SlackSendStepExecution(step, stepContextMock));
SlackSendStep.SlackSendStepExecution stepExecution = mock(SlackSendStep.SlackSendStepExecution.class, Mockito.withSettings()
.spiedInstance(new SlackSendStep.SlackSendStepExecution(step, stepContextMock))
.useConstructor(step, stepContextMock)
.defaultAnswer(Mockito.CALLS_REAL_METHODS));

when(Jenkins.get()).thenReturn(jenkins);

Expand Down Expand Up @@ -616,7 +656,10 @@ public void testSlackResponseObject() throws Exception {
step.setChannel("channel");
step.setColor("good");

SlackSendStep.SlackSendStepExecution stepExecution = spy(new SlackSendStep.SlackSendStepExecution(step, stepContextMock));
SlackSendStep.SlackSendStepExecution stepExecution = mock(SlackSendStep.SlackSendStepExecution.class, Mockito.withSettings()
.spiedInstance(new SlackSendStep.SlackSendStepExecution(step, stepContextMock))
.useConstructor(step, stepContextMock)
.defaultAnswer(Mockito.CALLS_REAL_METHODS));

when(Jenkins.get()).thenReturn(jenkins);

Expand Down Expand Up @@ -659,7 +702,10 @@ public void testSlackResponseObjectNullNonBotUser() throws Exception {
step.setChannel("channel");
step.setColor("good");

SlackSendStep.SlackSendStepExecution stepExecution = spy(new SlackSendStep.SlackSendStepExecution(step, stepContextMock));
SlackSendStep.SlackSendStepExecution stepExecution = mock(SlackSendStep.SlackSendStepExecution.class, Mockito.withSettings()
.spiedInstance(new SlackSendStep.SlackSendStepExecution(step, stepContextMock))
.useConstructor(step, stepContextMock)
.defaultAnswer(Mockito.CALLS_REAL_METHODS));

when(Jenkins.get()).thenReturn(jenkins);

Expand Down

0 comments on commit 0afbfea

Please sign in to comment.