@Test public void testGetNavigationRootPage() { Map<String, Object> properties = new HashMap<>(); properties.put(SiteNavigation.PN_NAV_ROOT, true); Page navRootPage = mockPage(properties); Page page0 = mockPage(null); Page page1 = mockPage(null); when(page0.getParent()).thenReturn(page1); when(page1.getParent()).thenReturn(navRootPage); Page page2 = mockPage(null); Page page3 = mockPage(null); when(page2.getParent()).thenReturn(page3); Assert.assertNull(SiteNavigation.getNavigationRootPage(null)); Assert.assertSame(navRootPage, SiteNavigation.getNavigationRootPage(navRootPage)); Assert.assertSame(navRootPage, SiteNavigation.getNavigationRootPage(page1)); Assert.assertSame(navRootPage, SiteNavigation.getNavigationRootPage(page0)); Assert.assertNull(SiteNavigation.getNavigationRootPage(page3)); Assert.assertNull(SiteNavigation.getNavigationRootPage(page2)); }
@Nullable public static Page getNavigationRootPage(Page page) { page = toLaunchProductionPage(page); while (page != null) { if (page.getContentResource().getValueMap().get(PN_NAV_ROOT, false)) { break; } page = page.getParent(); } return page; }
SiteNavigation { @Nullable public static Page getNavigationRootPage(Page page) { page = toLaunchProductionPage(page); while (page != null) { if (page.getContentResource().getValueMap().get(PN_NAV_ROOT, false)) { break; } page = page.getParent(); } return page; } }
SiteNavigation { @Nullable public static Page getNavigationRootPage(Page page) { page = toLaunchProductionPage(page); while (page != null) { if (page.getContentResource().getValueMap().get(PN_NAV_ROOT, false)) { break; } page = page.getParent(); } return page; } SiteNavigation(SlingHttpServletRequest request); }
SiteNavigation { @Nullable public static Page getNavigationRootPage(Page page) { page = toLaunchProductionPage(page); while (page != null) { if (page.getContentResource().getValueMap().get(PN_NAV_ROOT, false)) { break; } page = page.getParent(); } return page; } SiteNavigation(SlingHttpServletRequest request); static Page getProductPage(Page page); @Nullable static Page getCategoryPage(Page page); @Nullable static Page getSearchResultsPage(Page page); @Nullable static Page getNavigationRootPage(Page page); @Deprecated static String toProductUrl(String pagePath, String slug); @Deprecated static String toProductUrl(String pagePath, String slug, String variantSku); static Pair<String, String> toProductSkus(String combinedSku); @Deprecated String toPageUrl(Page page, String slug); @Deprecated String toProductUrl(Page page, String slug, String variantSku); static Page toLaunchProductionPage(Page page); }
SiteNavigation { @Nullable public static Page getNavigationRootPage(Page page) { page = toLaunchProductionPage(page); while (page != null) { if (page.getContentResource().getValueMap().get(PN_NAV_ROOT, false)) { break; } page = page.getParent(); } return page; } SiteNavigation(SlingHttpServletRequest request); static Page getProductPage(Page page); @Nullable static Page getCategoryPage(Page page); @Nullable static Page getSearchResultsPage(Page page); @Nullable static Page getNavigationRootPage(Page page); @Deprecated static String toProductUrl(String pagePath, String slug); @Deprecated static String toProductUrl(String pagePath, String slug, String variantSku); static Pair<String, String> toProductSkus(String combinedSku); @Deprecated String toPageUrl(Page page, String slug); @Deprecated String toProductUrl(Page page, String slug, String variantSku); static Page toLaunchProductionPage(Page page);  }