Search in sources :

Example 1 with ConfigurationCollectionData

use of org.apache.sling.caconfig.management.ConfigurationCollectionData in project sling by apache.

the class ConfigurationManagerImplTest method testGetConfigurationCollection_WithResourceCollectionAndPropertyInheritance.

@Test
public void testGetConfigurationCollection_WithResourceCollectionAndPropertyInheritance() {
    ConfigurationCollectionData configCollectionData = underTest.getConfigurationCollection(contextResourceLevel3, CONFIG_COL_NAME);
    List<ConfigurationData> configDatas = ImmutableList.copyOf(configCollectionData.getItems());
    assertEquals(2, configDatas.size());
    ConfigurationData configData1 = configDatas.get(0);
    assertFalse(configData1.isInherited());
    assertTrue(configData1.getPropertyNames().containsAll(ImmutableSet.of("prop1", "prop2", "prop3", "prop4", "prop5")));
    assertTrue(configData1.getPropertyNames().containsAll(ImmutableSet.of("prop1", "prop2", "prop3", "prop4", "prop5")));
    assertNull(configData1.getValues().get("prop1", String.class));
    assertNull(configData1.getValues().get("prop2", String.class));
    assertNull(configData1.getValues().get("prop3", Integer.class));
    assertFalse(configData1.getValues().get("prop4", Boolean.class));
    assertEquals("value5_level3", configData1.getValues().get("prop5", String.class));
    assertEquals("value1_level2", configData1.getEffectiveValues().get("prop1", String.class));
    assertNull(configData1.getEffectiveValues().get("prop2", String.class));
    assertEquals((Integer) 5, configData1.getEffectiveValues().get("prop3", 0));
    assertFalse(configData1.getEffectiveValues().get("prop4", Boolean.class));
    assertEquals("value5_level3", configData1.getEffectiveValues().get("prop5", String.class));
    String configPathLevel2 = getConfigCollectionItemResolvePath(getConfigCollectionParentResolvePath("/conf/test/level2/sling:configs/" + CONFIG_COL_NAME) + "/1");
    String configPathLevel3 = getConfigCollectionItemResolvePath(getConfigCollectionParentResolvePath("/conf/test/level2/level3/sling:configs/" + CONFIG_COL_NAME) + "/1");
    assertTrue(configData1.getValueInfo("prop1").isInherited());
    assertEquals(configPathLevel2, configData1.getValueInfo("prop1").getConfigSourcePath());
    assertFalse(configData1.getValueInfo("prop2").isInherited());
    assertNull(configData1.getValueInfo("prop2").getConfigSourcePath());
    assertFalse(configData1.getValueInfo("prop3").isInherited());
    assertNull(configData1.getValueInfo("prop3").getConfigSourcePath());
    assertFalse(configData1.getValueInfo("prop4").isInherited());
    assertEquals(configPathLevel3, configData1.getValueInfo("prop4").getConfigSourcePath());
    assertFalse(configData1.getValueInfo("prop5").isInherited());
    assertEquals(configPathLevel3, configData1.getValueInfo("prop5").getConfigSourcePath());
    ConfigurationData configData2 = configDatas.get(1);
    assertFalse(configData1.isInherited());
    assertEquals(ImmutableSet.of("prop1", "prop2", "prop3", "prop4"), configData2.getPropertyNames());
    assertNull(configData2.getValues().get("prop1", String.class));
    assertEquals((Integer) 5, configData2.getEffectiveValues().get("prop3", 0));
    String configPath2 = getConfigCollectionItemResolvePath(getConfigCollectionParentResolvePath("/conf/test/sling:configs/" + CONFIG_COL_NAME) + "/2");
    assertTrue(configData2.getValueInfo("prop4").isInherited());
    assertEquals(configPath2, configData2.getValueInfo("prop4").getConfigSourcePath());
    assertFalse(configData2.getValueInfo("prop3").isInherited());
    assertNull(configData2.getValueInfo("prop3").getConfigSourcePath());
    assertTrue((Boolean) configCollectionData.getProperties().get(ConfigurationResourceNameConstants.PROPERTY_CONFIG_COLLECTION_INHERIT));
    assertTrue(configData1.getValues().get(ConfigurationDefNameConstants.PROPERTY_CONFIG_PROPERTY_INHERIT, false));
}
Also used : ConfigurationCollectionData(org.apache.sling.caconfig.management.ConfigurationCollectionData) ConfigurationData(org.apache.sling.caconfig.management.ConfigurationData) Test(org.junit.Test)

Example 2 with ConfigurationCollectionData

use of org.apache.sling.caconfig.management.ConfigurationCollectionData in project sling by apache.

the class ConfigurationManagerImplTest method testGetConfigurationCollection_WithResourceCollectionInheritance.

