Search in sources :

Example 1 with List

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

the class ListImplTest method testOrderByModificationDate.

@Test
public void testOrderByModificationDate() throws Exception {
    Resource resource = context.currentResource("/content/list/listTypes/staticOrderByModificationDateListType");
    slingBindings.put(WCMBindings.PROPERTIES, resource.adaptTo(ValueMap.class));
    slingBindings.put(WCMBindings.CURRENT_STYLE, new MockStyle(resource));
    List list = context.request().adaptTo(List.class);
    checkListConsistency(list, new String[] { "Page 2", "Page 1" });
}
Also used : ValueMap(org.apache.sling.api.resource.ValueMap) Resource(org.apache.sling.api.resource.Resource) MockStyle(com.adobe.cq.wcm.core.components.context.MockStyle) List(com.adobe.cq.wcm.core.components.models.List) Test(org.junit.Test)

Example 2 with List

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

the class ListImplTest method testTagsListType.

@Test
public void testTagsListType() throws Exception {
    Resource resource = context.currentResource("/content/list/listTypes/tagsListType");
    slingBindings.put(WCMBindings.PROPERTIES, resource.adaptTo(ValueMap.class));
    slingBindings.put(WCMBindings.CURRENT_STYLE, new MockStyle(resource));
    List list = context.request().adaptTo(List.class);
    assertEquals(1, list.getItems().size());
}
Also used : ValueMap(org.apache.sling.api.resource.ValueMap) Resource(org.apache.sling.api.resource.Resource) MockStyle(com.adobe.cq.wcm.core.components.context.MockStyle) List(com.adobe.cq.wcm.core.components.models.List) Test(org.junit.Test)

Example 3 with List

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

the class ListImplTest method testSearchListType.

@Test
public void testSearchListType() throws Exception {
    SearchResult searchResult = mock(SearchResult.class);
    Hit hit = mock(Hit.class);
    when(mockSimpleSearch.getResult()).thenReturn(searchResult);
    when(searchResult.getHits()).thenReturn(Collections.singletonList(hit));
    Resource contentResource = context.currentResource("/content/list/pages/page_1/jcr:content");
    when(hit.getResource()).thenReturn(contentResource);
    Resource resource = context.currentResource("/content/list/listTypes/searchListType");
    slingBindings.put(WCMBindings.PROPERTIES, resource.adaptTo(ValueMap.class));
    slingBindings.put(WCMBindings.CURRENT_STYLE, new MockStyle(resource));
    List list = context.request().adaptTo(List.class);
    assertEquals(1, list.getItems().size());
}
Also used : Hit(com.day.cq.search.result.Hit) ValueMap(org.apache.sling.api.resource.ValueMap) Resource(org.apache.sling.api.resource.Resource) MockStyle(com.adobe.cq.wcm.core.components.context.MockStyle) SearchResult(com.day.cq.search.result.SearchResult) List(com.adobe.cq.wcm.core.components.models.List) Test(org.junit.Test)

Example 4 with List

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

the class ListImplTest method testOrderByModificationDateDesc.

@Test
public void testOrderByModificationDateDesc() throws Exception {
    Resource resource = context.currentResource("/content/list/listTypes/staticOrderByModificationDateDescListType");
    slingBindings.put(WCMBindings.PROPERTIES, resource.adaptTo(ValueMap.class));
    slingBindings.put(WCMBindings.CURRENT_STYLE, new MockStyle(resource));
    List list = context.request().adaptTo(List.class);
    checkListConsistency(list, new String[] { "Page 1", "Page 2" });
}
Also used : ValueMap(org.apache.sling.api.resource.ValueMap) Resource(org.apache.sling.api.resource.Resource) MockStyle(com.adobe.cq.wcm.core.components.context.MockStyle) List(com.adobe.cq.wcm.core.components.models.List) Test(org.junit.Test)

Example 5 with List

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

the class ListImplTest method testStaticListType.

@Test
public void testStaticListType() {
    Resource resource = context.currentResource("/content/list/listTypes/staticListType");
    slingBindings.put(WCMBindings.PROPERTIES, resource.adaptTo(ValueMap.class));
    slingBindings.put(WCMBindings.CURRENT_STYLE, new MockStyle(resource));
    List list = context.request().adaptTo(List.class);
    assertEquals(2, list.getItems().size());
}
Also used : ValueMap(org.apache.sling.api.resource.ValueMap) Resource(org.apache.sling.api.resource.Resource) MockStyle(com.adobe.cq.wcm.core.components.context.MockStyle) List(com.adobe.cq.wcm.core.components.models.List) Test(org.junit.Test)

Aggregations

List (com.adobe.cq.wcm.core.components.models.List)32 Test (org.junit.jupiter.api.Test)20 Resource (org.apache.sling.api.resource.Resource)13 ValueMap (org.apache.sling.api.resource.ValueMap)13 MockStyle (com.adobe.cq.wcm.core.components.context.MockStyle)11 Test (org.junit.Test)11 SearchResult (com.day.cq.search.result.SearchResult)3 SimpleSearch (com.day.cq.search.SimpleSearch)2 ComponentExporter (com.adobe.cq.export.json.ComponentExporter)1 ExporterConstants (com.adobe.cq.export.json.ExporterConstants)1 ListItem (com.adobe.cq.wcm.core.components.models.ListItem)1 AbstractComponentImpl (com.adobe.cq.wcm.core.components.util.AbstractComponentImpl)1 Predicate (com.day.cq.search.Predicate)1 Hit (com.day.cq.search.result.Hit)1 TagManager (com.day.cq.tagging.TagManager)1 NameConstants (com.day.cq.wcm.api.NameConstants)1 Page (com.day.cq.wcm.api.Page)1 Style (com.day.cq.wcm.api.designer.Style)1 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)1 Serializable (java.io.Serializable)1