diff --git a/src/test/java/org/jvnet/hudson/plugins/groovypostbuild/GroovyPostbuildRecorderTest.java b/src/test/java/org/jvnet/hudson/plugins/groovypostbuild/GroovyPostbuildRecorderTest.java index 8aaaec1..fecbd31 100644 --- a/src/test/java/org/jvnet/hudson/plugins/groovypostbuild/GroovyPostbuildRecorderTest.java +++ b/src/test/java/org/jvnet/hudson/plugins/groovypostbuild/GroovyPostbuildRecorderTest.java @@ -75,10 +75,14 @@ public class GroovyPostbuildRecorderTest { "import hudson.matrix.MatrixRun;", "if (manager.buildIsA(MatrixBuild.class)) {", " // codes for matrix parents.", - " manager.addShortText(\"parent\");", + " manager.addShortText('parent');", "} else if(manager.buildIsA(MatrixRun)) {", " // codes for matrix children.", - " manager.addShortText(manager.getEnvVariable(\"axis1\"));", + " manager.addShortText(manager.getEnvVariable('axis1'),", + " 'jenkins-!-color-dark-indigo',", + " 'jenkins-!-color-light-purple',", + " '3px dotted',", + " 'jenkins-!-success-color');", "} else {", " // unexpected case.", " manager.buildFailure();", @@ -86,6 +90,10 @@ public class GroovyPostbuildRecorderTest { }, '\n'); + private static final String SCRIPT_FOR_MATRIX2 = SCRIPT_FOR_MATRIX + .replace("jenkins-!-color-dark-indigo", "jenkins-!-error-color") + .replace("jenkins-!-success-color", "jenkins-!-color-dark-blue"); + @Test public void testMatrixProjectWithParent() throws Exception { MatrixProject p = j.createProject(MatrixProject.class); @@ -120,7 +128,7 @@ public void testMatrixProjectWithoutParent() throws Exception { p.setAxes(axisList); p.getPublishersList() .add(new GroovyPostbuildRecorder( - new SecureGroovyScript(SCRIPT_FOR_MATRIX, true, Collections.emptyList()), + new SecureGroovyScript(SCRIPT_FOR_MATRIX2, true, Collections.emptyList()), 2, false)); @@ -156,7 +164,9 @@ public void testBehaviorNotAffectWithSucceedingBuildSucceedingScript() throws Ex p.getPublishersList() .add(new GroovyPostbuildRecorder( new SecureGroovyScript( - "manager.addShortText('testing');", true, Collections.emptyList()), + "manager.addShortText('testing', null, null, null, null);", + true, + Collections.emptyList()), behavior, // behavior false // runForMatrixParent )); diff --git a/src/test/java/org/jvnet/hudson/plugins/groovypostbuild/WorkflowTest.java b/src/test/java/org/jvnet/hudson/plugins/groovypostbuild/WorkflowTest.java index a81ae1a..1a034ad 100644 --- a/src/test/java/org/jvnet/hudson/plugins/groovypostbuild/WorkflowTest.java +++ b/src/test/java/org/jvnet/hudson/plugins/groovypostbuild/WorkflowTest.java @@ -54,6 +54,30 @@ public void usingManager() throws Exception { assertEquals("stuff is broken", b.getAction(BadgeAction.class).getText()); } + @Test + public void usingManagerAddBadge2Args() throws Exception { + WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p-addBadge2"); + p.setDefinition(new CpsFlowDefinition("manager.addBadge('yellow.gif', 'stuff is broken')", true)); + WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0)); + assertEquals("stuff is broken", b.getAction(BadgeAction.class).getText()); + } + + @Test + public void usingManagerInfoBadge() throws Exception { + WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p-infoBadge"); + p.setDefinition(new CpsFlowDefinition("manager.addInfoBadge 'stuff is broken'", true)); + WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0)); + assertEquals("stuff is broken", b.getAction(BadgeAction.class).getText()); + } + + @Test + public void usingManagerErrorBadge() throws Exception { + WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p-errorBadge"); + p.setDefinition(new CpsFlowDefinition("manager.addErrorBadge 'stuff is broken'", true)); + WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0)); + assertEquals("stuff is broken", b.getAction(BadgeAction.class).getText()); + } + @Issue("JENKINS-54128") @Test public void logContains() throws Exception {