|
17 | 17 |
|
18 | 18 | import java.util.Objects;
|
19 | 19 |
|
20 |
| -import com.adobe.cq.ui.wcm.commons.config.NextGenDynamicMediaConfig; |
21 |
| -import com.adobe.cq.wcm.core.components.models.Component; |
22 |
| -import com.adobe.cq.wcm.core.components.testing.MockNextGenDynamicMediaConfig; |
23 | 20 | import org.apache.sling.api.resource.Resource;
|
24 | 21 | import org.apache.sling.api.resource.ValueMap;
|
25 | 22 | import org.junit.jupiter.api.BeforeEach;
|
|
28 | 25 |
|
29 | 26 | import com.adobe.cq.wcm.core.components.Utils;
|
30 | 27 | import com.adobe.cq.wcm.core.components.commons.link.Link;
|
| 28 | +import com.adobe.cq.wcm.core.components.models.Component; |
31 | 29 | import com.adobe.cq.wcm.core.components.models.ListItem;
|
32 | 30 | import com.adobe.cq.wcm.core.components.models.Teaser;
|
| 31 | +import com.adobe.cq.wcm.core.components.testing.MockNextGenDynamicMediaConfig; |
| 32 | +import com.day.cq.wcm.foundation.Image; |
33 | 33 | import io.wcm.testing.mock.aem.junit5.AemContextExtension;
|
34 | 34 |
|
35 | 35 | import static com.adobe.cq.wcm.core.components.internal.link.LinkTestUtils.assertValidLink;
|
36 | 36 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
37 |
| -import static org.junit.jupiter.api.Assertions.assertNotNull; |
38 | 37 | import static org.junit.jupiter.api.Assertions.assertNull;
|
39 | 38 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
40 |
| -import static org.mockito.Mockito.mock; |
41 | 39 |
|
42 | 40 | @ExtendWith(AemContextExtension.class)
|
43 | 41 | public class TeaserImplTest extends com.adobe.cq.wcm.core.components.internal.models.v1.TeaserImplTest {
|
44 | 42 |
|
45 | 43 | private static final String TEST_BASE = "/teaser/v2";
|
46 | 44 | private static final String TEASER_25 = TEST_ROOT_PAGE + TEST_ROOT_PAGE_GRID + "/teaser-25";
|
47 | 45 | private static final String TEASER_26 = TEST_ROOT_PAGE + TEST_ROOT_PAGE_GRID + "/teaser-26";
|
| 46 | + private static final String TEASER_27 = TEST_ROOT_PAGE + TEST_ROOT_PAGE_GRID + "/teaser-27"; |
| 47 | + private static final String TEASER_28 = TEST_ROOT_PAGE + TEST_ROOT_PAGE_GRID + "/teaser-28"; |
48 | 48 |
|
49 | 49 | @BeforeEach
|
50 | 50 | protected void setUp() {
|
@@ -206,4 +206,28 @@ protected void testTeaserWithNgdmImage() {
|
206 | 206 | assertEquals("Teasers Test", teaser.getTitle());
|
207 | 207 | Utils.testJSONExport(teaser, Utils.getTestExporterJSONPath(testBase, "teaser26"));
|
208 | 208 | }
|
| 209 | + |
| 210 | + @Test |
| 211 | + protected void testTeaserWithImageAndLinkAndNoTitleAndPretitleAndNoDescription() { |
| 212 | + Teaser teaser = getTeaserUnderTest(TEASER_27); |
| 213 | + assertEquals("Teaser Pre-title", teaser.getPretitle()); |
| 214 | + assertNull(teaser.getTitle()); |
| 215 | + assertNull(teaser.getDescription()); |
| 216 | + ValueMap imageValueMap = teaser.getImageResource().getValueMap(); |
| 217 | + assertEquals("/content/page1", imageValueMap.get(Image.PN_LINK_URL)); |
| 218 | + assertTrue(imageValueMap.get(Teaser.PN_IMAGE_LINK_HIDDEN, Boolean.class)); |
| 219 | + Utils.testJSONExport(teaser, Utils.getTestExporterJSONPath(testBase, "teaser27")); |
| 220 | + } |
| 221 | + |
| 222 | + @Test |
| 223 | + protected void testTeaserWithImageAndLinkAndNoTitleAndNoPretitleAndNoDescription() { |
| 224 | + Teaser teaser = getTeaserUnderTest(TEASER_28); |
| 225 | + assertNull(teaser.getPretitle()); |
| 226 | + assertNull(teaser.getTitle()); |
| 227 | + assertNull(teaser.getDescription()); |
| 228 | + ValueMap imageValueMap = teaser.getImageResource().getValueMap(); |
| 229 | + assertEquals("/content/page1", imageValueMap.get(Image.PN_LINK_URL)); |
| 230 | + assertNull(imageValueMap.get(Teaser.PN_IMAGE_LINK_HIDDEN, Boolean.class)); |
| 231 | + Utils.testJSONExport(teaser, Utils.getTestExporterJSONPath(testBase, "teaser28")); |
| 232 | + } |
209 | 233 | }
|
0 commit comments