blob: 449688b0f5334ddef105c49011bf8667150b4ad6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
package com.gitblit.wicket.panels;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.TreeNodeModel;
public class TreeNodeModelTest {
@Test
public void testContainsSubFolder() {
TreeNodeModel tree = new TreeNodeModel();
tree.add("foo").add("bar").add("baz");
assertTrue(tree.containsSubFolder("foo/bar/baz"));
assertTrue(tree.containsSubFolder("foo/bar"));
assertFalse(tree.containsSubFolder("foo/bar/blub"));
}
@Test
public void testAddInHierarchy() {
TreeNodeModel tree = new TreeNodeModel();
tree.add("foo").add("bar");
RepositoryModel model = new RepositoryModel("test","","",null);
// add model to non-existing folder. should be created automatically
tree.add("foo/bar/baz", model);
tree.add("another/non/existing/folder", model);
assertTrue(tree.containsSubFolder("foo/bar/baz"));
assertTrue(tree.containsSubFolder("another/non/existing/folder"));
}
@Test
public void testGetDepth() {
TreeNodeModel tree = new TreeNodeModel();
TreeNodeModel bar = tree.add("foo").add("bar").add("baz");
assertEquals(0, tree.getDepth());
assertEquals(3, bar.getDepth());
}
}
|