use of io.helidon.config.Config in project helidon by oracle.
the class AbstractComplexConfigTest method testBooleanDefault.
@Test
public void testBooleanDefault() {
Config node = getMissingConfig();
Boolean defaultValue = true;
Boolean expected = defaultValue;
assertThat(node.asBoolean().orElse(defaultValue), is(expected));
assertThat(node.as(Boolean.class).orElse(defaultValue), is(expected));
assertThat(node.asString().as(ConfigMappers::toBoolean).orElse(defaultValue), is(expected));
assertThat(node.as(Boolean.class).orElse(defaultValue), is(expected));
}
use of io.helidon.config.Config in project helidon by oracle.
the class AbstractComplexConfigTest method testLongListDefault.
@Test
public void testLongListDefault() {
Config node = getMissingConfig();
List<Long> defaultValue = Arrays.asList(Long.MIN_VALUE, 0L, Long.MAX_VALUE);
Long[] expected = defaultValue.toArray(new Long[0]);
assertThat(node.asList(Long.class).orElse(defaultValue), contains(expected));
}
use of io.helidon.config.Config in project helidon by oracle.
the class AbstractComplexConfigTest method testIntDefault.
@Test
public void testIntDefault() {
Config node = getMissingConfig();
int expected = 42;
int defaultValue = expected;
assertThat(node.asInt().orElse(defaultValue), is(expected));
assertThat(node.as(Integer.class).orElse(defaultValue), is(expected));
assertThat(node.asString().as(ConfigMappers::toInt).orElse(defaultValue), is(expected));
assertThat(node.asInt().orElse(defaultValue), is(expected));
assertThat(node.as(Integer.class).orElse(defaultValue), is(expected));
}
use of io.helidon.config.Config in project helidon by oracle.
the class AbstractComplexConfigTest method testDoubleDefault.
@Test
public void testDoubleDefault() {
Config node = getMissingConfig();
double expected = -1234.5678;
double defaultValue = expected;
assertThat(node.asDouble().orElse(defaultValue), is(expected));
assertThat(node.as(Double.class).orElse(defaultValue), is(expected));
assertThat(node.asString().as(ConfigMappers::toDouble).orElse(defaultValue), is(expected));
assertThat(node.asDouble().orElse(defaultValue), is(expected));
assertThat(node.as(Double.class).orElse(defaultValue), is(expected));
}
use of io.helidon.config.Config in project helidon by oracle.
the class AbstractComplexConfigTest method testUriDefault.
@Test
public void testUriDefault() {
Config node = getMissingConfig();
URI expected = URI.create("http://localhost");
URI defaultValue = expected;
assertThat(node.as(URI.class).orElse(defaultValue), is(expected));
assertThat(node.asString().as(ConfigMappers::toUri).orElse(defaultValue), is(expected));
assertThat(node.as(URI.class).orElse(defaultValue), is(expected));
assertThat(node.asString().as(ConfigMappers::toUri).orElse(defaultValue), is(expected));
}
Aggregations