use of com.day.cq.wcm.api.Page in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class PWAImplTest method setUp.
@BeforeEach
public void setUp() {
context.load().json("/pwa" + CoreComponentTestContext.TEST_CONTENT_JSON, SITES_PAGE_PATH);
resolver = context.resourceResolver();
resource = spy(resolver.getResource(SITES_PAGE_PATH));
mvp = resource.adaptTo(ModifiableValueMap.class);
when(resource.getPath()).thenReturn(SITES_PAGE_PATH);
ResourceResolver spyResolver = spy(resolver);
when(resource.getResourceResolver()).thenReturn(spyResolver);
Resource mockPWAResource = mock(Resource.class);
when(spyResolver.getResource(SITES_PAGE_PATH + "/" + JcrConstants.JCR_CONTENT)).thenReturn(mockPWAResource);
PageManager mockPageManager = mock(PageManager.class);
Page mockPage = mock(Page.class);
when(spyResolver.adaptTo(PageManager.class)).thenReturn(mockPageManager);
when(mockPageManager.getContainingPage(resource)).thenReturn(mockPage);
when(mockPage.getContentResource()).thenReturn(mockPWAResource);
when(mockPage.getPath()).thenReturn(SITES_PAGE_PATH);
Page mockParentPage = mock(Page.class);
when(mockPage.getParent()).thenReturn(mockParentPage);
mvp.put(PN_PWA_ENABLED, true);
mvp.put(PN_PWA_START_URL, SITES_PAGE_PATH + ".html");
when(mockPWAResource.getValueMap()).thenReturn(mvp);
}
use of com.day.cq.wcm.api.Page in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class LanguageNavigationSiteRootSelectionStrategyTest method testSiteRootFromContentPolicy.
@Test
void testSiteRootFromContentPolicy() throws PersistenceException {
// given
Page page = aemContext.pageManager().getPage("/content/languagenavigation/LOCALE-1/LOCALE-5/about");
deleteSiblings(page.getContentResource().getChild("root/languagenavigation-component-3"));
aemContext.contentPolicyMapping(LanguageNavigationImpl.RESOURCE_TYPE, "siteRoot", "/content/languagenavigation", "structureDepth", 3);
// when
Page siteRoot = subject.getSiteRoot(page);
int structureDepth = subject.getStructuralDepth(page);
// then
assertNotNull(siteRoot);
assertEquals("/content/languagenavigation", siteRoot.getPath());
assertEquals(3, structureDepth);
}
use of com.day.cq.wcm.api.Page in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class LanguageNavigationSiteRootSelectionStrategyTest method testSiteRootFromPageV2.
@Test
void testSiteRootFromPageV2() throws PersistenceException {
// given
Page page = aemContext.pageManager().getPage("/content/languagenavigation/LOCALE-1/LOCALE-5/about");
Resource languageNav = page.getContentResource().getChild("root/languagenavigation-component-2");
deleteSiblings(languageNav);
ModifiableValueMap properties = languageNav.adaptTo(ModifiableValueMap.class);
properties.put("sling:resourceType", com.adobe.cq.wcm.core.components.internal.models.v2.LanguageNavigationImpl.RESOURCE_TYPE);
languageNav.getResourceResolver().commit();
// when
Page siteRoot = subject.getSiteRoot(page);
int structureDepth = subject.getStructuralDepth(page);
// then
assertNotNull(siteRoot);
assertEquals("/content/languagenavigation", siteRoot.getPath());
assertEquals(2, structureDepth);
}
use of com.day.cq.wcm.api.Page in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class LanguageNavigationSiteRootSelectionStrategyTest method testSiteRootFromPage.
@Test
void testSiteRootFromPage() throws PersistenceException {
// given
Page page = aemContext.pageManager().getPage("/content/languagenavigation/LOCALE-1/LOCALE-5/about");
deleteSiblings(page.getContentResource().getChild("root/languagenavigation-component-2"));
// when
Page siteRoot = subject.getSiteRoot(page);
int structureDepth = subject.getStructuralDepth(page);
// then
assertNotNull(siteRoot);
assertEquals("/content/languagenavigation", siteRoot.getPath());
assertEquals(2, structureDepth);
}
use of com.day.cq.wcm.api.Page in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class LanguageNavigationSiteRootSelectionStrategyTest method testNoSiteRoot.
@Test
void testNoSiteRoot() throws PersistenceException {
// given
Page page = aemContext.pageManager().getPage("/content/languagenavigation/LOCALE-1/LOCALE-5/about");
deleteSiblings(page.getContentResource().getChild("root/languagenavigation-component-4"));
// when
Page siteRoot = subject.getSiteRoot(page);
int structureDepth = subject.getStructuralDepth(page);
// then
assertNull(siteRoot);
assertEquals(1, structureDepth);
}
Aggregations