File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\test\java\hudson\model\ItemsTest.java.html

1 package hudson.model;
2
3 import org.junit.BeforeClass;
4 import org.junit.Test;
5
6 import java.io.File;
7 import java.io.IOException;
8 import java.util.Collection;
9
10 import static org.junit.Assert.assertArrayEquals;
11 import static org.junit.Assert.assertEquals;
12 import static org.mockito.Mockito.*;
13
14 /**
15 * @author: <a hef="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a>
16 */
17 public class ItemsTest {
18
19 private static ItemGroup root;
20 private static ItemGroup foo;
21 private static ItemGroup foo_bar;
22
23 @BeforeClass
24 public static void itemGroups() {
25 root = mock(ItemGroup.class);
26 when(root.getFullName()).thenReturn("");
27
28 foo = mock(ItemGroup.class);
29 when(foo.getFullName()).thenReturn("foo");
30
31 foo_bar = mock(ItemGroup.class);
32 when(foo_bar.getFullName()).thenReturn("foo/bar");
33
34 }
35
36 @Test
37 public void getCanonicalName() {
38 assertEquals("foo", Items.getCanonicalName(root, "foo"));
39 assertEquals("foo", Items.getCanonicalName(root, "/foo"));
40 assertEquals("foo/bar", Items.getCanonicalName(root, "foo/bar"));
41 assertEquals("foo/bar", Items.getCanonicalName(foo, "bar"));
42 assertEquals("bar", Items.getCanonicalName(foo, "/bar"));
43 assertEquals("bar", Items.getCanonicalName(foo, "../bar"));
44 assertEquals("foo/bar", Items.getCanonicalName(foo, "./bar"));
45 assertEquals("foo/bar/baz/qux", Items.getCanonicalName(foo_bar, "baz/qux"));
46 assertEquals("foo/baz/qux", Items.getCanonicalName(foo_bar, "../baz/qux"));
47 }
48
49 @Test
50 public void computeRelativeNamesAfterRenaming() {
51 assertEquals("meu,bu,zo", Items.computeRelativeNamesAfterRenaming("ga", "meu", "ga,bu,zo", root ));
52 assertEquals("ga,bu,zo", Items.computeRelativeNamesAfterRenaming("ga", "meu", "ga,bu,zo", foo_bar ));
53 assertEquals("meu,bu,zo", Items.computeRelativeNamesAfterRenaming("foo/ga", "foo/meu", "ga,bu,zo", foo ));
54
55 assertEquals("/meu,/bu,/zo", Items.computeRelativeNamesAfterRenaming("ga", "meu", "/ga,/bu,/zo", root ));
56 assertEquals("/meu,/bu,/zo", Items.computeRelativeNamesAfterRenaming("ga", "meu", "/ga,/bu,/zo", foo_bar ));
57
58 assertEquals("../meu,../bu,../zo", Items.computeRelativeNamesAfterRenaming("ga", "meu", "../ga,../bu,../zo", foo ));
59 assertEquals("../qux/ga,bu,zo", Items.computeRelativeNamesAfterRenaming("foo/baz", "foo/qux", "../baz/ga,bu,zo", foo_bar ));
60 }
61
62 }
63