Search in sources :

Example 1 with NavigationItem

use of com.adobe.cq.wcm.core.components.models.NavigationItem in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class BreadcrumbImpl method addNavigationItems.

private void addNavigationItems(int currentLevel) {
    while (startLevel < currentLevel) {
        Page page = currentPage.getAbsoluteParent(startLevel);
        if (page != null) {
            boolean isActivePage = page.equals(currentPage);
            if (isActivePage && hideCurrent) {
                break;
            }
            if (checkIfNotHidden(page)) {
                NavigationItem navigationItem = new NavigationItemImpl(page, isActivePage);
                items.add(navigationItem);
            }
        }
        startLevel++;
    }
}
Also used : NavigationItem(com.adobe.cq.wcm.core.components.models.NavigationItem) Page(com.day.cq.wcm.api.Page)

Example 2 with NavigationItem

use of com.adobe.cq.wcm.core.components.models.NavigationItem in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class LanguageNavigationImplTest method testLanguageNavigationItemsOnTemplate.

@Test
protected void testLanguageNavigationItemsOnTemplate() {
    LanguageNavigation languageNavigation = getLanguageNavigationUnderTest("/conf/coretest/settings/wcm/templates/template-1/structure/jcr:content/root/languagenavigation");
    List<NavigationItem> items = getLanguageNavigationItems(languageNavigation);
    Object[][] expectedPages = { { "/content/languagenavigation/LOCALE-1", "LOCALE 1", false, 0, "US", "en-US", "/content/languagenavigation/LOCALE-1.html" }, { "/content/languagenavigation/LOCALE-1/LOCALE-5", "LOCALE 5", false, 1, "US", "en-US", "/content/languagenavigation/LOCALE-1/LOCALE-5.html" }, { "/content/languagenavigation/LOCALE-1/LOCALE-6", "LOCALE 6", false, 1, "US", "es-US", "/content/languagenavigation/LOCALE-1/LOCALE-6.html" }, { "/content/languagenavigation/LOCALE-2", "LOCALE 2", false, 0, "CA", "en-CA", "/content/languagenavigation/LOCALE-2.html" }, { "/content/languagenavigation/LOCALE-2/LOCALE-5", "LOCALE 5", false, 1, "CA", "en-CA", "/content/languagenavigation/LOCALE-2/LOCALE-5.html" }, { "/content/languagenavigation/LOCALE-2/LOCALE-7", "LOCALE 7", false, 1, "CA", "fr-CA", "/content/languagenavigation/LOCALE-2/LOCALE-7.html" }, { "/content/languagenavigation/LOCALE-3", "LOCALE 3", false, 0, "CH", "de-CH", "/LOCALE-3-vanity" }, { "/content/languagenavigation/LOCALE-3/LOCALE-8", "LOCALE 8", false, 1, "CH", "de-CH", "/content/languagenavigation/LOCALE-3/LOCALE-8.html" }, { "/content/languagenavigation/LOCALE-4", "LOCALE 4", false, 0, "DE", "de-DE", "/content/languagenavigation/LOCALE-4.html" }, { "/content/languagenavigation/LOCALE-4/LOCALE-9", "LOCALE 9", false, 1, "DE", "de-DE", "/content/languagenavigation/LOCALE-4/LOCALE-9.html" } };
    verifyLanguageNavigationItems(expectedPages, items);
}
Also used : LanguageNavigation(com.adobe.cq.wcm.core.components.models.LanguageNavigation) LanguageNavigationItem(com.adobe.cq.wcm.core.components.models.LanguageNavigationItem) NavigationItem(com.adobe.cq.wcm.core.components.models.NavigationItem) Test(org.junit.jupiter.api.Test)

Example 3 with NavigationItem

use of com.adobe.cq.wcm.core.components.models.NavigationItem in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class PageImplTest method testRedirectTarget.

@Test
@SuppressWarnings("deprecation")
protected void testRedirectTarget() {
    Page page = getPageUnderTest(REDIRECT_PAGE);
    loadHtmlPageItemsConfig(true);
    NavigationItem redirectTarget = page.getRedirectTarget();
    assertNotNull(redirectTarget);
    assertEquals("Templated Page", redirectTarget.getPage().getTitle());
    assertEquals("/core/content/page/templated-page.html", redirectTarget.getURL());
}
Also used : NavigationItem(com.adobe.cq.wcm.core.components.models.NavigationItem) Page(com.adobe.cq.wcm.core.components.models.Page) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with NavigationItem

use of com.adobe.cq.wcm.core.components.models.NavigationItem in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class BreadcrumbImplTest method checkBreadcrumbConsistency.

private void checkBreadcrumbConsistency(String[] expectedPages) {
    assertTrue("Expected that the returned breadcrumb will contain " + expectedPages.length + " items", underTest.getItems().size() == expectedPages.length);
    int index = 0;
    for (NavigationItem item : underTest.getItems()) {
        assertEquals(expectedPages[index++], item.getPage().getTitle());
    }
}
Also used : NavigationItem(com.adobe.cq.wcm.core.components.models.NavigationItem)

Example 5 with NavigationItem

use of com.adobe.cq.wcm.core.components.models.NavigationItem in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class PageImplTest method testRedirectTarget.

@Test
@SuppressWarnings("deprecation")
@Override
protected void testRedirectTarget() {
    Page page = getPageUnderTest(REDIRECT_PAGE);
    NavigationItem redirectTarget = page.getRedirectTarget();
    assertNotNull(redirectTarget);
    assertEquals("Templated Page", redirectTarget.getPage().getTitle());
    assertEquals("/core/content/page/templated-page.html", redirectTarget.getURL());
    assertValidLink(redirectTarget.getLink(), "/content/page/templated-page.html", context.request());
}
Also used : NavigationItem(com.adobe.cq.wcm.core.components.models.NavigationItem) Page(com.adobe.cq.wcm.core.components.models.Page) Test(org.junit.jupiter.api.Test)

Aggregations

NavigationItem (com.adobe.cq.wcm.core.components.models.NavigationItem)12 Test (org.junit.jupiter.api.Test)6 LanguageNavigationItem (com.adobe.cq.wcm.core.components.models.LanguageNavigationItem)5 LanguageNavigation (com.adobe.cq.wcm.core.components.models.LanguageNavigation)4 Page (com.day.cq.wcm.api.Page)3 Page (com.adobe.cq.wcm.core.components.models.Page)2 ArrayList (java.util.ArrayList)2 PageFilter (com.day.cq.wcm.api.PageFilter)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1