Search in sources :

Example 1 with PageRootProvider

use of com.adobe.acs.commons.wcm.PageRootProvider in project acs-aem-commons by Adobe-Consulting-Services.

the class SharedComponentPropertiesBindingsValuesProviderTest method setUp.

@Before
public void setUp() throws Exception {
    resource = mock(Resource.class);
    pageRootProvider = mock(PageRootProvider.class);
    page = mock(Page.class);
    bindings = new SimpleBindings();
    component = mock(Component.class);
    sharedPropsResource = mock(Resource.class);
    globalPropsResource = mock(Resource.class);
    resourceResolver = mock(ResourceResolver.class);
    componentManager = mock(ComponentManager.class);
    String globalPropsPath = SITE_ROOT + "/jcr:content/" + SharedComponentProperties.NN_GLOBAL_COMPONENT_PROPERTIES;
    String sharedPropsPath = SITE_ROOT + "/jcr:content/" + SharedComponentProperties.NN_SHARED_COMPONENT_PROPERTIES + "/" + RESOURCE_TYPE;
    bindings.put("resource", resource);
    when(resource.getResourceResolver()).thenReturn(resourceResolver);
    when(resourceResolver.getResource(sharedPropsPath)).thenReturn(sharedPropsResource);
    when(resourceResolver.getResource(globalPropsPath)).thenReturn(globalPropsResource);
    when(resourceResolver.adaptTo(ComponentManager.class)).thenReturn(componentManager);
    when(componentManager.getComponentOfResource(resource)).thenReturn(component);
    when(page.getPath()).thenReturn(SITE_ROOT);
    when(pageRootProvider.getRootPage(resource)).thenReturn(page);
    when(component.getResourceType()).thenReturn(RESOURCE_TYPE);
    when(sharedPropsResource.getName()).thenReturn("Shared Properties Resource");
    when(globalPropsResource.getName()).thenReturn("Global Properties Resource");
    sharedProps = new ValueMapDecorator(new HashMap<String, Object>());
    globalProps = new ValueMapDecorator(new HashMap<String, Object>());
    sharedProps.put("shared", "value");
    globalProps.put("global", "value");
    when(globalPropsResource.getValueMap()).thenReturn(globalProps);
    when(sharedPropsResource.getValueMap()).thenReturn(sharedProps);
}
Also used : HashMap(java.util.HashMap) SimpleBindings(javax.script.SimpleBindings) Resource(org.apache.sling.api.resource.Resource) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) ComponentManager(com.day.cq.wcm.api.components.ComponentManager) ValueMapDecorator(org.apache.sling.api.wrappers.ValueMapDecorator) Page(com.day.cq.wcm.api.Page) Component(com.day.cq.wcm.api.components.Component) PageRootProvider(com.adobe.acs.commons.wcm.PageRootProvider) Before(org.junit.Before)

Aggregations

PageRootProvider (com.adobe.acs.commons.wcm.PageRootProvider)1 Page (com.day.cq.wcm.api.Page)1 Component (com.day.cq.wcm.api.components.Component)1 ComponentManager (com.day.cq.wcm.api.components.ComponentManager)1 HashMap (java.util.HashMap)1 SimpleBindings (javax.script.SimpleBindings)1 Resource (org.apache.sling.api.resource.Resource)1 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)1 ValueMapDecorator (org.apache.sling.api.wrappers.ValueMapDecorator)1 Before (org.junit.Before)1