Search in sources :

Example 1 with BadgeSummaryAction

use of com.jenkinsci.plugins.badge.action.BadgeSummaryAction in project badge-plugin by jenkinsci.

the class CreateSummaryStepTest method createSummary_all.

@Test
public void createSummary_all() throws Exception {
    String text = randomUUID().toString();
    BadgeSummaryAction action = createSummary("summary.appendText('" + text + "', false, true, true, 'grey')");
    assertEquals("<b><i><font color=\"grey\">" + text + "</font></i></b>", action.getText());
}
Also used : BadgeSummaryAction(com.jenkinsci.plugins.badge.action.BadgeSummaryAction) Test(org.junit.Test)

Example 2 with BadgeSummaryAction

use of com.jenkinsci.plugins.badge.action.BadgeSummaryAction in project badge-plugin by jenkinsci.

the class CreateSummaryStepTest method createSummary_html_escaped.

@Test
public void createSummary_html_escaped() throws Exception {
    String text = randomUUID().toString();
    BadgeSummaryAction action = createSummary("summary.appendText('<li>" + text + "</li>', true)");
    assertEquals("&lt;li&gt;" + text + "&lt;/li&gt;", action.getText());
}
Also used : BadgeSummaryAction(com.jenkinsci.plugins.badge.action.BadgeSummaryAction) Test(org.junit.Test)

Example 3 with BadgeSummaryAction

use of com.jenkinsci.plugins.badge.action.BadgeSummaryAction in project badge-plugin by jenkinsci.

the class CreateSummaryStepTest method createSummary_html_unescaped.

@Test
public void createSummary_html_unescaped() throws Exception {
    String text = randomUUID().toString();
    BadgeSummaryAction action = createSummary("summary.appendText('<li>" + text + "</li>', false)");
    assertEquals("<li>" + text + "</li>", action.getText());
}
Also used : BadgeSummaryAction(com.jenkinsci.plugins.badge.action.BadgeSummaryAction) Test(org.junit.Test)

Example 4 with BadgeSummaryAction

use of com.jenkinsci.plugins.badge.action.BadgeSummaryAction in project badge-plugin by jenkinsci.

the class CreateSummaryStepTest method createSummary_with_text.

@Test
public void createSummary_with_text() 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));
    WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
    List<BadgeSummaryAction> summaryActions = b.getActions(BadgeSummaryAction.class);
    assertEquals(1, summaryActions.size());
    BadgeSummaryAction action = summaryActions.get(0);
    assertTrue(action.getIconPath().endsWith(icon));
    assertEquals(text, action.getText());
}
Also used : CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) BadgeSummaryAction(com.jenkinsci.plugins.badge.action.BadgeSummaryAction) Test(org.junit.Test)

Example 5 with BadgeSummaryAction

use of com.jenkinsci.plugins.badge.action.BadgeSummaryAction in project badge-plugin by jenkinsci.

the class CreateSummaryStepTest method createSummary.

private BadgeSummaryAction createSummary(String script) throws Exception {
    String icon = randomUUID().toString();
    WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
    p.setDefinition(new CpsFlowDefinition("def summary = createSummary(\"" + icon + "\")\n" + script, true));
    WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
    List<BadgeSummaryAction> summaryActions = b.getActions(BadgeSummaryAction.class);
    assertEquals(1, summaryActions.size());
    BadgeSummaryAction action = summaryActions.get(0);
    assertTrue(action.getIconPath().endsWith(icon));
    return action;
}
Also used : CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) BadgeSummaryAction(com.jenkinsci.plugins.badge.action.BadgeSummaryAction)

Aggregations

BadgeSummaryAction (com.jenkinsci.plugins.badge.action.BadgeSummaryAction)7 Test (org.junit.Test)5 CpsFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition)3 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)3 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)3