Search in sources :

Example 1 with ListItem

use of com.adobe.cq.wcm.core.components.models.ListItem in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class TeaserImplTest method testTeaserWithActions.

@Test
protected void testTeaserWithActions() {
    Teaser teaser = getTeaserUnderTest(TEASER_7);
    assertTrue(teaser.isActionsEnabled(), "Expected teaser with actions");
    assertEquals(2, teaser.getActions().size(), "Expected to find two actions");
    ListItem action = teaser.getActions().get(0);
    assertEquals("http://www.adobe.com", action.getPath(), "Action link does not match");
    assertEquals("Adobe", action.getTitle(), "Action text does not match");
    Utils.testJSONExport(teaser, Utils.getTestExporterJSONPath(testBase, "teaser9"));
}
Also used : Teaser(com.adobe.cq.wcm.core.components.models.Teaser) ListItem(com.adobe.cq.wcm.core.components.models.ListItem) Test(org.junit.jupiter.api.Test)

Example 2 with ListItem

use of com.adobe.cq.wcm.core.components.models.ListItem in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class TeaserImplTest method testTeaserWithTitleFromLinkedPageAndActions.

@Test
void testTeaserWithTitleFromLinkedPageAndActions() {
    Teaser teaser = getTeaserUnderTest(TEASER_12);
    assertEquals("Adobe", teaser.getTitle());
    List<ListItem> actions = teaser.getActions();
    assertEquals("http://www.adobe.com", actions.get(0).getPath());
    assertEquals("Adobe", actions.get(0).getTitle());
}
Also used : Teaser(com.adobe.cq.wcm.core.components.models.Teaser) ListItem(com.adobe.cq.wcm.core.components.models.ListItem) Test(org.junit.jupiter.api.Test)

Example 3 with ListItem

use of com.adobe.cq.wcm.core.components.models.ListItem in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class LayoutContainerImplTest method verifyContainerItems.

private void verifyContainerItems(Object[][] expectedItems, List<ListItem> items) {
    assertEquals(expectedItems.length, items.size(), "Item number mismatch");
    int index = 0;
    for (ListItem item : items) {
        assertEquals(expectedItems[index][1], item.getTitle(), "Item title mismatch");
        index++;
    }
}
Also used : ListItem(com.adobe.cq.wcm.core.components.models.ListItem)

Example 4 with ListItem

use of com.adobe.cq.wcm.core.components.models.ListItem in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class TeaserImplTest method testTeaserWithTitleNotFromLinkedPageAndActions.

@Test
void testTeaserWithTitleNotFromLinkedPageAndActions() {
    Teaser teaser = getTeaserUnderTest(TEASER_11);
    assertEquals("Teaser", teaser.getTitle());
    List<ListItem> actions = teaser.getActions();
    assertEquals("http://www.adobe.com", actions.get(0).getPath());
    assertEquals("Adobe", actions.get(0).getTitle());
    assertEquals("/content/teasers", actions.get(1).getPath());
    assertEquals("Teasers", actions.get(1).getTitle());
}
Also used : Teaser(com.adobe.cq.wcm.core.components.models.Teaser) ListItem(com.adobe.cq.wcm.core.components.models.ListItem) Test(org.junit.jupiter.api.Test)

Example 5 with ListItem

use of com.adobe.cq.wcm.core.components.models.ListItem in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class ListImplTest method testListRenderedAsTeaserItems.

@Test
protected void testListRenderedAsTeaserItems() {
    List list = getListUnderTest(LIST_20);
    assertEquals(3, list.getListItems().size());
    Collection<ListItem> items = list.getListItems();
    // The featured image of the page exists: the featured image node of the page is used to render the teaser item
    ListItem item0 = (ListItem) items.toArray()[0];
    Resource teaserResource0 = item0.getTeaserResource();
    ValueMap teaserProperties = teaserResource0.getValueMap();
    String linkURL = teaserProperties.get("linkURL", String.class);
    String fileReference = teaserProperties.get("fileReference", String.class);
    String title = teaserProperties.get("jcr:title", String.class);
    String description = teaserProperties.get("jcr:description", String.class);
    assertEquals("/content/list/pages/page_1/page_1_1/jcr:content/cq:featuredimage", teaserResource0.getPath(), "image resource: path");
    assertEquals("core/wcm/components/teaser/v2/teaser", teaserResource0.getResourceType(), "image resource: resource type");
    assertEquals("/content/list/pages/page_1/page_1_1", linkURL, "image resource: linkURL");
    assertEquals("/content/dam/core/images/Adobe_Systems_logo_and_wordmark.png", fileReference, "image resource: fileReference");
    assertEquals("Page 1.1", title, "image resource: title");
    assertEquals("Description for Page 1.1", description, "image resource: description");
    // The featured image of the page does not exist: the content node of the page is used to render the teaser item
    ListItem item2 = (ListItem) items.toArray()[2];
    Resource teaserResource2 = item2.getTeaserResource();
    assertEquals("/content/list/pages/page_1/page_1_3/jcr:content", teaserResource2.getPath(), "image resource: path");
    Utils.testJSONExport(list, Utils.getTestExporterJSONPath(testBase, LIST_20));
}
Also used : ValueMap(org.apache.sling.api.resource.ValueMap) Resource(org.apache.sling.api.resource.Resource) List(com.adobe.cq.wcm.core.components.models.List) ListItem(com.adobe.cq.wcm.core.components.models.ListItem) Test(org.junit.jupiter.api.Test)

Aggregations

ListItem (com.adobe.cq.wcm.core.components.models.ListItem)15 Test (org.junit.jupiter.api.Test)5 Teaser (com.adobe.cq.wcm.core.components.models.Teaser)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Map (java.util.Map)3 LocalizationUtils (com.adobe.cq.wcm.core.components.internal.LocalizationUtils)2 LinkHandler (com.adobe.cq.wcm.core.components.internal.link.LinkHandler)2 PageListItemImpl (com.adobe.cq.wcm.core.components.internal.models.v1.PageListItemImpl)2 SearchImpl (com.adobe.cq.wcm.core.components.internal.models.v1.SearchImpl)2 PN_FRAGMENT_VARIATION_PATH (com.adobe.cq.wcm.core.components.models.ExperienceFragment.PN_FRAGMENT_VARIATION_PATH)2 Search (com.adobe.cq.wcm.core.components.models.Search)2 PredicateConverter (com.day.cq.search.PredicateConverter)2 PredicateGroup (com.day.cq.search.PredicateGroup)2 Query (com.day.cq.search.Query)2 QueryBuilder (com.day.cq.search.QueryBuilder)2 FulltextPredicateEvaluator (com.day.cq.search.eval.FulltextPredicateEvaluator)2 PathPredicateEvaluator (com.day.cq.search.eval.PathPredicateEvaluator)2 TypePredicateEvaluator (com.day.cq.search.eval.TypePredicateEvaluator)2 SearchResult (com.day.cq.search.result.SearchResult)2 LanguageManager (com.day.cq.wcm.api.LanguageManager)2