Search in sources :

Example 1 with PageImageThumbnail

use of com.adobe.cq.wcm.core.components.commons.editor.dialog.inherited.PageImageThumbnail in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class PageImageThumbnailTest method testPageImageThumbnailWithNonExistingResource.

@Test
void testPageImageThumbnailWithNonExistingResource() {
    MockSlingHttpServletRequest request = context.request();
    MockRequestPathInfo requestPathInfo = (MockRequestPathInfo) request.getRequestPathInfo();
    requestPathInfo.setSuffix(RESOURCE1);
    PageImageThumbnail pageImageThumbnail = request.adaptTo(PageImageThumbnail.class);
    if (pageImageThumbnail != null) {
        assertNull(pageImageThumbnail.getAlt(), "getAlt()");
        assertNull(pageImageThumbnail.getSrc(), "getSrc()");
    }
}
Also used : MockRequestPathInfo(org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo) MockSlingHttpServletRequest(org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest) PageImageThumbnail(com.adobe.cq.wcm.core.components.commons.editor.dialog.inherited.PageImageThumbnail) Test(org.junit.jupiter.api.Test)

Example 2 with PageImageThumbnail

use of com.adobe.cq.wcm.core.components.commons.editor.dialog.inherited.PageImageThumbnail in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class PageImageThumbnailTest method testPageImageThumbnailWithParam.

@Test
void testPageImageThumbnailWithParam() {
    context.currentResource(RESOURCE);
    MockSlingHttpServletRequest request = context.request();
    request.setParameterMap(ImmutableMap.of("item", RESOURCE));
    PageImageThumbnail pageImageThumbnail = request.adaptTo(PageImageThumbnail.class);
    if (pageImageThumbnail != null) {
        assertEquals("featured image alt", pageImageThumbnail.getAlt(), "getAlt()");
        assertEquals("/content/page/_jcr_content/_cq_featuredimage.coreimg.png", pageImageThumbnail.getSrc(), "getSrc()");
    }
}
Also used : MockSlingHttpServletRequest(org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest) PageImageThumbnail(com.adobe.cq.wcm.core.components.commons.editor.dialog.inherited.PageImageThumbnail) Test(org.junit.jupiter.api.Test)

Example 3 with PageImageThumbnail

use of com.adobe.cq.wcm.core.components.commons.editor.dialog.inherited.PageImageThumbnail in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class PageImageThumbnailTest method testPageImageThumbnailWithLinkURL.

@Test
void testPageImageThumbnailWithLinkURL() {
    context.currentResource(RESOURCE);
    MockSlingHttpServletRequest request = context.request();
    request.setParameterMap(ImmutableMap.of("item", RESOURCE, "pageLink", "/content/page1"));
    PageImageThumbnail pageImageThumbnail = request.adaptTo(PageImageThumbnail.class);
    if (pageImageThumbnail != null) {
        assertEquals("featured image alt for page 1", pageImageThumbnail.getAlt(), "getAlt()");
        assertEquals("/content/page1/_jcr_content/_cq_featuredimage.coreimg.png", pageImageThumbnail.getSrc(), "getSrc()");
    }
}
Also used : MockSlingHttpServletRequest(org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest) PageImageThumbnail(com.adobe.cq.wcm.core.components.commons.editor.dialog.inherited.PageImageThumbnail) Test(org.junit.jupiter.api.Test)

Example 4 with PageImageThumbnail

use of com.adobe.cq.wcm.core.components.commons.editor.dialog.inherited.PageImageThumbnail in project aem-core-wcm-components by adobe.

the class PageImageThumbnailTest method testPageImageThumbnailWithSuffix.

@Test
void testPageImageThumbnailWithSuffix() {
    context.currentResource(RESOURCE);
    MockSlingHttpServletRequest request = context.request();
    MockRequestPathInfo requestPathInfo = (MockRequestPathInfo) request.getRequestPathInfo();
    requestPathInfo.setSuffix(RESOURCE);
    requestPathInfo.setResourcePath(RESOURCE);
    PageImageThumbnail pageImageThumbnail = request.adaptTo(PageImageThumbnail.class);
    if (pageImageThumbnail != null) {
        assertEquals("featured image alt", pageImageThumbnail.getAlt(), "getAlt()");
        assertEquals("/content/page/_jcr_content/_cq_featuredimage.coreimg.png", pageImageThumbnail.getSrc(), "getSrc()");
        assertEquals("/content/page/jcr:content/root/responsivegrid/image", pageImageThumbnail.getComponentPath(), "getComponentPath()");
        assertEquals("/content/page/jcr:content/root/responsivegrid/image", pageImageThumbnail.getConfigPath(), "getConfigPath()");
        assertEquals("/content/page", pageImageThumbnail.getCurrentPagePath(), "getCurrentPagePath()");
    } else {
        fail("can't create page image thumnbail model");
    }
}
Also used : MockRequestPathInfo(org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo) MockSlingHttpServletRequest(org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest) PageImageThumbnail(com.adobe.cq.wcm.core.components.commons.editor.dialog.inherited.PageImageThumbnail) Test(org.junit.jupiter.api.Test)

Example 5 with PageImageThumbnail

use of com.adobe.cq.wcm.core.components.commons.editor.dialog.inherited.PageImageThumbnail in project aem-core-wcm-components by adobe.

the class PageImageThumbnailTest method testPageImageThumbnailWithoutParam.

@Test
void testPageImageThumbnailWithoutParam() {
    context.currentResource(RESOURCE);
    MockSlingHttpServletRequest request = context.request();
    PageImageThumbnail pageImageThumbnail = request.adaptTo(PageImageThumbnail.class);
    if (pageImageThumbnail != null) {
        assertNull(pageImageThumbnail.getAlt(), "getAlt()");
        assertNull(pageImageThumbnail.getSrc(), "getSrc()");
    }
}
Also used : MockSlingHttpServletRequest(org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest) PageImageThumbnail(com.adobe.cq.wcm.core.components.commons.editor.dialog.inherited.PageImageThumbnail) Test(org.junit.jupiter.api.Test)

Aggregations

PageImageThumbnail (com.adobe.cq.wcm.core.components.commons.editor.dialog.inherited.PageImageThumbnail)12 MockSlingHttpServletRequest (org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest)12 Test (org.junit.jupiter.api.Test)12 MockRequestPathInfo (org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo)4