Search in sources :

Example 21 with ConfigurationMetadata

use of org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata in project sling by apache.

the class ConfigurationDataImplTest method setUp.

@Before
public void setUp() {
    configurationManagementSettings = context.registerInjectActivateService(new ConfigurationManagementSettingsImpl());
    configurationPersistenceStrategy = context.registerInjectActivateService(new DefaultConfigurationPersistenceStrategy());
    configResource = context.create().resource("/conf/test", "prop1", "value1", "prop4", true);
    configMetadata = new ConfigurationMetadata("testName", ImmutableList.<PropertyMetadata<?>>of(new PropertyMetadata<>("prop1", "defValue"), new PropertyMetadata<>("prop2", String.class), new PropertyMetadata<>("prop3", 5), new PropertyMetadata<>("propIntArray", new Integer[] { 1, 2, 3 })), false);
}
Also used : PropertyMetadata(org.apache.sling.caconfig.spi.metadata.PropertyMetadata) ConfigurationMetadata(org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata) DefaultConfigurationPersistenceStrategy(org.apache.sling.caconfig.impl.def.DefaultConfigurationPersistenceStrategy) Before(org.junit.Before)

Example 22 with ConfigurationMetadata

use of org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata in project sling by apache.

the class AnnotationClassParserTest method testBuildConfigurationMetadata_AllTypes.

@Test
public void testBuildConfigurationMetadata_AllTypes() {
    ConfigurationMetadata metadata = buildConfigurationMetadata(AllTypesConfig.class);
    assertEquals(AllTypesConfig.class.getName(), metadata.getName());
    assertNull(metadata.getLabel());
    assertNull(metadata.getDescription());
    assertTrue(metadata.getProperties().isEmpty());
    assertEquals(20, metadata.getPropertyMetadata().size());
}
Also used : AllTypesConfig(org.apache.sling.caconfig.example.AllTypesConfig) ConfigurationMetadata(org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata) AnnotationClassParser.buildConfigurationMetadata(org.apache.sling.caconfig.impl.metadata.AnnotationClassParser.buildConfigurationMetadata) Test(org.junit.Test)

Example 23 with ConfigurationMetadata

use of org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata in project sling by apache.

the class ConfigurationMetadataProviderMultiplexerImplTest method registerConfigurationMetadataProvider.

private void registerConfigurationMetadataProvider(String... names) {
    final Map<String, ConfigurationMetadata> metadata = new HashMap<>();
    for (String name : names) {
        metadata.put(name, new ConfigurationMetadata(name, ImmutableList.<PropertyMetadata<?>>of(), false));
    }
    context.registerService(ConfigurationMetadataProvider.class, new ConfigurationMetadataProvider() {

        @Override
        public SortedSet<String> getConfigurationNames() {
            return new TreeSet<>(metadata.keySet());
        }

        @Override
        public ConfigurationMetadata getConfigurationMetadata(String configName) {
            return metadata.get(configName);
        }
    });
}
Also used : HashMap(java.util.HashMap) PropertyMetadata(org.apache.sling.caconfig.spi.metadata.PropertyMetadata) ConfigurationMetadataProvider(org.apache.sling.caconfig.spi.ConfigurationMetadataProvider) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) SortedSet(java.util.SortedSet) ConfigurationMetadata(org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata)

Example 24 with ConfigurationMetadata

use of org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata in project sling by apache.

the class ConfigurationManagerImplNoDefaultTest method setUp.

@Before
public void setUp() {
    context.registerService(ConfigurationMetadataProvider.class, configurationMetadataProvider);
    ConfigurationTestUtils.registerConfigurationResolverWithoutDefaultImpl(context);
    underTest = context.registerInjectActivateService(new ConfigurationManagerImpl());
    contextResourceNoConfig = context.create().resource("/content/testNoConfig", PROPERTY_CONFIG_REF, "/conf/testNoConfig");
    configMetadata = new ConfigurationMetadata(CONFIG_NAME, ImmutableList.<PropertyMetadata<?>>of(new PropertyMetadata<>("prop1", "defValue"), new PropertyMetadata<>("prop2", String.class), new PropertyMetadata<>("prop3", 5)), false);
    when(configurationMetadataProvider.getConfigurationMetadata(CONFIG_NAME)).thenReturn(configMetadata);
    configMetadata = new ConfigurationMetadata(CONFIG_COL_NAME, ImmutableList.<PropertyMetadata<?>>of(new PropertyMetadata<>("prop1", "defValue"), new PropertyMetadata<>("prop2", String.class), new PropertyMetadata<>("prop3", 5)), true);
    when(configurationMetadataProvider.getConfigurationMetadata(CONFIG_COL_NAME)).thenReturn(configMetadata);
}
Also used : PropertyMetadata(org.apache.sling.caconfig.spi.metadata.PropertyMetadata) ConfigurationMetadata(org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata) Before(org.junit.Before)

Example 25 with ConfigurationMetadata

use of org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata in project sling by apache.

the class ConfigurationManagerImplTest method testGetConfigurationMetadata_Nested_SubLevel2.

@Test
public void testGetConfigurationMetadata_Nested_SubLevel2() {
    ConfigurationMetadata configMetadataSubLevel2 = underTest.getConfigurationMetadata(getConfigResolvePath(getConfigResolvePath(CONFIG_NESTED_NAME) + "/propSub") + "/propSubLevel2");
    assertNotNull(configMetadataSubLevel2);
    assertEquals("propSubLevel2", configMetadataSubLevel2.getName());
}
Also used : ConfigurationMetadata(org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata) Test(org.junit.Test)

Aggregations

ConfigurationMetadata (org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata)33 Test (org.junit.Test)17 PropertyMetadata (org.apache.sling.caconfig.spi.metadata.PropertyMetadata)9 Before (org.junit.Before)5 AnnotationClassParser.buildConfigurationMetadata (org.apache.sling.caconfig.impl.metadata.AnnotationClassParser.buildConfigurationMetadata)4 ConfigurationData (org.apache.sling.caconfig.management.ConfigurationData)4 ConfigurationMetadataProvider (org.apache.sling.caconfig.spi.ConfigurationMetadataProvider)3 HashMap (java.util.HashMap)2 ResettableIterator (org.apache.commons.collections.ResettableIterator)2 ListIteratorWrapper (org.apache.commons.collections.iterators.ListIteratorWrapper)2 Resource (org.apache.sling.api.resource.Resource)2 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 LinkedHashSet (java.util.LinkedHashSet)1 SortedSet (java.util.SortedSet)1 Configuration (org.apache.sling.caconfig.annotation.Configuration)1 Property (org.apache.sling.caconfig.annotation.Property)1 AllTypesConfig (org.apache.sling.caconfig.example.AllTypesConfig)1