use of org.apache.sling.caconfig.spi.ConfigurationCollectionPersistData in project sling by apache.
the class ConfigurationPersistenceStrategyMultiplexerImplTest method testWithDefaultStrategy.
@Test
public void testWithDefaultStrategy() {
context.registerInjectActivateService(new DefaultConfigurationPersistenceStrategy());
assertSame(resource1, underTest.getResource(resource1));
assertEquals(resource1.getPath(), underTest.getResourcePath(resource1.getPath()));
assertTrue(underTest.persistConfiguration(context.resourceResolver(), "/conf/test1", new ConfigurationPersistData(resource1.getValueMap())));
assertTrue(underTest.persistConfigurationCollection(context.resourceResolver(), "/conf/testCol", new ConfigurationCollectionPersistData(ImmutableList.of(new ConfigurationPersistData(resource1.getValueMap()).collectionItemName(resource1.getName()), new ConfigurationPersistData(resource2.getValueMap()).collectionItemName(resource2.getName())))));
assertTrue(underTest.deleteConfiguration(context.resourceResolver(), "/conf/test1"));
}
use of org.apache.sling.caconfig.spi.ConfigurationCollectionPersistData in project sling by apache.
the class ConfigurationPersistenceStrategyMultiplexerImplTest method testWithNoStrategies.
@Test
public void testWithNoStrategies() {
assertNull(underTest.getResource(resource1));
assertNull(underTest.getResourcePath(resource1.getPath()));
assertFalse(underTest.persistConfiguration(context.resourceResolver(), "/conf/test1", new ConfigurationPersistData(resource1.getValueMap())));
assertFalse(underTest.persistConfigurationCollection(context.resourceResolver(), "/conf/testCol", new ConfigurationCollectionPersistData(ImmutableList.of(new ConfigurationPersistData(resource1.getValueMap()).collectionItemName(resource1.getName()), new ConfigurationPersistData(resource2.getValueMap()).collectionItemName(resource2.getName())))));
assertFalse(underTest.deleteConfiguration(context.resourceResolver(), "/conf/test1"));
}
use of org.apache.sling.caconfig.spi.ConfigurationCollectionPersistData in project sling by apache.
the class ConfigurationManagerImplTest method testPersistConfigurationCollection.
@Test
public void testPersistConfigurationCollection() throws Exception {
underTest.persistConfigurationCollection(contextResourceNoConfig, CONFIG_COL_NAME, new ConfigurationCollectionPersistData(ImmutableList.of(new ConfigurationPersistData(ImmutableMap.<String, Object>of("prop1", "value1")).collectionItemName("0"), new ConfigurationPersistData(ImmutableMap.<String, Object>of("prop2", 5)).collectionItemName("1"))));
context.resourceResolver().commit();
String configPath0 = getConfigCollectionItemPersistPath(getConfigCollectionParentPersistPath("/conf/testNoConfig/sling:configs/" + CONFIG_COL_NAME) + "/0");
ValueMap props0 = context.resourceResolver().getResource(configPath0).getValueMap();
assertEquals("value1", props0.get("prop1"));
String configPath1 = getConfigCollectionItemPersistPath(getConfigCollectionParentPersistPath("/conf/testNoConfig/sling:configs/" + CONFIG_COL_NAME) + "/1");
ValueMap props1 = context.resourceResolver().getResource(configPath1).getValueMap();
assertEquals((Integer) 5, props1.get("prop2"));
}
use of org.apache.sling.caconfig.spi.ConfigurationCollectionPersistData in project sling by apache.
the class DefaultConfigurationPersistenceStrategyTest method testDisabled.
@Test
public void testDisabled() {
ConfigurationPersistenceStrategy2 underTest = context.registerInjectActivateService(new DefaultConfigurationPersistenceStrategy(), "enabled", false);
Resource resource = context.create().resource("/conf/test");
assertNull(underTest.getResource(resource));
assertNull(underTest.getResourcePath(resource.getPath()));
assertFalse(underTest.persistConfiguration(context.resourceResolver(), "/conf/test", new ConfigurationPersistData(ImmutableMap.<String, Object>of())));
assertFalse(underTest.persistConfigurationCollection(context.resourceResolver(), "/conf/test", new ConfigurationCollectionPersistData(ImmutableList.<ConfigurationPersistData>of())));
assertFalse(underTest.deleteConfiguration(context.resourceResolver(), "/conf/test"));
}
Aggregations