Skip to content

Commit 168bebb

Browse files
committed
split into two separate unit tests
1 parent 3a55f0a commit 168bebb

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

Diff for: bundles/core/src/test/java/io/wcm/wcm/core/components/impl/models/v2/TeaserV2ImplTest.java

+33-7
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040
import static io.wcm.handler.link.LinkNameConstants.PN_LINK_EXTERNAL_REF;
4141
import static io.wcm.handler.link.LinkNameConstants.PN_LINK_TYPE;
4242
import static io.wcm.handler.link.LinkNameConstants.PN_LINK_WINDOW_TARGET;
43+
import static io.wcm.handler.media.MediaNameConstants.NN_COMPONENT_MEDIA_RESPONSIVEIMAGE_SIZES;
4344
import static io.wcm.handler.media.MediaNameConstants.PN_COMPONENT_MEDIA_AUTOCROP;
4445
import static io.wcm.handler.media.MediaNameConstants.PN_COMPONENT_MEDIA_FORMATS;
45-
import static io.wcm.handler.media.MediaNameConstants.PN_MEDIA_REF_STANDARD;
4646
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;
4848
import static io.wcm.wcm.core.components.impl.models.helpers.DataLayerTestUtils.enableDataLayer;
4949
import static io.wcm.wcm.core.components.impl.models.v2.TeaserV2Impl.RESOURCE_TYPE;
5050
import static io.wcm.wcm.core.components.testcontext.AppAemContext.CONTENT_ROOT;
@@ -61,7 +61,6 @@
6161
import static org.junit.jupiter.api.Assertions.assertNull;
6262
import static org.junit.jupiter.api.Assertions.assertTrue;
6363

64-
import com.day.cq.wcm.api.policies.ContentPolicyMapping;
6564
import org.apache.sling.api.resource.Resource;
6665
import org.junit.jupiter.api.BeforeEach;
6766
import org.junit.jupiter.api.Test;
@@ -72,6 +71,7 @@
7271
import com.adobe.cq.wcm.core.components.models.datalayer.ComponentData;
7372
import com.day.cq.dam.api.Asset;
7473
import com.day.cq.wcm.api.Page;
74+
import com.day.cq.wcm.api.policies.ContentPolicyMapping;
7575

7676
import io.wcm.handler.link.type.ExternalLinkType;
7777
import io.wcm.handler.link.type.InternalLinkType;
@@ -194,11 +194,37 @@ void testTitleDescriptionImageFromPage() {
194194
PN_DESCRIPTION_FROM_PAGE, true,
195195
PN_IMAGE_FROM_PAGE_IMAGE, true,
196196
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+
197223
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");
202228
context.create().resource(policyMapping.getPolicy().getPath() + "/" + NN_COMPONENT_MEDIA_RESPONSIVEIMAGE_SIZES,
203229
"widths", "45,90");
204230

0 commit comments

Comments
 (0)