use of com.jenkinsci.plugins.badge.action.BadgeAction in project badge-plugin by jenkinsci.
the class AddBadgeStepTest method addBadge.
private void addBadge(boolean inNode) throws Exception {
String icon = UUID.randomUUID().toString();
String text = UUID.randomUUID().toString();
String link = UUID.randomUUID().toString();
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
String script = "addBadge(icon:\"" + icon + "\", text:\"" + text + "\", link:\"" + link + "\")";
if (inNode) {
script = "node() {" + script + "}";
}
p.setDefinition(new CpsFlowDefinition(script, true));
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
List<BuildBadgeAction> badgeActions = b.getBadgeActions();
assertEquals(1, badgeActions.size());
BadgeAction action = (BadgeAction) badgeActions.get(0);
assertTrue(action.getIconPath().endsWith(icon));
assertEquals(text, action.getText());
assertEquals(link, action.getLink());
}
use of com.jenkinsci.plugins.badge.action.BadgeAction in project badge-plugin by jenkinsci.
the class AddBadgeStepTest method addStatusBadge.
private void addStatusBadge(String functionName, String expectedIcon) throws Exception {
String text = UUID.randomUUID().toString();
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition(functionName + "(\"" + text + "\")", true));
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
List<BuildBadgeAction> badgeActions = b.getBadgeActions();
assertEquals(1, badgeActions.size());
BadgeAction action = (BadgeAction) badgeActions.get(0);
assertEquals(text, action.getText());
assertTrue(action.getIconPath().endsWith(expectedIcon));
}
use of com.jenkinsci.plugins.badge.action.BadgeAction in project badge-plugin by jenkinsci.
the class ShortTextStepTest method addShortText.
@Test
public void addShortText() throws Exception {
String text = UUID.randomUUID().toString();
String color = UUID.randomUUID().toString();
String background = UUID.randomUUID().toString();
Integer border = new Random().nextInt();
String borderColor = UUID.randomUUID().toString();
String link = UUID.randomUUID().toString();
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("addShortText(text:\"" + text + "\",color:\"" + color + "\", background:\"" + background + "\", border:" + border + ", borderColor:\"" + borderColor + "\", link:\"" + link + "\")", true));
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
List<? extends Action> allActions = b.getAllActions();
List<BuildBadgeAction> badgeActions = b.getBadgeActions();
assertEquals(1, badgeActions.size());
BadgeAction action = (BadgeAction) badgeActions.get(0);
assertEquals(text, action.getText());
assertEquals(color, action.getColor());
assertEquals(background, action.getBackground());
assertEquals(borderColor, action.getBorderColor());
assertEquals(border + "px", action.getBorder());
assertNull(action.getIconPath());
assertEquals(link, action.getLink());
}
use of com.jenkinsci.plugins.badge.action.BadgeAction in project badge-plugin by jenkinsci.
the class ShortTextStepTest method addShortText_minimal.
@Test
public void addShortText_minimal() throws Exception {
String text = UUID.randomUUID().toString();
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("addShortText(text:\"" + text + "\")", true));
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
List<BuildBadgeAction> badgeActions = b.getBadgeActions();
assertEquals(1, badgeActions.size());
BadgeAction action = (BadgeAction) badgeActions.get(0);
assertEquals(text, action.getText());
assertNull(action.getColor());
assertNull(action.getBackground());
assertNull(action.getBorderColor());
assertNull(action.getBorder());
assertNull(action.getIconPath());
assertNull(action.getLink());
}
Aggregations