Search in sources :

Example 1 with CloudConfiguration

use of com.adobe.acs.commons.cloudconfig.CloudConfiguration in project acs-aem-commons by Adobe-Consulting-Services.

the class CloudConfigurationListImplTest method valid.

@SuppressWarnings("unchecked")
@Test
public void valid() throws IOException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
    MockRequestPathInfo requestPathInfo = (MockRequestPathInfo) context.request().getRequestPathInfo();
    requestPathInfo.setSuffix("/apps/core/wcm/templates/marketocloudconfig");
    CloudConfigurationList list = new CloudConfigurationListImpl(context.request());
    assertNotNull(list);
    Field field = list.getClass().getDeclaredField("configs");
    field.setAccessible(true);
    assertNotNull(field.get(list));
    CloudConfiguration config = new CloudConfigurationImpl(context.resourceResolver().getResource("/conf/test"));
    ((List<CloudConfiguration>) field.get(list)).add(config);
    assertNotNull(list.getCloudConfigurations());
    assertEquals(1, list.getCloudConfigurations().size());
    config = list.getCloudConfigurations().get(0);
    assertNotNull(config);
    assertEquals("/conf/test", config.getItemPath());
    assertEquals("/", config.getConfigPath());
}
Also used : Field(java.lang.reflect.Field) MockRequestPathInfo(org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo) CloudConfigurationList(com.adobe.acs.commons.cloudconfig.CloudConfigurationList) CloudConfiguration(com.adobe.acs.commons.cloudconfig.CloudConfiguration) CloudConfigurationList(com.adobe.acs.commons.cloudconfig.CloudConfigurationList) List(java.util.List) Test(org.junit.Test)

Aggregations

CloudConfiguration (com.adobe.acs.commons.cloudconfig.CloudConfiguration)1 CloudConfigurationList (com.adobe.acs.commons.cloudconfig.CloudConfigurationList)1 Field (java.lang.reflect.Field)1 List (java.util.List)1 MockRequestPathInfo (org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo)1 Test (org.junit.Test)1