use of io.helidon.config.Config in project helidon by oracle.
the class AbstractComplexConfigTest method testStringListDefault.
@Test
public void testStringListDefault() {
Config node = getMissingConfig();
List<String> defaultValue = Arrays.asList("def-1", "def-2", "def-3");
String[] expected = defaultValue.toArray(new String[0]);
assertThat(node.asList(String.class).orElse(defaultValue), contains(expected));
assertThat(node.asList(aConfig -> aConfig.asString().get()).orElse(defaultValue), contains(expected));
}
use of io.helidon.config.Config in project helidon by oracle.
the class DemoTest method testUseAppConfigMapper.
@Test
public void testUseAppConfigMapper() {
Config config = Config.builder().sources(ConfigSources.classpath("application.conf")).addParser(HoconConfigParser.create()).disableValueResolving().build();
AppConfig appConfig = config.get("app").as(// MAP using provided Mapper
new AppConfigMapper()).get();
assertThat(appConfig.getGreeting(), is("Hello"));
assertThat(appConfig.getName(), is("Demo"));
assertThat(appConfig.getPageSize(), is(20));
assertThat(appConfig.getBasicRange(), contains(-20, 20));
assertThat(appConfig.isStorageEnabled(), is(false));
assertThat(appConfig.getStoragePassphrase(), is("${AES=thisIsEncriptedPassphrase}"));
}
use of io.helidon.config.Config in project helidon by oracle.
the class DemoTest method testRegisterAppConfigMapper.
@Test
public void testRegisterAppConfigMapper() {
Config config = Config.builder().sources(ConfigSources.classpath("application.conf")).addParser(HoconConfigParser.create()).addMapper(AppConfig.class, new AppConfigMapper()).disableValueResolving().build();
AppConfig appConfig = config.get("app").as(// get AS type
AppConfig.class).get();
assertThat(appConfig.getGreeting(), is("Hello"));
assertThat(appConfig.getName(), is("Demo"));
assertThat(appConfig.getPageSize(), is(20));
assertThat(appConfig.getBasicRange(), contains(-20, 20));
assertThat(appConfig.isStorageEnabled(), is(false));
assertThat(appConfig.getStoragePassphrase(), is("${AES=thisIsEncriptedPassphrase}"));
}
use of io.helidon.config.Config in project helidon by oracle.
the class DemoTest method testCreateConfig.
@Test
public void testCreateConfig() {
// looks for: application .yaml | .conf | .json | .properties on classpath
Config config = Config.create();
assertThat(config.get("app.greeting").asString().get(), is("Hello"));
}
use of io.helidon.config.Config in project helidon by oracle.
the class DemoTest method testSecurityFilter.
@Test
public void testSecurityFilter() {
Config config = Config.builder().sources(ConfigSources.classpath("application.conf")).addParser(HoconConfigParser.create()).addFilter(// custom config filter
new SecurityConfigFilter()).disableValueResolving().build();
assertThat(config.get("app.storagePassphrase").asString(), is(simpleValue("Password1.")));
}
Aggregations