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());
}
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);
}
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);
}
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));
}
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));
}
Aggregations