use of org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata in project sling by apache.
the class ConfigurationManagerImplTest method testGetConfigurationMetadata_Nested_SubList.
@Test
public void testGetConfigurationMetadata_Nested_SubList() {
ConfigurationMetadata configMetadataSubList = underTest.getConfigurationMetadata(getConfigResolvePath(CONFIG_NESTED_NAME) + "/propSubList");
assertNotNull(configMetadataSubList);
assertEquals("propSubList", configMetadataSubList.getName());
}
use of org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata in project sling by apache.
the class ConfigurationMetadataProviderMultiplexerImplTest method testWithTwoProviders.
@Test
public void testWithTwoProviders() {
registerConfigurationMetadataProvider("test1");
registerConfigurationMetadataProvider("test2");
SortedSet<String> configNames = underTest.getConfigurationNames();
assertEquals(ImmutableSortedSet.of("test1", "test2"), configNames);
ConfigurationMetadata configMetadata = underTest.getConfigurationMetadata("test1");
assertEquals("test1", configMetadata.getName());
configMetadata = underTest.getConfigurationMetadata("test2");
assertEquals("test2", configMetadata.getName());
}
use of org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata in project sling by apache.
the class ConfigurationManagerImplTest method testGetConfigurationMetadata_Nested.
@Test
public void testGetConfigurationMetadata_Nested() {
ConfigurationMetadata configMetadata = underTest.getConfigurationMetadata(CONFIG_NESTED_NAME);
assertNotNull(configMetadata);
assertEquals(CONFIG_NESTED_NAME, configMetadata.getName());
}
use of org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata in project sling by apache.
the class ConfigurationMetadataProviderIT method testConfigurationMetadata.
@Test
public void testConfigurationMetadata() {
ConfigurationMetadataProvider underTest = teleporter.getService(ConfigurationMetadataProvider.class);
ConfigurationMetadata configMetadata = underTest.getConfigurationMetadata(SimpleConfig.class.getName());
assertNotNull(configMetadata);
assertEquals(SimpleConfig.class.getName(), configMetadata.getName());
}
use of org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata in project sling by apache.
the class ConfigurationBuilderImpl method applyDefaultValues.
/**
* Apply default values from configuration metadata (where no real data is present).
* @param props Properties
* @param configName Configuration name
* @return null if no default values found, or a new map with added default properties.
*/
private Map<String, Object> applyDefaultValues(Map<String, Object> props, String configName) {
ConfigurationMetadata metadata = configurationMetadataProvider.getConfigurationMetadata(configName);
if (metadata == null) {
// probably a configuration list - remove item name from end
if (StringUtils.contains(configName, "/")) {
String partialConfigName = StringUtils.substringBeforeLast(configName, "/");
metadata = configurationMetadataProvider.getConfigurationMetadata(partialConfigName);
}
if (metadata == null) {
return null;
}
}
Map<String, Object> updatedMap = new HashMap<>();
for (PropertyMetadata<?> propertyMetadata : metadata.getPropertyMetadata().values()) {
if (propertyMetadata.getDefaultValue() != null) {
updatedMap.put(propertyMetadata.getName(), propertyMetadata.getDefaultValue());
}
}
if (updatedMap.isEmpty()) {
return null;
}
updatedMap.putAll(props);
return updatedMap;
}
Aggregations