Search in sources :

Example 1 with CloudConfigurationList

use of com.adobe.acs.commons.cloudconfig.CloudConfigurationList 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)

Example 2 with CloudConfigurationList

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

the class CloudConfigurationListImplTest method invalid.

@Test
public void invalid() {
    MockRequestPathInfo requestPathInfo = (MockRequestPathInfo) context.request().getRequestPathInfo();
    requestPathInfo.setSuffix("");
    CloudConfigurationList list = new CloudConfigurationListImpl(context.request());
    assertNotNull(list);
    assertNotNull(list.getCloudConfigurations());
    assertEquals(0, list.getCloudConfigurations().size());
}
Also used : MockRequestPathInfo(org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo) CloudConfigurationList(com.adobe.acs.commons.cloudconfig.CloudConfigurationList) Test(org.junit.Test)

Aggregations

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