|
40 | 40 | import static io.wcm.handler.link.LinkNameConstants.PN_LINK_EXTERNAL_REF;
|
41 | 41 | import static io.wcm.handler.link.LinkNameConstants.PN_LINK_TYPE;
|
42 | 42 | import static io.wcm.handler.link.LinkNameConstants.PN_LINK_WINDOW_TARGET;
|
| 43 | +import static io.wcm.handler.media.MediaNameConstants.NN_COMPONENT_MEDIA_RESPONSIVEIMAGE_SIZES; |
43 | 44 | import static io.wcm.handler.media.MediaNameConstants.PN_COMPONENT_MEDIA_AUTOCROP;
|
44 | 45 | import static io.wcm.handler.media.MediaNameConstants.PN_COMPONENT_MEDIA_FORMATS;
|
45 |
| -import static io.wcm.handler.media.MediaNameConstants.PN_MEDIA_REF_STANDARD; |
46 | 46 | import static io.wcm.handler.media.MediaNameConstants.PN_COMPONENT_MEDIA_RESPONSIVE_TYPE;
|
47 |
| -import static io.wcm.handler.media.MediaNameConstants.NN_COMPONENT_MEDIA_RESPONSIVEIMAGE_SIZES; |
| 47 | +import static io.wcm.handler.media.MediaNameConstants.PN_MEDIA_REF_STANDARD; |
48 | 48 | import static io.wcm.wcm.core.components.impl.models.helpers.DataLayerTestUtils.enableDataLayer;
|
49 | 49 | import static io.wcm.wcm.core.components.impl.models.v2.TeaserV2Impl.RESOURCE_TYPE;
|
50 | 50 | import static io.wcm.wcm.core.components.testcontext.AppAemContext.CONTENT_ROOT;
|
|
61 | 61 | import static org.junit.jupiter.api.Assertions.assertNull;
|
62 | 62 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
63 | 63 |
|
64 |
| -import com.day.cq.wcm.api.policies.ContentPolicyMapping; |
65 | 64 | import org.apache.sling.api.resource.Resource;
|
66 | 65 | import org.junit.jupiter.api.BeforeEach;
|
67 | 66 | import org.junit.jupiter.api.Test;
|
|
72 | 71 | import com.adobe.cq.wcm.core.components.models.datalayer.ComponentData;
|
73 | 72 | import com.day.cq.dam.api.Asset;
|
74 | 73 | import com.day.cq.wcm.api.Page;
|
| 74 | +import com.day.cq.wcm.api.policies.ContentPolicyMapping; |
75 | 75 |
|
76 | 76 | import io.wcm.handler.link.type.ExternalLinkType;
|
77 | 77 | import io.wcm.handler.link.type.InternalLinkType;
|
@@ -194,11 +194,37 @@ void testTitleDescriptionImageFromPage() {
|
194 | 194 | PN_DESCRIPTION_FROM_PAGE, true,
|
195 | 195 | PN_IMAGE_FROM_PAGE_IMAGE, true,
|
196 | 196 | PN_ALT_VALUE_FROM_PAGE_IMAGE, true));
|
| 197 | + |
| 198 | + Teaser underTest = AdaptTo.notNull(context.request(), Teaser.class); |
| 199 | + |
| 200 | + assertEquals("Page Title", underTest.getTitle()); |
| 201 | + assertEquals("Page Description", underTest.getDescription()); |
| 202 | + assertValidMedia(underTest, "/content/dam/sample/sample.jpg/_jcr_content/renditions/original./sample.jpg"); |
| 203 | + } |
| 204 | + |
| 205 | + @Test |
| 206 | + void testTitleDescriptionImageFromPage_WithContentPolicy() { |
| 207 | + Page targetPage = context.create().page(page, "page1", null, |
| 208 | + JCR_TITLE, "Page Title", |
| 209 | + JCR_DESCRIPTION, "Page Description"); |
| 210 | + context.create().resource(targetPage, NN_PAGE_FEATURED_IMAGE, |
| 211 | + PN_MEDIA_REF_STANDARD, asset.getPath()); |
| 212 | + context.currentResource(context.create().resource(page, "teaser", |
| 213 | + PROPERTY_RESOURCE_TYPE, RESOURCE_TYPE, |
| 214 | + JCR_TITLE, "Teaser Title", |
| 215 | + JCR_DESCRIPTION, "Teaser Description", |
| 216 | + PN_LINK_TYPE, InternalLinkType.ID, |
| 217 | + PN_LINK_CONTENT_REF, targetPage.getPath(), |
| 218 | + PN_TITLE_FROM_PAGE, true, |
| 219 | + PN_DESCRIPTION_FROM_PAGE, true, |
| 220 | + PN_IMAGE_FROM_PAGE_IMAGE, true, |
| 221 | + PN_ALT_VALUE_FROM_PAGE_IMAGE, true)); |
| 222 | + |
197 | 223 | ContentPolicyMapping policyMapping = context.contentPolicyMapping(RESOURCE_TYPE,
|
198 |
| - "jcr:title", "Teaser Mock Policy", |
199 |
| - PN_COMPONENT_MEDIA_FORMATS, MediaFormats.SQUARE.getName(), |
200 |
| - PN_COMPONENT_MEDIA_AUTOCROP, Boolean.TRUE, |
201 |
| - PN_COMPONENT_MEDIA_RESPONSIVE_TYPE, "imageSizes"); |
| 224 | + JCR_TITLE, "Teaser Mock Policy", |
| 225 | + PN_COMPONENT_MEDIA_FORMATS, MediaFormats.SQUARE.getName(), |
| 226 | + PN_COMPONENT_MEDIA_AUTOCROP, Boolean.TRUE, |
| 227 | + PN_COMPONENT_MEDIA_RESPONSIVE_TYPE, "imageSizes"); |
202 | 228 | context.create().resource(policyMapping.getPolicy().getPath() + "/" + NN_COMPONENT_MEDIA_RESPONSIVEIMAGE_SIZES,
|
203 | 229 | "widths", "45,90");
|
204 | 230 |
|
|
0 commit comments