NavigationImpl implements Navigation { @Override public Node getNode(String... nodePath) { return getNode(NodePath.path(nodePath)); } NavigationImpl(SiteId siteId, NavigationService navigationService, NavigationContext navCtx, DescriptionService descriptionService,
            ResourceBundleManager bundleManager);   NavigationImpl(SiteId siteId); @Override boolean removeNode(NodePath path); @Override Node getNode(String... nodePath); @Override Node getNode(NodePath nodePath); @Override Node getNode(NodePath nodePath, NodeVisitor visitor); @Override int getPriority(); @Override SiteId getSiteId(); @Override Node getRootNode(NodeVisitor visitor); @Override void refreshNode(Node node); @Override void refreshNode(Node node, NodeVisitor visitor); @Override void saveNode(Node node); @Override void setPriority(int priority);  }
@Test public void getNode() { createNavigationChildren(); Node node = navigation.getNode("parent", "child"); assertNotNull(node); assertEquals("child", node.getName()); }
@Test(expected = IllegalArgumentException.class) public void getNode_EmptyPath() { String[] path = new String[0]; navigation.getNode(path); }
@Test public void getNode_Invalid_Path() { createNavigationChildren(); Node node = navigation.getNode("foo", "child"); assertNull(node); }
@Test(expected = IllegalArgumentException.class) public void getNode_NullNodePath() { navigation.getNode((NodePath) null); }
@Test(expected = IllegalArgumentException.class) public void getNode_NullVisitor() { navigation.getNode(NodePath.path("parent"), null); }
@Test public void getNode_With_Visitor() { createNavigationChildren(); Node node = navigation.getNode(NodePath.path("parent"), Nodes.visitNone()); assertNotNull(node); assertFalse(node.isChildrenLoaded()); node = navigation.getNode(NodePath.path("parent"), Nodes.visitChildren()); assertTrue(node.isChildrenLoaded()); assertNotNull(node.getChild("child")); }
@Test public void serialization_Remove() throws Exception { createNavigationChildren(); Node parent = navigation.getNode(NodePath.path("parent"), Nodes.visitAll()); parent.removeChild("child"); assertEquals(0, parent.getChildCount()); Node parentNode = SerializationUtils.serializeDeserialize(parent); assertEquals(0, parentNode.getChildCount()); }
@Test public void serialization_Add() throws Exception { createNavigationChildren(); Node parent = navigation.getNode(NodePath.path("parent"), Nodes.visitAll()); parent.addChild("child2"); Node parentNode = SerializationUtils.serializeDeserialize(parent); assertEquals("child", parentNode.getChild(0).getName()); assertEquals("child2", parentNode.getChild(1).getName()); }