@Test
public void findMenuItems() throws Exception {
new FacesRequest() {
protected void invokeApplication() throws Exception {
WikiNodeDAO dao = (WikiNodeDAO)getInstance(WikiNodeDAO.class);
WikiDirectory root = dao.findWikiDirectory(1l);
List<WikiTreeNode<WikiDirectory>> tree = dao.findMenuItemTree(root, 3l, 3l, false);
Assert.assertEquals(tree.size(), 3);
Assert.assertEquals(tree.get(0).getLevel(), 1);
Assert.assertEquals(tree.get(0).getNode().getName(), "BBB");
Assert.assertEquals(tree.get(1).getLevel(), 1);
Assert.assertEquals(tree.get(1).getNode().getName(), "CCC");
Assert.assertEquals(tree.get(2).getLevel(), 2);
Assert.assertEquals(tree.get(2).getNode().getName(), "DDD");
tree = dao.findMenuItemTree(root, 3l, 1l, false);
Assert.assertEquals(tree.size(), 3);
Assert.assertEquals(tree.get(0).getLevel(), 1);
Assert.assertEquals(tree.get(0).getNode().getName(), "BBB");
Assert.assertEquals(tree.get(1).getLevel(), 1);
Assert.assertEquals(tree.get(1).getNode().getName(), "CCC");
Assert.assertEquals(tree.get(2).getLevel(), 1);
Assert.assertEquals(tree.get(2).getNode().getName(), "DDD");
tree = dao.findMenuItemTree(root, 1l, 3l, false);
Assert.assertEquals(tree.size(), 2);
Assert.assertEquals(tree.get(0).getLevel(), 1);
Assert.assertEquals(tree.get(0).getNode().getName(), "BBB");
Assert.assertEquals(tree.get(1).getLevel(), 1);
Assert.assertEquals(tree.get(1).getNode().getName(), "CCC");