|
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;
|
| 46 | +import static io.wcm.handler.media.MediaNameConstants.PN_COMPONENT_MEDIA_RESPONSIVE_TYPE; |
45 | 47 | import static io.wcm.handler.media.MediaNameConstants.PN_MEDIA_REF_STANDARD;
|
46 | 48 | import static io.wcm.wcm.core.components.impl.models.helpers.DataLayerTestUtils.enableDataLayer;
|
47 | 49 | import static io.wcm.wcm.core.components.impl.models.v2.TeaserV2Impl.RESOURCE_TYPE;
|
|
69 | 71 | import com.adobe.cq.wcm.core.components.models.datalayer.ComponentData;
|
70 | 72 | import com.day.cq.dam.api.Asset;
|
71 | 73 | import com.day.cq.wcm.api.Page;
|
| 74 | +import com.day.cq.wcm.api.policies.ContentPolicyMapping; |
72 | 75 |
|
73 | 76 | import io.wcm.handler.link.type.ExternalLinkType;
|
74 | 77 | import io.wcm.handler.link.type.InternalLinkType;
|
@@ -199,6 +202,39 @@ void testTitleDescriptionImageFromPage() {
|
199 | 202 | assertValidMedia(underTest, "/content/dam/sample/sample.jpg/_jcr_content/renditions/original./sample.jpg");
|
200 | 203 | }
|
201 | 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 | + |
| 223 | + ContentPolicyMapping policyMapping = context.contentPolicyMapping(RESOURCE_TYPE, |
| 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"); |
| 228 | + context.create().resource(policyMapping.getPolicy().getPath() + "/" + NN_COMPONENT_MEDIA_RESPONSIVEIMAGE_SIZES, |
| 229 | + "widths", "45,90"); |
| 230 | + |
| 231 | + Teaser underTest = AdaptTo.notNull(context.request(), Teaser.class); |
| 232 | + |
| 233 | + assertEquals("Page Title", underTest.getTitle()); |
| 234 | + assertEquals("Page Description", underTest.getDescription()); |
| 235 | + assertValidMedia(underTest, "/content/dam/sample/sample.jpg/_jcr_content/renditions/original.image_file.90.90.35,0,125,90.file/sample.jpg"); |
| 236 | + } |
| 237 | + |
202 | 238 | @Test
|
203 | 239 | void testTitleDescriptionFromPage_HtmlReservedChars() {
|
204 | 240 | Page targetPage = context.create().page(page, "page1", null,
|
|
0 commit comments