Search in sources :

Example 31 with Config

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));
}
Also used : Config(io.helidon.config.Config) ConfigMappers(io.helidon.config.ConfigMappers) Test(org.junit.jupiter.api.Test)

Example 32 with Config

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));
}
Also used : Config(io.helidon.config.Config) Test(org.junit.jupiter.api.Test)

Example 33 with Config

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));
}
Also used : Config(io.helidon.config.Config) ConfigMappers(io.helidon.config.ConfigMappers) Test(org.junit.jupiter.api.Test)

Example 34 with Config

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));
}
Also used : Config(io.helidon.config.Config) ConfigMappers(io.helidon.config.ConfigMappers) Test(org.junit.jupiter.api.Test)

Example 35 with Config

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));
}
Also used : Config(io.helidon.config.Config) ConfigMappers(io.helidon.config.ConfigMappers) URI(java.net.URI) Test(org.junit.jupiter.api.Test)

Aggregations

Config (io.helidon.config.Config)329 Test (org.junit.jupiter.api.Test)169 LogConfig (io.helidon.common.LogConfig)56 WebServer (io.helidon.webserver.WebServer)54 Routing (io.helidon.webserver.Routing)51 BeforeAll (org.junit.jupiter.api.BeforeAll)24 Security (io.helidon.security.Security)20 HealthSupport (io.helidon.health.HealthSupport)18 Single (io.helidon.common.reactive.Single)17 MetricsSupport (io.helidon.metrics.MetricsSupport)16 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)16 ConfigSources (io.helidon.config.ConfigSources)15 JsonpSupport (io.helidon.media.jsonp.JsonpSupport)15 SecurityContext (io.helidon.security.SecurityContext)15 Optional (java.util.Optional)15 TimeUnit (java.util.concurrent.TimeUnit)15 WebSecurity (io.helidon.security.integration.webserver.WebSecurity)13 HealthChecks (io.helidon.health.checks.HealthChecks)12 WebClient (io.helidon.webclient.WebClient)12 GrpcRouting (io.helidon.grpc.server.GrpcRouting)11