Search in sources :

Example 11 with ConfigurationData

use of org.apache.sling.caconfig.management.ConfigurationData in project sling by apache.

the class ConfigurationDataImplTest method testIgnoreProperties.

@Test
public void testIgnoreProperties() {
    Resource resource = context.create().resource("/conf/testIgnoreProps", "prop1", "value1", "prop4", true, "jcr:primaryType", "myType");
    ConfigurationData underTest = new ConfigurationDataImpl(null, resource, resource, null, contextResource, "test", configurationManager, configurationManagementSettings, configurationOverrideMultiplexer, configurationPersistenceStrategy, false, null);
    assertEquals(ImmutableSet.of("prop1", "prop4"), underTest.getPropertyNames());
    assertNull(underTest.getValues().get("jcr:primaryType"));
    assertNull(underTest.getEffectiveValues().get("jcr:primaryType"));
}
Also used : Resource(org.apache.sling.api.resource.Resource) ConfigurationData(org.apache.sling.caconfig.management.ConfigurationData) Test(org.junit.Test)

Example 12 with ConfigurationData

use of org.apache.sling.caconfig.management.ConfigurationData in project sling by apache.

the class ConfigurationManagerImplNoDefaultTest method testGet_NoConfigResource.

@Test
public void testGet_NoConfigResource() {
    ConfigurationData configData = underTest.getConfiguration(contextResourceNoConfig, CONFIG_NAME);
    assertNotNull(configData);
    assertEquals(ImmutableSet.of("prop1", "prop2", "prop3"), configData.getPropertyNames());
    assertNull(configData.getValues().get("prop1", String.class));
    assertEquals((Integer) 5, configData.getEffectiveValues().get("prop3", 0));
    assertFalse(configData.getValueInfo("prop1").isInherited());
    assertFalse(configData.getValueInfo("prop3").isInherited());
}
Also used : ConfigurationData(org.apache.sling.caconfig.management.ConfigurationData) Test(org.junit.Test)

Example 13 with ConfigurationData

use of org.apache.sling.caconfig.management.ConfigurationData in project sling by apache.

the class ConfigurationManagerImplNoDefaultTest method testNewCollectionItem.

@Test
public void testNewCollectionItem() {
    ConfigurationData newItem = underTest.newCollectionItem(contextResourceNoConfig, CONFIG_COL_NAME);
    assertNotNull(newItem);
    assertEquals((Integer) 5, newItem.getEffectiveValues().get("prop3", 0));
}
Also used : ConfigurationData(org.apache.sling.caconfig.management.ConfigurationData) Test(org.junit.Test)

Example 14 with ConfigurationData

use of org.apache.sling.caconfig.management.ConfigurationData in project sling by apache.

the class ConfigurationManagerImplTest method testGetConfiguration.

@Test
public void testGetConfiguration() {
    ConfigurationData configData = underTest.getConfiguration(contextResource, CONFIG_NAME);
    assertNotNull(configData);
    assertFalse(configData.isInherited());
    assertEquals(ImmutableSet.of("prop1", "prop2", "prop3", "prop4"), configData.getPropertyNames());
    assertEquals("value1", configData.getValues().get("prop1", String.class));
    assertEquals((Integer) 5, configData.getEffectiveValues().get("prop3", 0));
    assertFalse(configData.getValueInfo("prop1").isInherited());
    assertFalse(configData.getValueInfo("prop3").isInherited());
    assertFalse(configData.getValues().get(ConfigurationDefNameConstants.PROPERTY_CONFIG_PROPERTY_INHERIT, false));
}
Also used : ConfigurationData(org.apache.sling.caconfig.management.ConfigurationData) Test(org.junit.Test)

Example 15 with ConfigurationData

use of org.apache.sling.caconfig.management.ConfigurationData in project sling by apache.

the class ConfigurationManagerImplTest method testPersistConfigurationCollection_Nested.

@Test
public void testPersistConfigurationCollection_Nested() throws Exception {
    underTest.persistConfigurationCollection(contextResourceLevel2, getConfigResolvePath(CONFIG_NESTED_NAME) + "/propSubList", new ConfigurationCollectionPersistData(ImmutableList.of(new ConfigurationPersistData(ImmutableMap.<String, Object>of("prop1", "value1_persist")).collectionItemName("item1"), new ConfigurationPersistData(ImmutableMap.<String, Object>of("prop1", "value2_persist")).collectionItemName("item2"), new ConfigurationPersistData(ImmutableMap.<String, Object>of("prop1", "value3_persist")).collectionItemName("item3"))));
    context.resourceResolver().commit();
    ConfigurationData configData = underTest.getConfiguration(contextResourceLevel2, CONFIG_NESTED_NAME);
    ConfigurationData[] subListData = configData.getValues().get("propSubList", ConfigurationData[].class);
    assertEquals(3, subListData.length);
    assertEquals("value1_persist", subListData[0].getValues().get("prop1", String.class));
    assertEquals("value2_persist", subListData[1].getValues().get("prop1", String.class));
    assertEquals("value3_persist", subListData[2].getValues().get("prop1", String.class));
}
Also used : ConfigurationCollectionPersistData(org.apache.sling.caconfig.spi.ConfigurationCollectionPersistData) ConfigurationPersistData(org.apache.sling.caconfig.spi.ConfigurationPersistData) ConfigurationData(org.apache.sling.caconfig.management.ConfigurationData) Test(org.junit.Test)

Aggregations

ConfigurationData (org.apache.sling.caconfig.management.ConfigurationData)34 Test (org.junit.Test)31 ValueMap (org.apache.sling.api.resource.ValueMap)5 ConfigurationCollectionData (org.apache.sling.caconfig.management.ConfigurationCollectionData)4 ConfigurationMetadata (org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata)4 Resource (org.apache.sling.api.resource.Resource)3 DummyConfigurationOverrideProvider (org.apache.sling.caconfig.impl.override.DummyConfigurationOverrideProvider)2 ConfigurationPersistData (org.apache.sling.caconfig.spi.ConfigurationPersistData)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 ResettableIterator (org.apache.commons.collections.ResettableIterator)1 ListIteratorWrapper (org.apache.commons.collections.iterators.ListIteratorWrapper)1 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)1 ContextResource (org.apache.sling.caconfig.resource.spi.ContextResource)1 ConfigurationCollectionPersistData (org.apache.sling.caconfig.spi.ConfigurationCollectionPersistData)1