use of org.apache.sling.caconfig.management.ConfigurationData in project sling by apache.
the class ConfigurationManagerImplTest method testGetConfiguration_NoConfigResource_NoConfigMetadata.
@Test
public void testGetConfiguration_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 ConfigurationManagerImplTest method testDeleteConfigurationCollection.
@Test
public void testDeleteConfigurationCollection() throws Exception {
underTest.deleteConfiguration(contextResource, CONFIG_COL_NAME);
ConfigurationCollectionData configCollectionData = underTest.getConfigurationCollection(contextResource, CONFIG_COL_NAME);
List<ConfigurationData> configDatas = ImmutableList.copyOf(configCollectionData.getItems());
assertEquals(0, configDatas.size());
}
use of org.apache.sling.caconfig.management.ConfigurationData in project sling by apache.
the class ConfigurationManagerImplTest method testGetConfigurationCollection_NoConfigMetadata.
@Test
public void testGetConfigurationCollection_NoConfigMetadata() {
when(configurationMetadataProvider.getConfigurationMetadata(CONFIG_COL_NAME)).thenReturn(null);
List<ConfigurationData> configDatas = ImmutableList.copyOf(underTest.getConfigurationCollection(contextResource, CONFIG_COL_NAME).getItems());
assertEquals(2, configDatas.size());
ConfigurationData configData1 = configDatas.get(0);
assertFalse(configData1.isInherited());
assertEquals(ImmutableSet.of("prop1"), configData1.getPropertyNames());
assertEquals("value1", configData1.getValues().get("prop1", String.class));
assertEquals((Integer) 0, configData1.getEffectiveValues().get("prop3", 0));
assertFalse(configData1.getValueInfo("prop1").isInherited());
assertFalse(configData1.getValueInfo("prop3").isInherited());
ConfigurationData configData2 = configDatas.get(1);
assertFalse(configData2.isInherited());
assertEquals(ImmutableSet.of("prop4"), configData2.getPropertyNames());
assertNull(configData2.getValues().get("prop1", String.class));
assertEquals((Integer) 0, configData2.getEffectiveValues().get("prop3", 0));
assertFalse(configData2.getValueInfo("prop1").isInherited());
assertFalse(configData2.getValueInfo("prop3").isInherited());
}
use of org.apache.sling.caconfig.management.ConfigurationData in project sling by apache.
the class ConfigurationManagerImplTest method testGetConfiguration_NoConfigResource.
@Test
public void testGetConfiguration_NoConfigResource() {
ConfigurationData configData = underTest.getConfiguration(contextResourceNoConfig, CONFIG_NAME);
assertNotNull(configData);
assertFalse(configData.isInherited());
assertEquals(ImmutableSet.of("prop1", "prop2", "prop3"), configData.getPropertyNames());
assertNull(configData.getValues().get("prop1", String.class));
assertEquals((Integer) 5, configData.getEffectiveValues().get("prop3", 0));
assertFalse(configData.getValueInfo("prop1").isInherited());
assertFalse(configData.getValueInfo("prop3").isInherited());
}
use of org.apache.sling.caconfig.management.ConfigurationData in project sling by apache.
the class ConfigurationManagerImplTest method testGetConfigurationNested.
@Test
public void testGetConfigurationNested() {
ConfigurationData configData = underTest.getConfiguration(contextResourceLevel2, CONFIG_NESTED_NAME);
assertNotNull(configData);
// root level
assertEquals(ImmutableSet.of("prop1", "propSub", "propSubList", "prop4"), configData.getPropertyNames());
assertEquals("value1", configData.getValues().get("prop1", String.class));
assertEquals("value1", configData.getEffectiveValues().get("prop1", String.class));
assertTrue(configData.getValues().get("prop4", false));
assertTrue(configData.getEffectiveValues().get("prop4", false));
assertEquals(ConfigurationMetadata.class, configData.getValueInfo("propSub").getPropertyMetadata().getType());
assertEquals(ConfigurationMetadata[].class, configData.getValueInfo("propSubList").getPropertyMetadata().getType());
// propSub
ConfigurationData subData = configData.getValues().get("propSub", ConfigurationData.class);
ConfigurationData subDataEffective = configData.getEffectiveValues().get("propSub", ConfigurationData.class);
assertNotNull(subData);
assertNotNull(subDataEffective);
assertTrue(ConfigurationData.class.isAssignableFrom(configData.getValueInfo("propSub").getValue().getClass()));
assertTrue(ConfigurationData.class.isAssignableFrom(configData.getValueInfo("propSub").getEffectiveValue().getClass()));
assertTrue(ConfigurationData[].class.isAssignableFrom(configData.getValueInfo("propSubList").getValue().getClass()));
assertTrue(ConfigurationData[].class.isAssignableFrom(configData.getValueInfo("propSubList").getEffectiveValue().getClass()));
assertNull(subData.getValues().get("prop1", String.class));
assertEquals("propSubValue1", subData.getEffectiveValues().get("prop1", String.class));
assertFalse(subData.getValues().get("prop4", false));
assertTrue(subData.getEffectiveValues().get("prop4", false));
// propSub/propSubLevel2
ConfigurationData subDataLevel2 = subData.getValues().get("propSubLevel2", ConfigurationData.class);
ConfigurationData subDataLevel2Effective = subData.getEffectiveValues().get("propSubLevel2", ConfigurationData.class);
assertNotNull(subDataLevel2);
assertNotNull(subDataLevel2Effective);
assertTrue(ConfigurationData.class.isAssignableFrom(subData.getValueInfo("propSubLevel2").getValue().getClass()));
assertTrue(ConfigurationData.class.isAssignableFrom(subData.getValueInfo("propSubLevel2").getEffectiveValue().getClass()));
assertNull(subDataLevel2.getValues().get("prop1", String.class));
assertEquals("propSubLevel2Value1", subDataLevel2.getEffectiveValues().get("prop1", String.class));
assertFalse(subDataLevel2.getValues().get("prop4", false));
assertTrue(subDataLevel2.getEffectiveValues().get("prop4", false));
// propSubList
ConfigurationData[] subListData = configData.getValues().get("propSubList", ConfigurationData[].class);
ConfigurationData[] subListDataEffective = configData.getEffectiveValues().get("propSubList", ConfigurationData[].class);
assertNotNull(subListData);
assertNotNull(subListDataEffective);
assertTrue(ConfigurationData[].class.isAssignableFrom(configData.getValueInfo("propSubList").getValue().getClass()));
assertTrue(ConfigurationData[].class.isAssignableFrom(configData.getValueInfo("propSubList").getEffectiveValue().getClass()));
assertEquals(2, subListData.length);
assertEquals("propSubListValue1.1", subListData[0].getValues().get("prop1", String.class));
assertEquals("propSubListValue1.1", subListData[0].getEffectiveValues().get("prop1", String.class));
assertEquals("propSubListValue1.2", subListData[1].getValues().get("prop1", String.class));
assertEquals("propSubListValue1.2", subListData[1].getEffectiveValues().get("prop1", String.class));
ConfigurationData subListDataItem1Sub = subListData[0].getValues().get("propSub", ConfigurationData.class);
ConfigurationData subListDataItem1SubEffecive = subListData[0].getEffectiveValues().get("propSub", ConfigurationData.class);
assertNotNull(subListDataItem1Sub);
assertNotNull(subListDataItem1SubEffecive);
assertNull(subListDataItem1Sub.getValues().get("prop1", String.class));
assertEquals("propSubList1_proSubValue1", subListDataItem1Sub.getEffectiveValues().get("prop1", String.class));
assertFalse(subListDataItem1Sub.getValues().get("prop4", false));
assertTrue(subListDataItem1Sub.getEffectiveValues().get("prop4", false));
}
Aggregations