Search in sources :

Example 1 with ConfigurationManager

use of com.day.cq.wcm.webservicesupport.ConfigurationManager in project acs-aem-commons by Adobe-Consulting-Services.

the class TwitterAdapterFactoryTest method setupPage.

private Page setupPage(ValueMap configData) {
    com.day.cq.wcm.webservicesupport.Configuration config = setupConfiguration(configData);
    String[] configPath = new String[] { "configpath " };
    Page page = mock(Page.class);
    Resource contentResource = mock(Resource.class);
    when(page.getContentResource()).thenReturn(contentResource);
    ResourceResolver resourceResolver = mock(ResourceResolver.class);
    when(contentResource.getResourceResolver()).thenReturn(resourceResolver);
    ConfigurationManager configurationManager = mock(ConfigurationManager.class);
    when(resourceResolver.adaptTo(ConfigurationManager.class)).thenReturn(configurationManager);
    when(contentResource.getValueMap()).thenReturn(new ValueMapDecorator(Collections.singletonMap(ConfigurationConstants.PN_CONFIGURATIONS, configPath)));
    when(configurationManager.getConfiguration("twitterconnect", configPath)).thenReturn(config);
    return page;
}
Also used : Resource(org.apache.sling.api.resource.Resource) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) ValueMapDecorator(com.adobe.cq.commerce.common.ValueMapDecorator) Page(com.day.cq.wcm.api.Page) ConfigurationManager(com.day.cq.wcm.webservicesupport.ConfigurationManager)

Example 2 with ConfigurationManager

use of com.day.cq.wcm.webservicesupport.ConfigurationManager in project acs-aem-commons by Adobe-Consulting-Services.

the class TwitterAdapterFactory method findTwitterConfiguration.

private com.day.cq.wcm.webservicesupport.Configuration findTwitterConfiguration(Page page) {
    ConfigurationManager configurationManager = page.getContentResource().getResourceResolver().adaptTo(ConfigurationManager.class);
    final HierarchyNodeInheritanceValueMap pageProperties = new HierarchyNodeInheritanceValueMap(page.getContentResource());
    final String[] services = pageProperties.getInherited(ConfigurationConstants.PN_CONFIGURATIONS, new String[0]);
    return configurationManager.getConfiguration(CLOUD_SERVICE_NAME, services);
}
Also used : HierarchyNodeInheritanceValueMap(com.day.cq.commons.inherit.HierarchyNodeInheritanceValueMap) ConfigurationManager(com.day.cq.wcm.webservicesupport.ConfigurationManager)

Aggregations

ConfigurationManager (com.day.cq.wcm.webservicesupport.ConfigurationManager)2 ValueMapDecorator (com.adobe.cq.commerce.common.ValueMapDecorator)1 HierarchyNodeInheritanceValueMap (com.day.cq.commons.inherit.HierarchyNodeInheritanceValueMap)1 Page (com.day.cq.wcm.api.Page)1 Resource (org.apache.sling.api.resource.Resource)1 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)1