提交 2d1d47ed 编写于 作者: V Vincent Latombe

Merge pull request #1879 from Vlatombe/trim_display_name

Trim display name before applying it
......@@ -164,7 +164,7 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
}
public void setDisplayName(String displayName) throws IOException {
this.displayName = Util.fixEmpty(displayName);
this.displayName = Util.fixEmptyAndTrim(displayName);
save();
}
......
......@@ -151,6 +151,30 @@ public class AbstractBuildTest {
assertThat(log, containsString("Build step 'Bogus' marked build as failure"));
}
@Test void fixEmptyDisplayName() {
FreeStyleProject p = j.createFreeStyleProject("foo");
p.setDisplayName("");
assertEquals("An empty display name should be ignored.", "foo", p.getDisplayName());
}
@Test void fixBlankDisplayName() {
FreeStyleProject p = j.createFreeStyleProject("foo");
p.setDisplayName(" ");
assertEquals("A blank display name should be ignored.", "foo", p.getDisplayName());
}
@Test void validDisplayName() {
FreeStyleProject p = j.createFreeStyleProject("foo");
p.setDisplayName("bar");
assertEquals("A non-blank display name should be used.", "bar", p.getDisplayName());
}
@Test void trimValidDisplayName() {
FreeStyleProject p = j.createFreeStyleProject("foo");
p.setDisplayName(" bar ");
assertEquals("A non-blank display name with whitespace should be trimmed.", "bar", p.getDisplayName());
}
private static class ThrowBuilder extends org.jvnet.hudson.test.TestBuilder {
@Override public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
throw new NullPointerException();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册