mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-14 20:42:21 +00:00
Ensuring that getRelativeNameFrom actually inserts ../ sequences where it should.
The implementation of the method is rather hard to follow so this certainly needs to be tested!
This commit is contained in:
1 parent
bac8b9795a
commit
b8ace7789a
1 file changed
+8
-4
@@ -203,16 +203,20 @@ public class FunctionsTest {
|
||||
when(i.getName()).thenReturn("jobName");
|
||||
when(i.getDisplayName()).thenReturn("displayName");
|
||||
TopLevelItemAndItemGroup ig = mock(TopLevelItemAndItemGroup.class);
|
||||
Jenkins j = mock(Jenkins.class);
|
||||
ItemGroup j = mock(Jenkins.class);
|
||||
when(ig.getName()).thenReturn("parent");
|
||||
when(ig.getDisplayName()).thenReturn("parentDisplay");
|
||||
when(ig.getParent()).thenReturn((ItemGroup) j);
|
||||
when(ig.getParent()).thenReturn(j);
|
||||
when(i.getParent()).thenReturn(ig);
|
||||
|
||||
Item i2 = mock(Item.class);
|
||||
when(i2.getDisplayName()).thenReturn("top");
|
||||
when(i2.getParent()).thenReturn(j);
|
||||
|
||||
assertEquals("displayName", Functions.getRelativeDisplayNameFrom(i, ig));
|
||||
assertEquals("parentDisplay » displayName", Functions.getRelativeDisplayNameFrom(i, j));
|
||||
assertEquals(".. » top", Functions.getRelativeDisplayNameFrom(i2, ig));
|
||||
}
|
||||
|
||||
|
||||
private void createMockAncestors(StaplerRequest req, Ancestor... ancestors) {
|
||||
List<Ancestor> ancestorsList = Arrays.asList(ancestors);
|
||||
when(req.getAncestors()).thenReturn(ancestorsList);
|
||||
|
||||
Reference in new issue
Block a user