use of org.apache.sling.caconfig.spi.metadata.PropertyMetadata in project sling by apache.
the class CAConfigInventoryPrinterTest method setUp.
@Before
public void setUp() {
context.registerService(ConfigurationMetadataProvider.class, configurationMetadataProvider);
context.registerService(ConfigurationOverrideProvider.class, configurationOverrideProvider);
ConfigurationTestUtils.registerConfigurationResolver(context);
underTest = context.registerInjectActivateService(new CAConfigInventoryPrinter());
ConfigurationMetadata configMetadata = new ConfigurationMetadata(SAMPLE_CONFIG_NAME, ImmutableList.<PropertyMetadata<?>>of(new PropertyMetadata<>("prop1", "defValue"), new PropertyMetadata<>("prop2", String.class), new PropertyMetadata<>("prop3", 5)), false);
when(configurationMetadataProvider.getConfigurationMetadata(SAMPLE_CONFIG_NAME)).thenReturn(configMetadata);
when(configurationMetadataProvider.getConfigurationNames()).thenReturn(ImmutableSortedSet.of(SAMPLE_CONFIG_NAME));
when(configurationOverrideProvider.getOverrideStrings()).thenReturn(ImmutableList.of(SAMPLE_OVERRIDE_STRING));
}
use of org.apache.sling.caconfig.spi.metadata.PropertyMetadata in project sling by apache.
the class ConfigurationManagerImplTest method setUp.
@Before
public void setUp() {
context.registerService(ConfigurationMetadataProvider.class, configurationMetadataProvider);
ConfigurationTestUtils.registerConfigurationResolver(context, "configBucketNames", getAlternativeBucketNames());
underTest = context.registerInjectActivateService(new ConfigurationManagerImpl());
contextResource = context.create().resource("/content/test", PROPERTY_CONFIG_REF, "/conf/test");
contextResourceLevel2 = context.create().resource("/content/test/level2", PROPERTY_CONFIG_REF, "/conf/test/level2");
contextResourceLevel3 = context.create().resource("/content/test/level2/level3", PROPERTY_CONFIG_REF, "/conf/test/level2/level3");
contextResourceNoConfig = context.create().resource("/content/testNoConfig", PROPERTY_CONFIG_REF, "/conf/testNoConfig");
context.create().resource(getConfigResolvePath("/conf/test/sling:configs/" + CONFIG_NAME), "prop1", "value1", "prop4", true);
context.create().resource(getConfigCollectionItemResolvePath(getConfigCollectionParentResolvePath("/conf/test/sling:configs/" + CONFIG_COL_NAME) + "/1"), "prop1", "value1");
context.create().resource(getConfigCollectionItemResolvePath(getConfigCollectionParentResolvePath("/conf/test/sling:configs/" + CONFIG_COL_NAME) + "/2"), "prop4", true);
// test fixture with resource collection inheritance on level 2
context.create().resource(getConfigCollectionParentResolvePath("/conf/test/level2/sling:configs/" + CONFIG_COL_NAME), PROPERTY_CONFIG_COLLECTION_INHERIT, true);
context.create().resource(getConfigCollectionItemResolvePath(getConfigCollectionParentResolvePath("/conf/test/level2/sling:configs/" + CONFIG_COL_NAME) + "/1"), "prop1", "value1_level2");
// test fixture with property inheritance and resource collection inheritance on level 3
context.create().resource(getConfigResolvePath("/conf/test/level2/level3/sling:configs/" + CONFIG_NAME), "prop4", false, "prop5", "value5_level3", PROPERTY_CONFIG_PROPERTY_INHERIT, true);
context.create().resource(getConfigCollectionParentResolvePath("/conf/test/level2/level3/sling:configs/" + CONFIG_COL_NAME), PROPERTY_CONFIG_COLLECTION_INHERIT, true);
context.create().resource(getConfigCollectionItemResolvePath(getConfigCollectionParentResolvePath("/conf/test/level2/level3/sling:configs/" + CONFIG_COL_NAME) + "/1"), "prop4", false, "prop5", "value5_level3", PROPERTY_CONFIG_PROPERTY_INHERIT, true);
// test fixture nested configuration
context.create().resource(getConfigResolvePath("/conf/test/level2/sling:configs/" + CONFIG_NESTED_NAME), "prop1", "value1", "prop4", true);
context.create().resource(getConfigResolvePath(getConfigResolvePath("/conf/test/sling:configs/" + CONFIG_NESTED_NAME) + "/propSub"), "prop1", "propSubValue1", "prop4", true);
context.create().resource(getConfigResolvePath(getConfigResolvePath(getConfigResolvePath("/conf/test/sling:configs/" + CONFIG_NESTED_NAME) + "/propSub") + "/propSubLevel2"), "prop1", "propSubLevel2Value1", "prop4", true);
context.create().resource(getConfigCollectionItemResolvePath(getConfigCollectionParentResolvePath(getConfigResolvePath("/conf/test/level2/sling:configs/" + CONFIG_NESTED_NAME) + "/propSubList") + "/item1"), "prop1", "propSubListValue1.1");
context.create().resource(getConfigCollectionItemResolvePath(getConfigCollectionParentResolvePath(getConfigResolvePath("/conf/test/level2/sling:configs/" + CONFIG_NESTED_NAME) + "/propSubList") + "/item2"), "prop1", "propSubListValue1.2");
context.create().resource(getConfigResolvePath(getConfigCollectionItemResolvePath(getConfigCollectionParentResolvePath(getConfigResolvePath("/conf/test/sling:configs/" + CONFIG_NESTED_NAME) + "/propSubList") + "/item1") + "/propSub"), "prop1", "propSubList1_proSubValue1", "prop4", true);
// config metadata singleton config
ConfigurationMetadata 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);
// config metadata config collection
ConfigurationMetadata configColMetadata = 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(configColMetadata);
// config metadata nested config
/*
* testConfigNested
* |
* +- propSub
* | |
* | +- propSubLevel2
* |
* +- propSubList
* |
* +- <collection>
* |
* +- propSub
* |
* +- propSubLevel2
*/
ConfigurationMetadata propSubLevel2Metadata = new ConfigurationMetadata("propSubLevel2", ImmutableList.<PropertyMetadata<?>>of(new PropertyMetadata<>("prop1", "defValueLevel2")), false);
ConfigurationMetadata propSubMetadata = new ConfigurationMetadata("propSub", ImmutableList.<PropertyMetadata<?>>of(new PropertyMetadata<>("prop1", "defValue"), new PropertyMetadata<>("prop2", String.class), new PropertyMetadata<>("prop3", 5), new PropertyMetadata<>("propSubLevel2", ConfigurationMetadata.class).configurationMetadata(propSubLevel2Metadata)), false);
ConfigurationMetadata propSubListMetadata = new ConfigurationMetadata("propSubList", ImmutableList.<PropertyMetadata<?>>of(new PropertyMetadata<>("prop1", "defValueSubList"), new PropertyMetadata<>("propSub", ConfigurationMetadata.class).configurationMetadata(propSubMetadata)), true);
ConfigurationMetadata configNestedMetadata = new ConfigurationMetadata(CONFIG_NESTED_NAME, ImmutableList.<PropertyMetadata<?>>of(new PropertyMetadata<>("prop1", "defValue"), new PropertyMetadata<>("propSub", ConfigurationMetadata.class).configurationMetadata(propSubMetadata), new PropertyMetadata<>("propSubList", ConfigurationMetadata[].class).configurationMetadata(propSubListMetadata)), false);
when(configurationMetadataProvider.getConfigurationMetadata(CONFIG_NESTED_NAME)).thenReturn(configNestedMetadata);
when(configurationMetadataProvider.getConfigurationNames()).thenReturn(ImmutableSortedSet.of(CONFIG_NAME, CONFIG_COL_NAME, CONFIG_NESTED_NAME));
}
use of org.apache.sling.caconfig.spi.metadata.PropertyMetadata 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);
}
use of org.apache.sling.caconfig.spi.metadata.PropertyMetadata 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);
}
});
}
use of org.apache.sling.caconfig.spi.metadata.PropertyMetadata 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);
}
Aggregations