Search in sources :

Example 11 with Component

use of com.day.cq.wcm.api.components.Component in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class NavigationImplTest method getNavigationUnderTest.

protected Navigation getNavigationUnderTest(String resourcePath) {
    Utils.enableDataLayer(context, true);
    context.currentResource(resourcePath);
    MockSlingHttpServletRequest request = context.request();
    request.setContextPath("/core");
    Component component = mock(Component.class);
    when(component.getResourceType()).thenReturn(resourceType);
    SlingBindings slingBindings = (SlingBindings) request.getAttribute(SlingBindings.class.getName());
    slingBindings.put(WCMBindings.COMPONENT, component);
    request.setAttribute(SlingBindings.class.getName(), slingBindings);
    return request.adaptTo(Navigation.class);
}
Also used : SlingBindings(org.apache.sling.api.scripting.SlingBindings) MockSlingHttpServletRequest(org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest) Component(com.day.cq.wcm.api.components.Component)

Aggregations

Component (com.day.cq.wcm.api.components.Component)11 Resource (org.apache.sling.api.resource.Resource)5 ComponentManager (com.day.cq.wcm.api.components.ComponentManager)4 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)3 Page (com.day.cq.wcm.api.Page)2 HashMap (java.util.HashMap)2 SlingHttpServletRequest (org.apache.sling.api.SlingHttpServletRequest)2 ValueMap (org.apache.sling.api.resource.ValueMap)2 SlingBindings (org.apache.sling.api.scripting.SlingBindings)2 MockSlingHttpServletRequest (org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest)2 PageRootProvider (com.adobe.acs.commons.wcm.PageRootProvider)1 LinkHandler (com.adobe.cq.wcm.core.components.internal.link.LinkHandler)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 RepositoryException (javax.jcr.RepositoryException)1 SimpleBindings (javax.script.SimpleBindings)1 JspException (javax.servlet.jsp.JspException)1 JspWriter (javax.servlet.jsp.JspWriter)1