Search in sources :

Example 11 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 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 12 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 testWithTeaserAndNoLink.

@Test
void testWithTeaserAndNoLink() {
    context.currentResource(TEASER1);
    MockSlingHttpServletRequest request = context.request();
    request.setParameterMap(ImmutableMap.of("item", TEASER1));
    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)

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