@Test
public void testGetConfigurationCollection_WithResourceCollectionInheritance() {
    ConfigurationCollectionData configCollectionData = underTest.getConfigurationCollection(contextResourceLevel2, CONFIG_COL_NAME);
    List<ConfigurationData> configDatas = ImmutableList.copyOf(configCollectionData.getItems());
    assertEquals(2, configDatas.size());
    ConfigurationData configData1 = configDatas.get(0);
    assertFalse(configData1.isInherited());
    assertEquals(ImmutableSet.of("prop1", "prop2", "prop3"), configData1.getPropertyNames());
    assertEquals("value1_level2", configData1.getValues().get("prop1", String.class));
    assertEquals("value1_level2", configData1.getEffectiveValues().get("prop1", String.class));
    assertEquals((Integer) 5, configData1.getEffectiveValues().get("prop3", 0));
    String configPath1 = getConfigCollectionItemResolvePath(getConfigCollectionParentResolvePath("/conf/test/level2/sling:configs/" + CONFIG_COL_NAME) + "/1");
    assertFalse(configData1.getValueInfo("prop1").isInherited());
    assertEquals(configPath1, configData1.getValueInfo("prop1").getConfigSourcePath());
    assertFalse(configData1.getValueInfo("prop3").isInherited());
    assertNull(configData1.getValueInfo("prop3").getConfigSourcePath());
    ConfigurationData configData2 = configDatas.get(1);
    assertTrue(configData2.isInherited());
    assertEquals(ImmutableSet.of("prop1", "prop2", "prop3", "prop4"), configData2.getPropertyNames());
    assertNull(configData2.getValues().get("prop1", String.class));
    assertEquals((Integer) 5, configData2.getEffectiveValues().get("prop3", 0));
    String configPath2 = getConfigCollectionItemResolvePath(getConfigCollectionParentResolvePath("/conf/test/sling:configs/" + CONFIG_COL_NAME) + "/2");
    assertTrue(configData2.getValueInfo("prop4").isInherited());
    assertEquals(configPath2, configData2.getValueInfo("prop4").getConfigSourcePath());
    assertFalse(configData2.getValueInfo("prop3").isInherited());
    assertNull(configData2.getValueInfo("prop3").getConfigSourcePath());
    assertTrue((Boolean) configCollectionData.getProperties().get(ConfigurationResourceNameConstants.PROPERTY_CONFIG_COLLECTION_INHERIT));
}
Also used : ConfigurationCollectionData(org.apache.sling.caconfig.management.ConfigurationCollectionData) ConfigurationData(org.apache.sling.caconfig.management.ConfigurationData) Test(org.junit.Test)

Example 3 with ConfigurationCollectionData

use of org.apache.sling.caconfig.management.ConfigurationCollectionData in project sling by apache.

the class ConfigurationCollectionDataImplTest method testProperties.

@Test
public void testProperties() {
    Map<String, Object> props = ImmutableMap.<String, Object>of("jcr:primaryType", "test", "prop1", "value1");
    ConfigurationCollectionData underTest = new ConfigurationCollectionDataImpl("name1", items, "/path1", props, configurationManagementSettings);
    assertEquals("name1", underTest.getConfigName());
    assertSame(items, underTest.getItems());
    assertEquals("/path1", underTest.getResourcePath());
    assertEquals(ImmutableMap.<String, Object>of("prop1", "value1"), underTest.getProperties());
}
Also used : ConfigurationCollectionData(org.apache.sling.caconfig.management.ConfigurationCollectionData) Test(org.junit.Test)

Example 4 with ConfigurationCollectionData

use of org.apache.sling.caconfig.management.ConfigurationCollectionData in project sling by apache.

the class ConfigurationManagerImplTest method testGetConfigurationCollection.

@Test
public void testGetConfigurationCollection() {
    ConfigurationCollectionData configCollectionData = underTest.getConfigurationCollection(contextResource, CONFIG_COL_NAME);
    List<ConfigurationData> configDatas = ImmutableList.copyOf(configCollectionData.getItems());
    assertEquals(2, configDatas.size());
    ConfigurationData configData1 = configDatas.get(0);
    assertFalse(configData1.isInherited());
    assertEquals("1", configData1.getCollectionItemName());
    assertEquals(ImmutableSet.of("prop1", "prop2", "prop3"), configData1.getPropertyNames());
    assertEquals("value1", configData1.getValues().get("prop1", String.class));
    assertEquals((Integer) 5, configData1.getEffectiveValues().get("prop3", 0));
    assertFalse(configData1.getValueInfo("prop1").isInherited());
    assertFalse(configData1.getValueInfo("prop3").isInherited());
    ConfigurationData configData2 = configDatas.get(1);
    assertFalse(configData2.isInherited());
    assertEquals("2", configData2.getCollectionItemName());
    assertEquals(ImmutableSet.of("prop1", "prop2", "prop3", "prop4"), configData2.getPropertyNames());
    assertNull(configData2.getValues().get("prop1", String.class));
    assertEquals((Integer) 5, configData2.getEffectiveValues().get("prop3", 0));
    assertFalse(configData2.getValueInfo("prop1").isInherited());
    assertFalse(configData2.getValueInfo("prop3").isInherited());
    assertNull(configCollectionData.getProperties().get(ConfigurationResourceNameConstants.PROPERTY_CONFIG_COLLECTION_INHERIT));
}
Also used : ConfigurationCollectionData(org.apache.sling.caconfig.management.ConfigurationCollectionData) ConfigurationData(org.apache.sling.caconfig.management.ConfigurationData) Test(org.junit.Test)

Example 5 with ConfigurationCollectionData

use of org.apache.sling.caconfig.management.ConfigurationCollectionData in project sling by apache.

the class ConfigurationCollectionDataImplTest method testEmpty.

@Test
public void testEmpty() {
    ConfigurationCollectionData underTest = new ConfigurationCollectionDataImpl("name1", ImmutableList.<ConfigurationData>of(), "/path1", null, configurationManagementSettings);
    assertEquals("name1", underTest.getConfigName());
    assertTrue(underTest.getItems().isEmpty());
    assertEquals("/path1", underTest.getResourcePath());
    assertEquals(ImmutableMap.<String, Object>of(ConfigurationResourceNameConstants.PROPERTY_CONFIG_COLLECTION_INHERIT, true), underTest.getProperties());
}
Also used : ConfigurationCollectionData(org.apache.sling.caconfig.management.ConfigurationCollectionData) Test(org.junit.Test)

Aggregations

ConfigurationCollectionData (org.apache.sling.caconfig.management.ConfigurationCollectionData)6 Test (org.junit.Test)6 ConfigurationData (org.apache.sling.caconfig.management.ConfigurationData)4