summaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
authorFlorian Zschocke <zschocke@gmx.de>2019-06-15 14:34:29 +0200
committerFlorian Zschocke <zschocke@gmx.de>2019-06-15 14:50:50 +0200
commit0bace7e0323ed7f4c7e773f647f6d73f563dea38 (patch)
treedf45d95ca490717c4c4157f326f6e7abfd3a550a /src/test/java
parent150ff287d220b93092e689c887a64b00a21a2693 (diff)
downloadgitblit-0bace7e0323ed7f4c7e773f647f6d73f563dea38.tar.gz
gitblit-0bace7e0323ed7f4c7e773f647f6d73f563dea38.zip
Add support nested groups on the Repositories page
Fix for #725. Also covers #527. This is a squashed commit of the following commits, merging and closing pull request #1267: commit 55fee41769ffab1aff59344fe117d481687aa743 Author: Martin Spielmann <mail@martinspielmann.de> Date: Mon Nov 6 17:19:53 2017 +0100 declared local variable final to fix travis build commit 131e4d14a48c2a3fdce621fa54637de50684d040 Author: Martin Spielmann <mail@martinspielmann.de> Date: Mon Nov 6 14:11:55 2017 +0100 fix formatting (use tab for identation) commit 8da5f6d5967894f157251c320928acdab3a451e7 Author: Martin Spielmann <mail@martinspielmann.de> Date: Mon Nov 6 13:45:39 2017 +0100 Add repositoryListType tree. Addresses #725, 527 and includes #1224 commit 6c061651fb95212ae242dbca06c8d9ef80146201 Merge: f365daa3 40ee9653 Author: Martin Spielmann <mail@martinspielmann.de> Date: Sat Nov 4 13:19:08 2017 +0100 Merge remote-tracking branch 'collapsible/ticket/527' into 725_nested_repos commit f365daa3b1d6be135365f9b11bdece320beabf4e Author: Martin Spielmann <mail@martinspielmann.de> Date: Sat Nov 4 13:10:24 2017 +0100 first working version of tree model
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/com/gitblit/wicket/panels/TreeNodeModelTest.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/test/java/com/gitblit/wicket/panels/TreeNodeModelTest.java b/src/test/java/com/gitblit/wicket/panels/TreeNodeModelTest.java
new file mode 100644
index 00000000..449688b0
--- /dev/null
+++ b/src/test/java/com/gitblit/wicket/panels/TreeNodeModelTest.java
@@ -0,0 +1,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());
+ }
+
+
+}