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);
}
Aggregations