From 14b56ae641057121d39615f7543fa49d54bcd792 Mon Sep 17 00:00:00 2001 From: strangelookingnerd <49242855+strangelookingnerd@users.noreply.github.com> Date: Wed, 25 Sep 2024 17:42:00 +0200 Subject: [PATCH] Upgrade to badge-plugin 2.x (#995) --- .../configuration/LineInTheBuildLog.java | 5 ++-- .../FailureCauseManagementPage.java | 2 +- .../build_steps/AddABuildStep.java | 4 ++-- .../build_steps/AddAPostBuildAction.java | 4 ++-- build-monitor-plugin/pom.xml | 6 ++--- .../features/HasBadgesBadgePlugin.java | 23 +++++++++++++++---- .../BadgeBadgePluginRecipe.java | 4 ++-- pom.xml | 4 +++- 8 files changed, 33 insertions(+), 19 deletions(-) diff --git a/build-monitor-acceptance/src/main/java/com/sonyericsson/jenkins/plugins/bfa/tasks/configuration/LineInTheBuildLog.java b/build-monitor-acceptance/src/main/java/com/sonyericsson/jenkins/plugins/bfa/tasks/configuration/LineInTheBuildLog.java index b83388332..57b1617a4 100644 --- a/build-monitor-acceptance/src/main/java/com/sonyericsson/jenkins/plugins/bfa/tasks/configuration/LineInTheBuildLog.java +++ b/build-monitor-acceptance/src/main/java/com/sonyericsson/jenkins/plugins/bfa/tasks/configuration/LineInTheBuildLog.java @@ -23,9 +23,8 @@ public void performAs(T actor) { actor.attemptsTo( Scroll.to(FailureCauseManagementPage.Add_Indication), Click.on(FailureCauseManagementPage.Add_Indication), - WaitUntil.the( - FailureCauseManagementPage.Build_Log_Indication_Link, WebElementStateMatchers.isVisible()), - Click.on(FailureCauseManagementPage.Build_Log_Indication_Link), + WaitUntil.the(FailureCauseManagementPage.Build_Log_Indication, WebElementStateMatchers.isVisible()), + Click.on(FailureCauseManagementPage.Build_Log_Indication), Enter.theValue(pattern).into(FailureCauseManagementPage.Pattern_Field)); } diff --git a/build-monitor-acceptance/src/main/java/com/sonyericsson/jenkins/plugins/bfa/user_interface/FailureCauseManagementPage.java b/build-monitor-acceptance/src/main/java/com/sonyericsson/jenkins/plugins/bfa/user_interface/FailureCauseManagementPage.java index 68c7f9319..7a037c363 100644 --- a/build-monitor-acceptance/src/main/java/com/sonyericsson/jenkins/plugins/bfa/user_interface/FailureCauseManagementPage.java +++ b/build-monitor-acceptance/src/main/java/com/sonyericsson/jenkins/plugins/bfa/user_interface/FailureCauseManagementPage.java @@ -12,7 +12,7 @@ public class FailureCauseManagementPage { Target.the("the description textarea").locatedBy("//textarea[@name='_.description']"); public static final Target Add_Indication = Button.called("Add Indication"); - public static final Target Build_Log_Indication_Link = Link.called("Build Log Indication"); + public static final Target Build_Log_Indication = Button.called("Build Log Indication"); public static final Target Pattern_Field = Input.named("pattern"); public static final Target Save = Button.called("Save"); diff --git a/build-monitor-acceptance/src/main/java/net/serenitybdd/screenplay/jenkins/tasks/configuration/build_steps/AddABuildStep.java b/build-monitor-acceptance/src/main/java/net/serenitybdd/screenplay/jenkins/tasks/configuration/build_steps/AddABuildStep.java index 7a7bf4f33..aa7cab951 100644 --- a/build-monitor-acceptance/src/main/java/net/serenitybdd/screenplay/jenkins/tasks/configuration/build_steps/AddABuildStep.java +++ b/build-monitor-acceptance/src/main/java/net/serenitybdd/screenplay/jenkins/tasks/configuration/build_steps/AddABuildStep.java @@ -6,7 +6,7 @@ import net.serenitybdd.screenplay.Actor; import net.serenitybdd.screenplay.Task; import net.serenitybdd.screenplay.actions.Click; -import net.serenitybdd.screenplay.jenkins.targets.Link; +import net.serenitybdd.screenplay.jenkins.targets.Button; import net.serenitybdd.screenplay.jenkins.user_interface.ProjectConfigurationPage; public class AddABuildStep implements Task { @@ -22,7 +22,7 @@ public void performAs(final T actor) { Click.on(ProjectConfigurationPage.Build_Steps), Sleep.of(1, TimeUnit.SECONDS), Click.on(ProjectConfigurationPage.Add_Build_Step), - Click.on(Link.called(buildStepName))); + Click.on(Button.called(buildStepName))); } public AddABuildStep(String buildStepName) { diff --git a/build-monitor-acceptance/src/main/java/net/serenitybdd/screenplay/jenkins/tasks/configuration/build_steps/AddAPostBuildAction.java b/build-monitor-acceptance/src/main/java/net/serenitybdd/screenplay/jenkins/tasks/configuration/build_steps/AddAPostBuildAction.java index e08078e2e..87fa1e67c 100644 --- a/build-monitor-acceptance/src/main/java/net/serenitybdd/screenplay/jenkins/tasks/configuration/build_steps/AddAPostBuildAction.java +++ b/build-monitor-acceptance/src/main/java/net/serenitybdd/screenplay/jenkins/tasks/configuration/build_steps/AddAPostBuildAction.java @@ -6,7 +6,7 @@ import net.serenitybdd.screenplay.Actor; import net.serenitybdd.screenplay.Task; import net.serenitybdd.screenplay.actions.Click; -import net.serenitybdd.screenplay.jenkins.targets.Link; +import net.serenitybdd.screenplay.jenkins.targets.Button; import net.serenitybdd.screenplay.jenkins.user_interface.ProjectConfigurationPage; import net.serenitybdd.screenplayx.actions.Scroll; @@ -24,7 +24,7 @@ public void performAs(T actor) { Sleep.of(1, TimeUnit.SECONDS), Click.on(ProjectConfigurationPage.Add_Post_Build_Action), Sleep.of(1, TimeUnit.SECONDS), - Click.on(Link.called(postBuildActionName))); + Click.on(Button.called(postBuildActionName))); } public AddAPostBuildAction(String postBuildActionName) { diff --git a/build-monitor-plugin/pom.xml b/build-monitor-plugin/pom.xml index 6612be3e4..9221e058e 100644 --- a/build-monitor-plugin/pom.xml +++ b/build-monitor-plugin/pom.xml @@ -49,8 +49,8 @@ io.jenkins.tools.bom - bom-2.414.x - 2982.vdce2153031a_0 + bom-${jenkins.baseline}.x + 3387.v0f2773fa_3200 pom import @@ -71,7 +71,7 @@ org.jenkins-ci.plugins badge - 1.9.1 + 2.1 true diff --git a/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasBadgesBadgePlugin.java b/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasBadgesBadgePlugin.java index 0901868f0..ff8eda975 100644 --- a/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasBadgesBadgePlugin.java +++ b/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasBadgesBadgePlugin.java @@ -8,6 +8,8 @@ import java.util.Iterator; import java.util.List; import java.util.function.Predicate; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * @author Daniel Beland @@ -57,6 +59,9 @@ public List value() { public static class Badge { private final BadgeAction badge; + private static final Pattern BADGE_STYLE_PATTERN = + Pattern.compile("(border: (?.*) solid (?.*);)?" + + "(background: (?.*);)?" + "(color: (?.*);)?"); public Badge(BadgeAction badge) { this.badge = badge; @@ -69,29 +74,37 @@ public final String text() { @JsonProperty public final String color() { - return badge.getColor(); + String style = badge.getStyle(); + Matcher matcher = BADGE_STYLE_PATTERN.matcher(style); + return matcher.matches() ? matcher.group("color") : null; } @JsonProperty public final String background() { - return badge.getBackground(); + String style = badge.getStyle(); + Matcher matcher = BADGE_STYLE_PATTERN.matcher(style); + return matcher.matches() ? matcher.group("background") : null; } @JsonProperty public final String border() { - return badge.getBorder(); + String style = badge.getStyle(); + Matcher matcher = BADGE_STYLE_PATTERN.matcher(style); + return matcher.matches() ? matcher.group("border") : null; } @JsonProperty public final String borderColor() { - return badge.getBorderColor(); + String style = badge.getStyle(); + Matcher matcher = BADGE_STYLE_PATTERN.matcher(style); + return matcher.matches() ? matcher.group("borderColor") : null; } } private static class ActionFilter implements Predicate { @Override public boolean test(BadgeAction action) { - return action.getIconPath() == null; + return action.getIcon() == null; } } } diff --git a/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/syntacticsugar/BadgeBadgePluginRecipe.java b/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/syntacticsugar/BadgeBadgePluginRecipe.java index 7de430b9e..952eec571 100644 --- a/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/syntacticsugar/BadgeBadgePluginRecipe.java +++ b/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/syntacticsugar/BadgeBadgePluginRecipe.java @@ -18,13 +18,13 @@ public BadgeBadgePluginRecipe() { } public BadgeBadgePluginRecipe withText(String text) { - when(badge.getIconPath()).thenReturn(null); + when(badge.getIcon()).thenReturn(null); lenient().when(badge.getText()).thenReturn(text); return this; } public BadgeBadgePluginRecipe withIcon(String icon, String text) { - when(badge.getIconPath()).thenReturn(icon); + when(badge.getIcon()).thenReturn(icon); lenient().when(badge.getText()).thenReturn(text); return this; } diff --git a/pom.xml b/pom.xml index 45334f25c..4a94c399f 100644 --- a/pom.xml +++ b/pom.xml @@ -37,7 +37,9 @@ 1.14 999999-SNAPSHOT - 2.414.3 + + 2.440 + ${jenkins.baseline}.3 jenkinsci/build-monitor-plugin false