use of io.helidon.config.Config in project helidon by oracle.
the class GenericConfigMapperTest method testWithDefault.
@Test
public void testWithDefault() {
Config config = Config.builder().sources(ConfigSources.create(prepareConfigApp(// uid
false, // greeting
true, // PAGESIZE
false, // basicRange
true, // logging
true, // security
true, // names
true).build())).disableEnvironmentVariablesSource().disableSystemPropertiesSource().build();
print(config);
AppConfig appConfig = config.get("app").as(AppConfig.class).get();
assertThat(appConfig.getPageSize(), is(10));
}
use of io.helidon.config.Config in project helidon by oracle.
the class GenericConfigMapperTest method testWrongDefaultsNotUsed.
@Test
public void testWrongDefaultsNotUsed() {
Config config = Config.builder(ConfigSources.create(Map.of("numberWithDefault", "23", "numberWithDefaultSupplier", "42"))).disableEnvironmentVariablesSource().disableSystemPropertiesSource().build();
WrongDefaultBean wrongDefaultBean = config.as(WrongDefaultBean.class).get();
assertThat(wrongDefaultBean.numberWithDefault, is(23));
assertThat(wrongDefaultBean.numberWithDefaultSupplier, is(42));
}
use of io.helidon.config.Config in project helidon by oracle.
the class GenericConfigMapperTest method testTransient.
@Test
public void testTransient() {
Config config = Config.builder().sources(ConfigSources.create(prepareConfigApp(// UID
true, // greeting
true, // pageSize
true, // basicRange
true, // logging
true, // security
true, // names
true).build())).disableEnvironmentVariablesSource().disableSystemPropertiesSource().build();
print(config);
assertThat(config.get("app.uid").type(), is(Type.VALUE));
assertThat(config.get("app.security.providers.0.uid").type(), is(Type.VALUE));
assertThat(config.get("app.security.providers.1.uid").type(), is(Type.VALUE));
AppConfig appConfig = config.get("app").as(AppConfig.class).get();
assertThat(appConfig.getUid(), is(nullValue()));
assertThat(appConfig.getSecurity().getProviders().get(0).getUid(), is(nullValue()));
assertThat(appConfig.getSecurity().getProviders().get(1).getUid(), is(nullValue()));
}
use of io.helidon.config.Config in project helidon by oracle.
the class CustomParserPrecedenceTest method testCustomParserOverride.
@Test
public void testCustomParserOverride() {
Config config = configBuilder().build();
assertThat(config.get(Parsers1Priority100ConfigParser.KEY_PREFIX + KEY).asString(), is(ConfigValues.simpleValue(VALUE)));
}
use of io.helidon.config.Config in project helidon by oracle.
the class ConfigCreateDefaultFromEnvVarsTest method testCreate.
@Test
@ExtendWith(RestoreSystemPropertiesExt.class)
public void testCreate() {
Config config = Config.create();
assertThat(config.get(KEY).asString(), is(simpleValue(ENV_VALUE)));
}
Aggregations