use of org.apache.sling.caconfig.example.ListConfig in project sling by apache.
the class ConfigurationProxyTest method testConfig_Nested.
@Test
public void testConfig_Nested() {
context.build().resource("/test", "stringParam", "v1").resource("/test/subConfig", "stringParam", "v2", "intParam", 444, "boolParam", true).resource("/test/subListConfig/1", "stringParam", "v3.1").resource("/test/subListConfig/2", "stringParam", "v3.2").resource("/test/subListConfig/3", "stringParam", "v3.3").resource("/test/subConfigWithoutAnnotation", "stringParam", "v4");
Resource resource = context.resourceResolver().getResource("/test");
NestedConfig cfg = get(resource, NestedConfig.class);
assertEquals("v1", cfg.stringParam());
SimpleConfig subConfig = cfg.subConfig();
assertEquals("v2", subConfig.stringParam());
assertEquals(444, subConfig.intParam());
assertEquals(true, subConfig.boolParam());
ListConfig[] listConfig = cfg.subListConfig();
assertEquals(3, listConfig.length);
assertEquals("v3.1", listConfig[0].stringParam());
assertEquals("v3.2", listConfig[1].stringParam());
assertEquals("v3.3", listConfig[2].stringParam());
WithoutAnnotationConfig subConfigWithoutAnnotation = cfg.subConfigWithoutAnnotation();
assertEquals("v4", subConfigWithoutAnnotation.stringParam());
}
use of org.apache.sling.caconfig.example.ListConfig in project sling by apache.
the class ConfigurationResolverAnnotationClassTest method testConfig_Nested.
@Test
public void testConfig_Nested() {
context.build().resource("/conf/content/site1/sling:configs/org.apache.sling.caconfig.example.NestedConfig", "stringParam", "configValue3").siblingsMode().resource("subConfig", "stringParam", "configValue4", "intParam", 444, "boolParam", true).hierarchyMode().resource("subListConfig").siblingsMode().resource("1", "stringParam", "configValue2.1").resource("2", "stringParam", "configValue2.2").resource("3", "stringParam", "configValue2.3");
NestedConfig cfg = underTest.get(site1Page1).as(NestedConfig.class);
assertEquals("configValue3", cfg.stringParam());
SimpleConfig subConfig = cfg.subConfig();
assertEquals("configValue4", subConfig.stringParam());
assertEquals(444, subConfig.intParam());
assertEquals(true, subConfig.boolParam());
ListConfig[] listConfig = cfg.subListConfig();
assertEquals(3, listConfig.length);
assertEquals("configValue2.1", listConfig[0].stringParam());
assertEquals("configValue2.2", listConfig[1].stringParam());
assertEquals("configValue2.3", listConfig[2].stringParam());
}
use of org.apache.sling.caconfig.example.ListConfig in project sling by apache.
the class ConfigurationResolverCustomPersistence2Test method testConfig_Nested.
@Test
public void testConfig_Nested() {
context.build().resource("/conf/content/site1/settings/org.apache.sling.caconfig.example.NestedConfig").resource("jcr:content", "stringParam", "configValue3").siblingsMode().resource("subConfig", "stringParam", "configValue4", "intParam", 444, "boolParam", true).hierarchyMode().resource("subListConfig").siblingsMode().resource("1", "stringParam", "configValue2.1").resource("2", "stringParam", "configValue2.2").resource("3", "stringParam", "configValue2.3");
NestedConfig cfg = underTest.get(site1Page1).as(NestedConfig.class);
assertEquals("configValue3", cfg.stringParam());
SimpleConfig subConfig = cfg.subConfig();
assertEquals("configValue4", subConfig.stringParam());
assertEquals(444, subConfig.intParam());
assertEquals(true, subConfig.boolParam());
ListConfig[] listConfig = cfg.subListConfig();
assertEquals(3, listConfig.length);
assertEquals("configValue2.1", listConfig[0].stringParam());
assertEquals("configValue2.2", listConfig[1].stringParam());
assertEquals("configValue2.3", listConfig[2].stringParam());
}
use of org.apache.sling.caconfig.example.ListConfig in project sling by apache.
the class ConfigurationResolverCustomPersistenceTest method testConfig_Nested.
@Test
public void testConfig_Nested() {
context.build().resource("/conf/content/site1/settings/org.apache.sling.caconfig.example.NestedConfig").resource("jcr:content", "stringParam", "configValue3").siblingsMode().resource("subConfig/jcr:content", "stringParam", "configValue4", "intParam", 444, "boolParam", true).hierarchyMode().resource("subListConfig").siblingsMode().resource("1/jcr:content", "stringParam", "configValue2.1").resource("2/jcr:content", "stringParam", "configValue2.2").resource("3/jcr:content", "stringParam", "configValue2.3");
NestedConfig cfg = underTest.get(site1Page1).as(NestedConfig.class);
assertEquals("configValue3", cfg.stringParam());
SimpleConfig subConfig = cfg.subConfig();
assertEquals("configValue4", subConfig.stringParam());
assertEquals(444, subConfig.intParam());
assertEquals(true, subConfig.boolParam());
ListConfig[] listConfig = cfg.subListConfig();
assertEquals(3, listConfig.length);
assertEquals("configValue2.1", listConfig[0].stringParam());
assertEquals("configValue2.2", listConfig[1].stringParam());
assertEquals("configValue2.3", listConfig[2].stringParam());
}
Aggregations