Search in sources :

Example 21 with ConfigurationData

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

the class ConfigurationDataImplTest method testWithResourceOnly.

@Test
public void testWithResourceOnly() {
    ConfigurationData underTest = new ConfigurationDataImpl(null, configResource, configResource, null, contextResource, "test", configurationManager, configurationManagementSettings, configurationOverrideMultiplexer, configurationPersistenceStrategy, false, null);
    assertEquals("test", underTest.getConfigName());
    assertNull(underTest.getCollectionItemName());
    assertEquals(ImmutableSet.of("prop1", "prop4"), underTest.getPropertyNames());
    ValueMap values = underTest.getValues();
    assertEquals("value1", values.get("prop1", String.class));
    assertEquals(true, values.get("prop4", Boolean.class));
    ValueMap effectiveValues = underTest.getEffectiveValues();
    assertEquals("value1", effectiveValues.get("prop1", String.class));
    assertEquals(true, effectiveValues.get("prop4", Boolean.class));
    ValueInfo<?> prop1 = underTest.getValueInfo("prop1");
    assertNull(prop1.getPropertyMetadata());
    assertEquals("value1", prop1.getValue());
    assertEquals("value1", prop1.getEffectiveValue());
    ValueInfo<?> prop4 = underTest.getValueInfo("prop4");
    assertNull("prop4", prop4.getPropertyMetadata());
    assertEquals(true, prop4.getValue());
    assertEquals(true, prop4.getEffectiveValue());
}
Also used : ValueMap(org.apache.sling.api.resource.ValueMap) ConfigurationData(org.apache.sling.caconfig.management.ConfigurationData) Test(org.junit.Test)

Example 22 with ConfigurationData

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

the class ConfigurationManagerImplNoDefaultTest method testGet_NoConfigResource_NoConfigMetadata.

@Test
public void testGet_NoConfigResource_NoConfigMetadata() {
    when(configurationMetadataProvider.getConfigurationMetadata(CONFIG_NAME)).thenReturn(null);
    ConfigurationData configData = underTest.getConfiguration(contextResourceNoConfig, CONFIG_NAME);
    assertNull(configData);
}
Also used : ConfigurationData(org.apache.sling.caconfig.management.ConfigurationData) Test(org.junit.Test)

Example 23 with ConfigurationData

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

the class ConfigurationManagerImplNoDefaultTest method testNewCollectionItem_NoConfigMetadata.

@Test
public void testNewCollectionItem_NoConfigMetadata() {
    when(configurationMetadataProvider.getConfigurationMetadata(CONFIG_COL_NAME)).thenReturn(null);
    ConfigurationData newItem = underTest.newCollectionItem(contextResourceNoConfig, CONFIG_COL_NAME);
    assertNull(newItem);
}
Also used : ConfigurationData(org.apache.sling.caconfig.management.ConfigurationData) Test(org.junit.Test)

Example 24 with ConfigurationData

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

the class ConfigurationManagerImplTest method testGetConfiguration_WithResourceInheritance.

@Test
public void testGetConfiguration_WithResourceInheritance() {
    ConfigurationData configData = underTest.getConfiguration(contextResourceLevel2, CONFIG_NAME);
    assertNotNull(configData);
    assertTrue(configData.isInherited());
    assertEquals(ImmutableSet.of("prop1", "prop2", "prop3", "prop4"), configData.getPropertyNames());
    assertNull(configData.getValues().get("prop1", String.class));
    assertEquals("value1", configData.getEffectiveValues().get("prop1", String.class));
    assertEquals((Integer) 5, configData.getEffectiveValues().get("prop3", 0));
    String configPath = getConfigResolvePath("/conf/test/sling:configs/" + CONFIG_NAME);
    assertEquals(configPath, configData.getValueInfo("prop1").getConfigSourcePath());
    assertTrue(configData.getValueInfo("prop1").isInherited());
    assertFalse(configData.getValueInfo("prop3").isInherited());
    assertNull(configData.getValueInfo("prop3").getConfigSourcePath());
    assertFalse(configData.getValues().get(ConfigurationDefNameConstants.PROPERTY_CONFIG_PROPERTY_INHERIT, false));
}
Also used : ConfigurationData(org.apache.sling.caconfig.management.ConfigurationData) Test(org.junit.Test)

Example 25 with ConfigurationData

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

the class ConfigurationManagerImplTest method testGetConfiguration_WithPropertyInheritance.

@Test
public void testGetConfiguration_WithPropertyInheritance() {
    ConfigurationData configData = underTest.getConfiguration(contextResourceLevel3, CONFIG_NAME);
    assertNotNull(configData);
    assertFalse(configData.isInherited());
    assertTrue(configData.getPropertyNames().containsAll(ImmutableSet.of("prop1", "prop2", "prop3", "prop4", "prop5")));
    assertNull(configData.getValues().get("prop1", String.class));
    assertNull(configData.getValues().get("prop2", String.class));
    assertNull(configData.getValues().get("prop3", Integer.class));
    assertFalse(configData.getValues().get("prop4", Boolean.class));
    assertEquals("value5_level3", configData.getValues().get("prop5", String.class));
    assertEquals("value1", configData.getEffectiveValues().get("prop1", String.class));
    assertNull(configData.getEffectiveValues().get("prop2", String.class));
    assertEquals((Integer) 5, configData.getEffectiveValues().get("prop3", 0));
    assertFalse(configData.getEffectiveValues().get("prop4", Boolean.class));
    assertEquals("value5_level3", configData.getEffectiveValues().get("prop5", String.class));
    String configPath = getConfigResolvePath("/conf/test/sling:configs/" + CONFIG_NAME);
    String configPathLevel3 = getConfigResolvePath("/conf/test/level2/level3/sling:configs/" + CONFIG_NAME);
    assertTrue(configData.getValueInfo("prop1").isInherited());
    assertEquals(configPath, configData.getValueInfo("prop1").getConfigSourcePath());
    assertFalse(configData.getValueInfo("prop2").isInherited());
    assertNull(configData.getValueInfo("prop2").getConfigSourcePath());
    assertFalse(configData.getValueInfo("prop3").isInherited());
    assertNull(configData.getValueInfo("prop3").getConfigSourcePath());
    assertFalse(configData.getValueInfo("prop4").isInherited());
    assertEquals(configPathLevel3, configData.getValueInfo("prop4").getConfigSourcePath());
    assertFalse(configData.getValueInfo("prop5").isInherited());
    assertEquals(configPathLevel3, configData.getValueInfo("prop5").getConfigSourcePath());
    assertTrue(configData.getValues().get(ConfigurationDefNameConstants.PROPERTY_CONFIG_PROPERTY_INHERIT, false));
}
Also used : 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