From 470620c9e43fba69ae200355eb1827fb5baeb72b Mon Sep 17 00:00:00 2001 From: Michael Tughan Date: Tue, 10 Dec 2024 11:00:51 -0500 Subject: [PATCH] JENKINS-74974 - Adapt Scriptler test to use preferred terminology (#1859) Scriptler 390 and above use "(built-in)" to refer to the built-in node instead of "(controller)" or "(master)". Update the test harness to check for any of these terms. The adaptation code can be simplified once older versions of the Scriptler plugin are no longer being tested. --- .../acceptance/plugins/scriptler/ScriptResult.java | 14 ++++++++++++-- .../org/jenkinsci/test/acceptance/po/Jenkins.java | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jenkinsci/test/acceptance/plugins/scriptler/ScriptResult.java b/src/main/java/org/jenkinsci/test/acceptance/plugins/scriptler/ScriptResult.java index 2a1e00ff3..02c6b2ca1 100644 --- a/src/main/java/org/jenkinsci/test/acceptance/plugins/scriptler/ScriptResult.java +++ b/src/main/java/org/jenkinsci/test/acceptance/plugins/scriptler/ScriptResult.java @@ -23,12 +23,15 @@ */ package org.jenkinsci.test.acceptance.plugins.scriptler; +import java.util.List; +import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.jenkinsci.test.acceptance.po.Jenkins; import org.jenkinsci.test.acceptance.po.Node; public class ScriptResult { + private static final List BUILT_IN_NODE_NAMES = List.of("built-in", "controller", "master"); private final String result; public ScriptResult(String result) { @@ -37,8 +40,15 @@ public ScriptResult(String result) { public String output(Node node) { String name = node.getName(); - if (node instanceof Jenkins && "(master)".equals(name)) { - name = "(controller)"; + if (node instanceof Jenkins) { + // TODO: use the below code once Scriptler versions 390 and up are the only ones tested + // return "(" + node + ")"; + return BUILT_IN_NODE_NAMES.stream() + .map(nodeName -> "(" + nodeName + ")") + .map(this::output) + .filter(Objects::nonNull) + .findFirst() + .orElse(null); } return output(name); } diff --git a/src/main/java/org/jenkinsci/test/acceptance/po/Jenkins.java b/src/main/java/org/jenkinsci/test/acceptance/po/Jenkins.java index 6ff40865c..43485f032 100644 --- a/src/main/java/org/jenkinsci/test/acceptance/po/Jenkins.java +++ b/src/main/java/org/jenkinsci/test/acceptance/po/Jenkins.java @@ -216,7 +216,7 @@ public T getPluginPage(Class type) { @Override public String getName() { - return "(master)"; + return "built-in"; } @Override