Search in sources :

Example 6 with Resource

use of org.apache.sling.api.resource.Resource 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 7 with Resource

use of org.apache.sling.api.resource.Resource 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)

Example 8 with Resource

use of org.apache.sling.api.resource.Resource in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class ListImplTest method testProperties.

@Test
public void testProperties() throws Exception {
    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);
    assertTrue(list.showDescription());
    assertTrue(list.showModificationDate());
    assertTrue(list.linkItems());
}
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 9 with Resource

use of org.apache.sling.api.resource.Resource in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class ListImplTest method testChildrenListType.

@Test
public void testChildrenListType() throws Exception {
    Resource resource = context.currentResource("/content/list/listTypes/childrenListType");
    slingBindings.put(WCMBindings.PROPERTIES, resource.adaptTo(ValueMap.class));
    slingBindings.put(WCMBindings.CURRENT_STYLE, new MockStyle(resource));
    List list = context.request().adaptTo(List.class);
    assertEquals(3, 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 10 with Resource

use of org.apache.sling.api.resource.Resource in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class OptionsImplTest method testRadioOptionsType.

@Test
public void testRadioOptionsType() throws Exception {
    Resource optionsRes = context.currentResource(CONTENT_ROOT + "/radio");
    slingBindings.put(WCMBindings.PROPERTIES, optionsRes.adaptTo(ValueMap.class));
    slingBindings.put(RESOURCE_PROPERTY, optionsRes);
    Options options = context.request().adaptTo(Options.class);
    assertEquals(Type.RADIO, options.getType());
}
Also used : Options(com.adobe.cq.wcm.core.components.models.form.Options) RequestDispatcherOptions(org.apache.sling.api.request.RequestDispatcherOptions) ValueMap(org.apache.sling.api.resource.ValueMap) Resource(org.apache.sling.api.resource.Resource) Test(org.junit.Test)

Aggregations

Resource (org.apache.sling.api.resource.Resource)1569 Test (org.junit.Test)695 ValueMap (org.apache.sling.api.resource.ValueMap)338 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)260 NonExistingResource (org.apache.sling.api.resource.NonExistingResource)164 HashMap (java.util.HashMap)160 Node (javax.jcr.Node)151 ArrayList (java.util.ArrayList)137 ModifiableValueMap (org.apache.sling.api.resource.ModifiableValueMap)119 PersistenceException (org.apache.sling.api.resource.PersistenceException)114 Test (org.junit.jupiter.api.Test)72 Map (java.util.Map)70 SlingHttpServletRequest (org.apache.sling.api.SlingHttpServletRequest)70 HttpServletRequest (javax.servlet.http.HttpServletRequest)62 SyntheticResource (org.apache.sling.api.resource.SyntheticResource)60 FakeSlingHttpServletRequest (org.apache.sling.launchpad.testservices.exported.FakeSlingHttpServletRequest)59 LoginException (org.apache.sling.api.resource.LoginException)58 RepositoryException (javax.jcr.RepositoryException)54 Calendar (java.util.Calendar)50 Session (javax.jcr.Session)49