diff --git a/pom.xml b/pom.xml
index c12a9e5..d1243e5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,6 +14,10 @@
https://github.com/jenkinsci/badge-plugin
+
+ strangelookingnerd
+ Daniel Krämer
+
bakito
Marc Brugger
@@ -129,6 +133,16 @@
io.jenkins.plugins
ionicons-api
+
+ org.jenkins-ci.plugins
+ jackson2-api
+ test
+
+
+ io.jenkins.plugins
+ commons-lang3-api
+ test
+
org.jenkins-ci.plugins.workflow
workflow-cps
@@ -150,11 +164,6 @@
workflow-job
test
-
- org.jenkins-ci.plugins
- junit
- test
-
com.hubspot.jinjava
diff --git a/src/test/java/com/jenkinsci/plugins/badge/action/AbstractActionTest.java b/src/test/java/com/jenkinsci/plugins/badge/action/AbstractActionTest.java
index 052f377..2e06e4c 100644
--- a/src/test/java/com/jenkinsci/plugins/badge/action/AbstractActionTest.java
+++ b/src/test/java/com/jenkinsci/plugins/badge/action/AbstractActionTest.java
@@ -1,28 +1,31 @@
package com.jenkinsci.plugins.badge.action;
-import static org.junit.jupiter.api.Assertions.*;
-
import org.junit.jupiter.api.Test;
+import org.jvnet.hudson.test.JenkinsRule;
+import org.jvnet.hudson.test.junit.jupiter.WithJenkins;
+
+import static org.junit.jupiter.api.Assertions.*;
+@WithJenkins
class AbstractActionTest {
@Test
- void isJenkinsSymbolRef() {
+ void isJenkinsSymbolRef(@SuppressWarnings("unused") JenkinsRule r) {
assertTrue(AbstractAction.isJenkinsSymbolRef("symbol-cube"));
assertFalse(AbstractAction.isJenkinsSymbolRef("info.gif"));
}
@Test
- void getJenkinsColorClass() {
+ void getJenkinsColorClass(@SuppressWarnings("unused") JenkinsRule r) {
assertNull(AbstractAction.getJenkinsColorClass(null));
assertNull(AbstractAction.getJenkinsColorClass(""));
assertNull(AbstractAction.getJenkinsColorClass("teal"));
assertNull(AbstractAction.getJenkinsColorClass("burlywood"));
assertNull(AbstractAction.getJenkinsColorClass("light-"));
assertNull(AbstractAction.getJenkinsColorClass("dark-"));
- assertEquals(AbstractAction.getJenkinsColorClass("blue"), "jenkins-!-color-blue");
- assertEquals(AbstractAction.getJenkinsColorClass("light-blue"), "jenkins-!-color-light-blue");
- assertEquals(AbstractAction.getJenkinsColorClass("dark-blue"), "jenkins-!-color-dark-blue");
- assertEquals(AbstractAction.getJenkinsColorClass("danger"), "jenkins-!-danger-color");
+ assertEquals("jenkins-!-color-blue", AbstractAction.getJenkinsColorClass("blue"));
+ assertEquals("jenkins-!-color-light-blue", AbstractAction.getJenkinsColorClass("light-blue"));
+ assertEquals("jenkins-!-color-dark-blue", AbstractAction.getJenkinsColorClass("dark-blue"));
+ assertEquals("jenkins-!-danger-color", AbstractAction.getJenkinsColorClass("danger"));
}
}
diff --git a/src/test/java/com/jenkinsci/plugins/badge/action/BadgeActionTest.java b/src/test/java/com/jenkinsci/plugins/badge/action/BadgeActionTest.java
index ebb80be..acaec67 100644
--- a/src/test/java/com/jenkinsci/plugins/badge/action/BadgeActionTest.java
+++ b/src/test/java/com/jenkinsci/plugins/badge/action/BadgeActionTest.java
@@ -2,20 +2,19 @@
import hudson.model.Hudson;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.jvnet.hudson.test.JenkinsRule;
+import org.jvnet.hudson.test.junit.jupiter.WithJenkins;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
-public class BadgeActionTest {
- @Rule
- public JenkinsRule r = new JenkinsRule();
+@WithJenkins
+class BadgeActionTest {
@Test
- public void getIconPath() {
+ void getIconPath(@SuppressWarnings("unused") JenkinsRule r) {
assertNull(BadgeAction.getIconPath(null));
assertEquals("/icon.png", BadgeAction.getIconPath("/icon.png"));
assertEquals("http://foo.com/icon.png", BadgeAction.getIconPath("http://foo.com/icon.png"));
@@ -27,35 +26,35 @@ public void getIconPath() {
}
@Test
- public void getIconClass() {
+ void getIconClass(@SuppressWarnings("unused") JenkinsRule r) {
BadgeAction action = BadgeAction.createBadge("info.gif", "text");
assertEquals("", action.getIconClass());
- action = BadgeAction.createBadge("symbol-star", "text");
+ action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "text");
assertEquals("icon-sm", action.getIconClass());
- action = BadgeAction.createBadge("symbol-star", "#000000", "", null);
+ action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "#000000", "", null);
assertEquals("icon-sm", action.getIconClass());
- action = BadgeAction.createBadge("symbol-star", "blue", "", null);
+ action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "blue", "", null);
assertEquals("icon-sm jenkins-!-color-blue", action.getIconClass());
action = BadgeAction.createBadge("/foo/symbol-star.gif", "blue", "", null);
assertEquals("jenkins-!-color-blue", action.getIconClass());
// teal is not in the palette
- action = BadgeAction.createBadge("symbol-star", "teal", "", null);
+ action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "teal", "", null);
assertEquals("icon-sm", action.getIconClass());
}
@Test
- public void getIconColorStyle() {
+ void getIconColorStyle(@SuppressWarnings("unused") JenkinsRule r) {
BadgeAction action = BadgeAction.createBadge("info.gif", "text");
assertNull(action.getIconColorStyle());
- action = BadgeAction.createBadge("symbol-star", "#000000", "", null);
+ action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "#000000", "", null);
assertEquals("#000000", action.getIconColorStyle());
- action = BadgeAction.createBadge("symbol-star", "var(--yellow)", "", null);
+ action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "var(--yellow)", "", null);
assertEquals("var(--yellow)", action.getIconColorStyle());
- action = BadgeAction.createBadge("symbol-star", "jenkins-!-color-blue", "", null);
+ action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "jenkins-!-color-blue", "", null);
assertNull(action.getIconColorStyle());
- action = BadgeAction.createBadge("symbol-star", "blue", "", null);
+ action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "blue", "", null);
assertNull(action.getIconColorStyle());
- action = BadgeAction.createBadge("symbol-star", "teal", "", null);
+ action = BadgeAction.createBadge("symbol-star plugin-ionicons-api", "teal", "", null);
assertEquals("teal", action.getIconColorStyle());
}
diff --git a/src/test/java/com/jenkinsci/plugins/badge/action/ClassHierarchyTest.java b/src/test/java/com/jenkinsci/plugins/badge/action/ClassHierarchyTest.java
index a482c31..d4225cc 100644
--- a/src/test/java/com/jenkinsci/plugins/badge/action/ClassHierarchyTest.java
+++ b/src/test/java/com/jenkinsci/plugins/badge/action/ClassHierarchyTest.java
@@ -25,15 +25,16 @@
import hudson.model.Action;
import hudson.model.BuildBadgeAction;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-public class ClassHierarchyTest {
+
+class ClassHierarchyTest {
@Test
- public void badgeSummaryAction() {
+ void badgeSummaryAction() {
assertTrue(Action.class.isAssignableFrom(BadgeSummaryAction.class));
assertTrue(AbstractAction.class.isAssignableFrom(BadgeSummaryAction.class));
@@ -42,7 +43,7 @@ public void badgeSummaryAction() {
}
@Test
- public void badgeAction() {
+ void badgeAction() {
assertTrue(Action.class.isAssignableFrom(BadgeAction.class));
assertTrue(AbstractAction.class.isAssignableFrom(BadgeAction.class));
@@ -51,7 +52,7 @@ public void badgeAction() {
}
@Test
- public void htmlBadgeAction() {
+ void htmlBadgeAction() {
assertTrue(Action.class.isAssignableFrom(HtmlBadgeAction.class));
assertTrue(AbstractAction.class.isAssignableFrom(HtmlBadgeAction.class));
diff --git a/src/test/java/com/jenkinsci/plugins/badge/dsl/AbstractBadgeTest.java b/src/test/java/com/jenkinsci/plugins/badge/dsl/AbstractBadgeTest.java
index def5a27..8f9c301 100644
--- a/src/test/java/com/jenkinsci/plugins/badge/dsl/AbstractBadgeTest.java
+++ b/src/test/java/com/jenkinsci/plugins/badge/dsl/AbstractBadgeTest.java
@@ -23,16 +23,10 @@
*/
package com.jenkinsci.plugins.badge.dsl;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.jvnet.hudson.test.BuildWatcher;
-import org.jvnet.hudson.test.JenkinsRule;
+import org.jvnet.hudson.test.junit.jupiter.WithJenkins;
-public abstract class AbstractBadgeTest {
- @ClassRule
- public static BuildWatcher buildWatcher = new BuildWatcher();
- @Rule
- public JenkinsRule r = new JenkinsRule();
+@WithJenkins
+abstract class AbstractBadgeTest {
}
diff --git a/src/test/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStepTest.java b/src/test/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStepTest.java
index 44957f5..af868af 100644
--- a/src/test/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStepTest.java
+++ b/src/test/java/com/jenkinsci/plugins/badge/dsl/AddBadgeStepTest.java
@@ -29,26 +29,77 @@
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.jvnet.hudson.test.JenkinsRule;
import java.util.List;
import java.util.UUID;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-public class AddBadgeStepTest extends AbstractBadgeTest {
+
+class AddBadgeStepTest extends AbstractBadgeTest {
+
+ @Test
+ void addBadge(JenkinsRule r) throws Exception {
+ addBadge(r, false);
+ }
+
+ @Test
+ void addBadge_in_node(JenkinsRule r) throws Exception {
+ addBadge(r, true);
+ }
+
+ @Test
+ void addInfoBadge(JenkinsRule r) throws Exception {
+ addStatusBadge(r, "addInfoBadge", "symbol-information-circle plugin-ionicons-api", false);
+ addStatusBadge(r,"addInfoBadge", "symbol-information-circle plugin-ionicons-api", true);
+ }
@Test
- public void addBadge() throws Exception {
- addBadge(false);
+ void addWarningBadge(JenkinsRule r) throws Exception {
+ addStatusBadge(r,"addWarningBadge", "symbol-warning plugin-ionicons-api", false);
+ addStatusBadge(r,"addWarningBadge", "symbol-warning plugin-ionicons-api", true);
}
@Test
- public void addBadge_in_node() throws Exception {
- addBadge(true);
+ void addErrorBadge(JenkinsRule r) throws Exception {
+ addStatusBadge(r, "addErrorBadge", "symbol-remove-circle plugin-ionicons-api", false);
+ addStatusBadge(r, "addErrorBadge", "symbol-remove-circle plugin-ionicons-api", true);
+ }
+
+ @Test
+ void addBadge_invalid_link(JenkinsRule r) throws Exception {
+ String icon = UUID.randomUUID().toString();
+ String text = UUID.randomUUID().toString();
+ String link = "javascript:" + UUID.randomUUID();
+ WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
+
+ String script = "addBadge(icon:\"" + icon + "\", text:\"" + text + "\", link:\"" + link + "\")";
+ p.setDefinition(new CpsFlowDefinition(script, true));
+ r.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0));
+ }
+
+ @Test
+ void addBadge_invalid_text(JenkinsRule r) throws Exception {
+ String icon = UUID.randomUUID().toString();
+ String textPrefix = UUID.randomUUID().toString();
+ String text = textPrefix + "');alert('foo";
+ WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
+
+ String script = "addBadge(icon: '" + icon + "', text:\"" + text + "\")";
+ p.setDefinition(new CpsFlowDefinition(script, true));
+ WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
+
+ List badgeActions = b.getBadgeActions();
+ assertEquals(1, badgeActions.size());
+
+ BadgeAction action = (BadgeAction) badgeActions.get(0);
+ assertTrue(action.getIconPath().endsWith(icon));
+ assertEquals(textPrefix + "');alert('foo", action.getText());
}
- private void addBadge(boolean inNode) throws Exception {
+ private void addBadge(JenkinsRule r, boolean inNode) throws Exception {
String icon = UUID.randomUUID().toString();
String text = UUID.randomUUID().toString();
String link = "https://" + UUID.randomUUID();
@@ -71,25 +122,7 @@ private void addBadge(boolean inNode) throws Exception {
assertEquals(link, action.getLink());
}
- @Test
- public void addInfoBadge() throws Exception {
- addStatusBadge("addInfoBadge", "symbol-information-circle plugin-ionicons-api", false);
- addStatusBadge("addInfoBadge", "symbol-information-circle plugin-ionicons-api", true);
- }
-
- @Test
- public void addWarningBadge() throws Exception {
- addStatusBadge("addWarningBadge", "symbol-warning plugin-ionicons-api", false);
- addStatusBadge("addWarningBadge", "symbol-warning plugin-ionicons-api", true);
- }
-
- @Test
- public void addErrorBadge() throws Exception {
- addStatusBadge("addErrorBadge", "symbol-remove-circle plugin-ionicons-api", false);
- addStatusBadge("addErrorBadge", "symbol-remove-circle plugin-ionicons-api", true);
- }
-
- private void addStatusBadge(String functionName, String expectedIcon, boolean withLink) throws Exception {
+ private void addStatusBadge(JenkinsRule r, String functionName, String expectedIcon, boolean withLink) throws Exception {
String text = UUID.randomUUID().toString();
String link = "mailto://" + UUID.randomUUID();
@@ -107,42 +140,11 @@ private void addStatusBadge(String functionName, String expectedIcon, boolean wi
BadgeAction action = (BadgeAction) badgeActions.get(0);
assertEquals(text, action.getText());
- assertTrue("expect " + action.getIconPath() + " ends with " + expectedIcon, action.getIconPath().endsWith(expectedIcon));
+ assertTrue(action.getIconPath().endsWith(expectedIcon));
if (withLink) {
assertEquals(link, action.getLink());
} else {
assertNull(action.getLink());
}
}
-
- @Test
- public void addBadge_invalid_link() throws Exception {
- String icon = UUID.randomUUID().toString();
- String text = UUID.randomUUID().toString();
- String link = "javascript:" + UUID.randomUUID();
- WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
-
- String script = "addBadge(icon:\"" + icon + "\", text:\"" + text + "\", link:\"" + link + "\")";
- p.setDefinition(new CpsFlowDefinition(script, true));
- r.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0));
- }
-
- @Test
- public void addBadge_invalid_text() throws Exception {
- String icon = UUID.randomUUID().toString();
- String textPrefix = UUID.randomUUID().toString();
- String text = textPrefix + "');alert('foo";
- WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
-
- String script = "addBadge(icon: '" + icon + "', text:\"" + text + "\")";
- p.setDefinition(new CpsFlowDefinition(script, true));
- WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
-
- List badgeActions = b.getBadgeActions();
- assertEquals(1, badgeActions.size());
-
- BadgeAction action = (BadgeAction) badgeActions.get(0);
- assertTrue(action.getIconPath().endsWith(icon));
- assertEquals(textPrefix + "');alert('foo", action.getText());
- }
}
diff --git a/src/test/java/com/jenkinsci/plugins/badge/dsl/AddHtmlBadgeStepTest.java b/src/test/java/com/jenkinsci/plugins/badge/dsl/AddHtmlBadgeStepTest.java
index 22b50c0..a23642b 100644
--- a/src/test/java/com/jenkinsci/plugins/badge/dsl/AddHtmlBadgeStepTest.java
+++ b/src/test/java/com/jenkinsci/plugins/badge/dsl/AddHtmlBadgeStepTest.java
@@ -28,30 +28,31 @@
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.jvnet.hudson.test.JenkinsRule;
import java.util.List;
import java.util.UUID;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-public class AddHtmlBadgeStepTest extends AbstractBadgeTest {
+
+class AddHtmlBadgeStepTest extends AbstractBadgeTest {
@Test
- public void addHtmlBadge() throws Exception {
+ void addHtmlBadge(JenkinsRule r) throws Exception {
String html = UUID.randomUUID().toString();
- testAddHtmlBadge(html, html);
+ testAddHtmlBadge(r, html, html);
}
@Test
- public void addHtmlBadge_remove_script() throws Exception {
+ void addHtmlBadge_remove_script(JenkinsRule r) throws Exception {
String uuid = UUID.randomUUID().toString();
String html = uuid + "";
- testAddHtmlBadge(html, uuid);
+ testAddHtmlBadge(r, html, uuid);
}
-
- private void testAddHtmlBadge(String html, String expected) throws Exception {
+ private void testAddHtmlBadge(JenkinsRule r, String html, String expected) throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
String script = "addHtmlBadge(\"" + html + "\")";
diff --git a/src/test/java/com/jenkinsci/plugins/badge/dsl/CreateSummaryStepTest.java b/src/test/java/com/jenkinsci/plugins/badge/dsl/CreateSummaryStepTest.java
index 1f750f3..f4fe052 100644
--- a/src/test/java/com/jenkinsci/plugins/badge/dsl/CreateSummaryStepTest.java
+++ b/src/test/java/com/jenkinsci/plugins/badge/dsl/CreateSummaryStepTest.java
@@ -27,80 +27,82 @@
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.jvnet.hudson.test.JenkinsRule;
import java.util.List;
import static java.util.UUID.randomUUID;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-public class CreateSummaryStepTest extends AbstractBadgeTest {
+
+class CreateSummaryStepTest extends AbstractBadgeTest {
@Test
- public void createSummary_plain() throws Exception {
+ void createSummary_plain(JenkinsRule r) throws Exception {
String text = randomUUID().toString();
- BadgeSummaryAction action = createSummary("summary.appendText('" + text + "')");
+ BadgeSummaryAction action = createSummary(r, "summary.appendText('" + text + "')");
assertEquals(text, action.getText());
}
@Test
- public void createSummary_html_unescaped() throws Exception {
+ void createSummary_html_unescaped(JenkinsRule r) throws Exception {
String text = randomUUID().toString();
- BadgeSummaryAction action = createSummary("summary.appendText('', false)");
+ BadgeSummaryAction action = createSummary(r, "summary.appendText('', false)");
assertEquals("", action.getText());
}
@Test
- public void createSummary_html_unescaped_remove_script() throws Exception {
+ void createSummary_html_unescaped_remove_script(JenkinsRule r) throws Exception {
String text = randomUUID().toString();
String html = "";
- BadgeSummaryAction action = createSummary("summary.appendText('" + html + "', false);");
+ BadgeSummaryAction action = createSummary(r, "summary.appendText('" + html + "', false);");
assertEquals("", action.getText());
assertEquals(html, action.getRawText());
}
@Test
- public void createSummary_html_escaped() throws Exception {
+ void createSummary_html_escaped(JenkinsRule r) throws Exception {
String text = randomUUID().toString();
- BadgeSummaryAction action = createSummary("summary.appendText('', true)");
+ BadgeSummaryAction action = createSummary(r, "summary.appendText('', true)");
assertEquals("<ul><li>" + text + "</li></ul>", action.getText());
}
@Test
- public void createSummary_all() throws Exception {
+ void createSummary_all(JenkinsRule r) throws Exception {
String text = randomUUID().toString();
- BadgeSummaryAction action = createSummary("summary.appendText('" + text + "', false, true, true, 'grey')");
+ BadgeSummaryAction action = createSummary(r, "summary.appendText('" + text + "', false, true, true, 'grey')");
assertEquals("" + text + "", action.getText());
}
- private BadgeSummaryAction createSummary(String script) throws Exception {
+ @Test
+ void createSummary_with_text(JenkinsRule r) throws Exception {
String icon = randomUUID().toString();
+ String text = randomUUID().toString();
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
- p.setDefinition(new CpsFlowDefinition("def summary = createSummary(\"" + icon + "\")\n" + script, true));
+ p.setDefinition(new CpsFlowDefinition("def summary = createSummary(icon:\"" + icon + "\", text:\"" + text + "\")", true));
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
List summaryActions = b.getActions(BadgeSummaryAction.class);
assertEquals(1, summaryActions.size());
BadgeSummaryAction action = summaryActions.get(0);
assertTrue(action.getIconPath().endsWith(icon));
- return action;
+ assertEquals(text, action.getText());
}
- @Test
- public void createSummary_with_text() throws Exception {
+ private BadgeSummaryAction createSummary(JenkinsRule r, String script) throws Exception {
String icon = randomUUID().toString();
- String text = randomUUID().toString();
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
- p.setDefinition(new CpsFlowDefinition("def summary = createSummary(icon:\"" + icon + "\", text:\"" + text + "\")", true));
+ p.setDefinition(new CpsFlowDefinition("def summary = createSummary(\"" + icon + "\")\n" + script, true));
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
List summaryActions = b.getActions(BadgeSummaryAction.class);
assertEquals(1, summaryActions.size());
BadgeSummaryAction action = summaryActions.get(0);
assertTrue(action.getIconPath().endsWith(icon));
- assertEquals(text, action.getText());
+ return action;
}
}
\ No newline at end of file
diff --git a/src/test/java/com/jenkinsci/plugins/badge/dsl/RemoveBadgesStepTest.java b/src/test/java/com/jenkinsci/plugins/badge/dsl/RemoveBadgesStepTest.java
index 62b2966..d026d11 100644
--- a/src/test/java/com/jenkinsci/plugins/badge/dsl/RemoveBadgesStepTest.java
+++ b/src/test/java/com/jenkinsci/plugins/badge/dsl/RemoveBadgesStepTest.java
@@ -27,35 +27,37 @@
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.jvnet.hudson.test.JenkinsRule;
import java.util.List;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-public class RemoveBadgesStepTest extends AbstractBadgeTest {
+
+class RemoveBadgesStepTest extends AbstractBadgeTest {
@Test
- public void removeBadges_by_id() throws Exception {
- removeBadges("addInfoBadge(text: 'a'", "removeBadges(id:'a')", "b");
+ void removeBadges_by_id(JenkinsRule r) throws Exception {
+ removeBadges(r, "addInfoBadge(text: 'a'", "removeBadges(id:'a')", "b");
}
@Test
- public void removeBadges_all() throws Exception {
- removeBadges("addInfoBadge(text: 'a'", "removeBadges()");
+ void removeBadges_all(JenkinsRule r) throws Exception {
+ removeBadges(r, "addInfoBadge(text: 'a'", "removeBadges()");
}
@Test
- public void removeHtmlBadges_by_id() throws Exception {
- removeBadges("addHtmlBadge(html: 'a'", "removeHtmlBadges(id:'a')", "b");
+ void removeHtmlBadges_by_id(JenkinsRule r) throws Exception {
+ removeBadges(r, "addHtmlBadge(html: 'a'", "removeHtmlBadges(id:'a')", "b");
}
@Test
- public void removeHtmlBadges_all() throws Exception {
- removeBadges("addHtmlBadge(html: 'a'", "removeHtmlBadges()");
+ void removeHtmlBadges_all(JenkinsRule r) throws Exception {
+ removeBadges(r, "addHtmlBadge(html: 'a'", "removeHtmlBadges()");
}
- private void removeBadges(String badgeScriptPrefix, String removeScript, String... remainingBadgeIds) throws Exception {
+ private void removeBadges(JenkinsRule r, String badgeScriptPrefix, String removeScript, String... remainingBadgeIds) throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
String script = badgeScriptPrefix + ", id: 'a')\n" +
badgeScriptPrefix + ", id: 'b')\n" +
@@ -71,6 +73,5 @@ private void removeBadges(String badgeScriptPrefix, String removeScript, String.
for (int i = 0; i < remainingBadgeIds.length; i++) {
assertEquals(remainingBadgeIds[i], badgeActions.get(i).getId());
}
-
}
}
diff --git a/src/test/java/com/jenkinsci/plugins/badge/dsl/RemoveSummariesStepTest.java b/src/test/java/com/jenkinsci/plugins/badge/dsl/RemoveSummariesStepTest.java
index 1436af2..1baf6a8 100644
--- a/src/test/java/com/jenkinsci/plugins/badge/dsl/RemoveSummariesStepTest.java
+++ b/src/test/java/com/jenkinsci/plugins/badge/dsl/RemoveSummariesStepTest.java
@@ -27,27 +27,27 @@
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.jvnet.hudson.test.JenkinsRule;
import java.util.List;
import static java.util.UUID.randomUUID;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-public class RemoveSummariesStepTest extends AbstractBadgeTest {
+class RemoveSummariesStepTest extends AbstractBadgeTest {
@Test
- public void removeSummaries_by_id() throws Exception {
- removeSummaries("removeSummaries(id:'a')", "b");
+ void removeSummaries_by_id(JenkinsRule r) throws Exception {
+ removeSummaries(r, "removeSummaries(id:'a')", "b");
}
@Test
- public void removeSummaries_all() throws Exception {
- removeSummaries("removeSummaries()");
+ void removeSummaries_all(JenkinsRule r) throws Exception {
+ removeSummaries(r, "removeSummaries()");
}
-
- private void removeSummaries(String removeScript, String... remainingBadgeIds) throws Exception {
+ private void removeSummaries(JenkinsRule r, String removeScript, String... remainingBadgeIds) throws Exception {
String icon = randomUUID().toString();
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
diff --git a/src/test/java/com/jenkinsci/plugins/badge/dsl/ShortTextStepTest.java b/src/test/java/com/jenkinsci/plugins/badge/dsl/ShortTextStepTest.java
index 27a8f94..82cb379 100644
--- a/src/test/java/com/jenkinsci/plugins/badge/dsl/ShortTextStepTest.java
+++ b/src/test/java/com/jenkinsci/plugins/badge/dsl/ShortTextStepTest.java
@@ -24,24 +24,25 @@
package com.jenkinsci.plugins.badge.dsl;
import com.jenkinsci.plugins.badge.action.BadgeAction;
-import hudson.model.Action;
import hudson.model.BuildBadgeAction;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.jvnet.hudson.test.JenkinsRule;
import java.util.List;
import java.util.Random;
import java.util.UUID;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
-public class ShortTextStepTest extends AbstractBadgeTest {
+
+class ShortTextStepTest extends AbstractBadgeTest {
@Test
- public void addShortText() throws Exception {
+ void addShortText(JenkinsRule r) throws Exception {
String text = UUID.randomUUID().toString();
String color = UUID.randomUUID().toString();
String background = UUID.randomUUID().toString();
@@ -54,7 +55,6 @@ public void addShortText() throws Exception {
+ borderColor + "\", link:\"" + link + "\")", true));
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
- List extends Action> allActions = b.getAllActions();
List badgeActions = b.getBadgeActions();
assertEquals(1, badgeActions.size());
@@ -69,7 +69,7 @@ public void addShortText() throws Exception {
}
@Test
- public void addShortText_minimal() throws Exception {
+ void addShortText_minimal(JenkinsRule r) throws Exception {
String text = UUID.randomUUID().toString();
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");