Search in sources :

Example 1 with ValueMapDecorator

use of com.adobe.cq.commerce.common.ValueMapDecorator in project acs-aem-commons by Adobe-Consulting-Services.

the class AssetsFolderPropertiesSupportTest method doGet.

@Test
public void doGet() throws Exception {
    final ValueMap graniteUiFormValues = new ValueMapDecorator(new HashMap<>());
    graniteUiFormValues.put("ootb", "ootb value");
    slingContext.create().resource("/content/dam/do-get/folder", ImmutableMap.<String, Object>builder().put("resource", "resource value").build());
    MockSlingHttpServletRequest request = new MockSlingHttpServletRequest(slingContext.resourceResolver(), osgiContext.bundleContext());
    MockRequestPathInfo requestPathInfo = (MockRequestPathInfo) request.getRequestPathInfo();
    requestPathInfo.setResourcePath("wizard.html");
    requestPathInfo.setSuffix("/content/dam/do-get/folder");
    request.setAttribute("granite.ui.form.values", graniteUiFormValues);
    assetsFolderPropertiesSupport.doGet(request, response);
    ValueMap actual = (ValueMap) request.getAttribute("granite.ui.form.values");
    assertEquals("ootb value", actual.get("ootb", String.class));
    assertEquals("resource value", actual.get("resource", String.class));
}
Also used : MockRequestPathInfo(org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo) MockSlingHttpServletRequest(org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest) ValueMap(org.apache.sling.api.resource.ValueMap) ValueMapDecorator(com.adobe.cq.commerce.common.ValueMapDecorator) Test(org.junit.Test)

Example 2 with ValueMapDecorator

use of com.adobe.cq.commerce.common.ValueMapDecorator 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 3 with ValueMapDecorator

use of com.adobe.cq.commerce.common.ValueMapDecorator in project acs-aem-commons by Adobe-Consulting-Services.

the class TwitterAdapterFactoryTest method setup.

@Before
public void setup() {
    Map<String, Object> validOAuthConfig = new HashMap<>();
    validOAuthConfig.put("oauth.client.id", VALID_OAUTH_CLIENT_ID);
    validOAuthConfig.put("oauth.client.secret", VALID_OAUTH_SECRET);
    this.validOauthValueMap = new ValueMapDecorator(validOAuthConfig);
}
Also used : HashMap(java.util.HashMap) ValueMapDecorator(com.adobe.cq.commerce.common.ValueMapDecorator) Before(org.junit.Before)

Aggregations

ValueMapDecorator (com.adobe.cq.commerce.common.ValueMapDecorator)3 Page (com.day.cq.wcm.api.Page)1 ConfigurationManager (com.day.cq.wcm.webservicesupport.ConfigurationManager)1 HashMap (java.util.HashMap)1 Resource (org.apache.sling.api.resource.Resource)1 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)1 ValueMap (org.apache.sling.api.resource.ValueMap)1 MockRequestPathInfo (org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo)1 MockSlingHttpServletRequest (org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest)1 Before (org.junit.Before)1 Test (org.junit.Test)1