Skip to content

Commit ec9b4dc

Browse files
committed
replaced deprecated Stringutils method with suggested replacement
1 parent 6ec55c3 commit ec9b4dc

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

test/src/test/java/hudson/cli/DisablePluginCommandTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import java.io.IOException;
4343
import java.util.function.BiPredicate;
4444
import org.apache.commons.lang3.StringUtils;
45+
import org.apache.commons.lang3.Strings;
4546
import org.junit.jupiter.api.Assumptions;
4647
import org.junit.jupiter.api.BeforeEach;
4748
import org.junit.jupiter.api.Disabled;
@@ -252,8 +253,8 @@ void disablePluginsMessageAlreadyDisabled() {
252253
assertPluginDisabled("dependee");
253254
assertPluginDisabled("depender");
254255

255-
assertTrue(checkResultWith(result, StringUtils::contains, "depender", PluginWrapper.PluginDisableStatus.DISABLED), "An occurrence of the depender plugin in the log says it was successfully disabled");
256-
assertTrue(checkResultWith(result, StringUtils::contains, "depender", PluginWrapper.PluginDisableStatus.ALREADY_DISABLED), "An occurrence of the depender plugin in the log says it was already disabled");
256+
assertTrue(checkResultWith(result, Strings.CS::contains, "depender", PluginWrapper.PluginDisableStatus.DISABLED), "An occurrence of the depender plugin in the log says it was successfully disabled");
257+
assertTrue(checkResultWith(result, Strings.CS::contains, "depender", PluginWrapper.PluginDisableStatus.ALREADY_DISABLED), "An occurrence of the depender plugin in the log says it was already disabled");
257258
}
258259

259260
/**
@@ -314,7 +315,7 @@ void quietModeWithErrorNoSuch() {
314315
assertPluginDisabled("depender");
315316
assertPluginDisabled("mandatory-depender");
316317

317-
assertTrue(checkResultWith(result, StringUtils::startsWith, "badplugin", PluginWrapper.PluginDisableStatus.NO_SUCH_PLUGIN), "Only error NO_SUCH_PLUGIN in quiet mode");
318+
assertTrue(checkResultWith(result, Strings.CS::startsWith, "badplugin", PluginWrapper.PluginDisableStatus.NO_SUCH_PLUGIN), "Only error NO_SUCH_PLUGIN in quiet mode");
318319
}
319320

320321
/**
@@ -331,7 +332,7 @@ void quietModeWithErrorDependents() {
331332
assertPluginEnabled("depender");
332333
assertPluginEnabled("mandatory-depender");
333334

334-
assertTrue(checkResultWith(result, StringUtils::startsWith, "dependee", PluginWrapper.PluginDisableStatus.NOT_DISABLED_DEPENDANTS), "Only error NOT_DISABLED_DEPENDANTS in quiet mode");
335+
assertTrue(checkResultWith(result, Strings.CS::startsWith, "dependee", PluginWrapper.PluginDisableStatus.NOT_DISABLED_DEPENDANTS), "Only error NOT_DISABLED_DEPENDANTS in quiet mode");
335336
}
336337

337338
/**

test/src/test/java/hudson/scm/ChangeLogSetTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import hudson.Extension;
77
import hudson.MarkupText;
88
import hudson.model.AbstractBuild;
9+
import hudson.model.Run;
910
import org.junit.jupiter.api.BeforeEach;
1011
import org.junit.jupiter.api.Test;
1112
import org.jvnet.hudson.test.FakeChangeLogSCM;
@@ -27,7 +28,7 @@ void setUp(JenkinsRule rule) {
2728
@Issue("JENKINS-17084")
2829
void catchingExceptionDuringAnnotation() {
2930
FakeChangeLogSCM.EntryImpl change = new FakeChangeLogSCM.EntryImpl();
30-
change.setParent(ChangeLogSet.createEmpty(null)); // otherwise test would actually test only NPE thrown when accessing parent.build
31+
change.setParent(ChangeLogSet.createEmpty((Run<?, ?>) null)); // otherwise test would actually test only NPE thrown when accessing parent.build
3132
assertDoesNotThrow(() -> {
3233
change.getMsgAnnotated();
3334
});

test/src/test/java/org/kohsuke/stapler/BindTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import hudson.ExtensionList;
1111
import hudson.model.InvisibleAction;
1212
import hudson.model.RootAction;
13-
import org.apache.commons.lang3.StringUtils;
13+
import org.apache.commons.lang3.Strings;
1414
import org.htmlunit.Page;
1515
import org.htmlunit.ScriptException;
1616
import org.htmlunit.html.HtmlPage;
@@ -56,7 +56,7 @@ void bindNormal() throws Exception {
5656
.orElseThrow()
5757
.getAttribute("src");
5858

59-
final Page script = wc.goTo(StringUtils.removeStart(scriptUrl, j.contextPath + "/"), "text/javascript");
59+
final Page script = wc.goTo(Strings.CS.removeStart(scriptUrl, j.contextPath + "/"), "text/javascript");
6060
final String content = script.getWebResponse().getContentAsString();
6161
assertThat(content, startsWith("varname = makeStaplerProxy('" + j.contextPath + "/$stapler/bound/"));
6262
assertThat(content, endsWith("','test',['annotatedJsMethod1','byName1']);"));
@@ -77,7 +77,7 @@ void bindWithWellKnownURL() throws Exception {
7777
.orElseThrow()
7878
.getAttribute("src");
7979

80-
final Page script = wc.goTo(StringUtils.removeStart(scriptUrl, j.contextPath + "/"), "text/javascript");
80+
final Page script = wc.goTo(Strings.CS.removeStart(scriptUrl, j.contextPath + "/"), "text/javascript");
8181
assertThat(script.getWebResponse().getContentAsString(), is("varname = makeStaplerProxy('" + j.contextPath + "/theWellKnownRoot','test',['annotatedJsMethod2','byName2']);"));
8282
}
8383
assertThat(root.invocations, is(1));
@@ -96,7 +96,7 @@ void bindWithWellKnownURLWithQuotes() throws Exception {
9696
.orElseThrow()
9797
.getAttribute("src");
9898

99-
final Page script = wc.goTo(StringUtils.removeStart(scriptUrl, j.contextPath + "/"), "text/javascript");
99+
final Page script = wc.goTo(Strings.CS.removeStart(scriptUrl, j.contextPath + "/"), "text/javascript");
100100
assertThat(script.getWebResponse().getContentAsString(), is("varname = makeStaplerProxy('" + j.contextPath + "/the\\'Well\\'Known\\\\\\'Root\\'With\\'Quotes','test',['annotatedJsMethod2','byName2']);"));
101101
}
102102
assertThat(root.invocations, is(1));
@@ -114,7 +114,7 @@ void bindNull() throws Exception {
114114
final HtmlPage htmlPage = exception.getPage();
115115
final String scriptUrl = htmlPage.getElementsByTagName("script").stream().filter(it -> it.getAttribute("src").equals(j.contextPath + "/$stapler/bound/script/null?var=varname")).findFirst().orElseThrow().getAttribute("src");
116116

117-
final Page script = wc.goTo(StringUtils.removeStart(scriptUrl, j.contextPath + "/"), "text/javascript");
117+
final Page script = wc.goTo(Strings.CS.removeStart(scriptUrl, j.contextPath + "/"), "text/javascript");
118118
final String content = script.getWebResponse().getContentAsString();
119119
assertThat(content, is("varname = null;"));
120120
}

0 commit comments

Comments
 (0)