NavigationManagerImpl implements NavigationManager { @Override public NavigationPageItem getMainNavigation(final int maxLevels) { Page siteRootPage = siteRoot.getRootPage(); if (siteRootPage == null) { siteRootPage = currentPage; } NavigationPageItem rootItem = createLinkableItem(siteRootPage); if (maxLevels > 0) { rootItem.setChildren(createChildItemsRecursively(siteRootPage, new ValidLinkableItemCreator(), 1, maxLevels)); } return rootItem; }  @Override NavigationPageItem getMainNavigation(final int maxLevels); @Override NavigationPageItem getFooterNavigation();  }
@Test void testGetMainNavigation() throws Exception { try (FileInputStream fis = new FileInputStream("src/main/webapp/app-root/components/admin/page/redirect.json"); BufferedInputStream bis = new BufferedInputStream(fis)) { context.load().json(bis, "/apps/wcm-io-samples/core/components/admin/page/redirect"); } NavigationPageItem rootItem = underTest.getMainNavigation(2); assertLinkItem("HOME", "/content/wcm-io-samples/en.html", rootItem); List<NavigationPageItem> mainnavItems = rootItem.getChildren(); assertEquals(5, mainnavItems.size()); assertLinkItem("CONFERENCE", "/content/wcm-io-samples/en/conference.html", mainnavItems.get(0)); assertLinkItem("ARCHIVE", "/content/wcm-io-samples/en/archive.html", mainnavItems.get(4)); List<NavigationPageItem> archiveItems = mainnavItems.get(4).getChildren(); assertEquals(2, archiveItems.size()); assertLinkItem("Handler Sample 2012", "http: assertLinkItem("Handler Sample 2011", "http: }
@Test void testGetMainNavigation_1Levels() throws Exception { NavigationPageItem rootItem = underTest.getMainNavigation(1); List<NavigationPageItem> mainnavItems = rootItem.getChildren(); assertEquals(5, mainnavItems.size()); List<NavigationPageItem> archiveItems = mainnavItems.get(4).getChildren(); assertEquals(0, archiveItems.size()); }
@Test void testGetMainNavigation_0Levels() throws Exception { NavigationPageItem rootItem = underTest.getMainNavigation(0); List<NavigationPageItem> mainnavItems = rootItem.getChildren(); assertEquals(0, mainnavItems.size()); }