Search in sources :

Example 11 with Config

use of io.helidon.config.Config in project helidon by oracle.

the class BuilderConfigMapperTest method testBuilderNoBuildMethod.

@Test
public void testBuilderNoBuildMethod() {
    Config config = Config.empty();
    assertThrows(ConfigMappingException.class, () -> config.as(BuilderNoBuildMethodBean.class).get());
}
Also used : Config(io.helidon.config.Config) Test(org.junit.jupiter.api.Test)

Example 12 with Config

use of io.helidon.config.Config in project helidon by oracle.

the class BuilderConfigMapperTest method testBuilderBadTypeBuildMethod.

@Test
public void testBuilderBadTypeBuildMethod() {
    Config config = Config.empty();
    assertThrows(ConfigMappingException.class, () -> config.as(BadTypeBuilderBean.class).get());
}
Also used : Config(io.helidon.config.Config) Test(org.junit.jupiter.api.Test)

Example 13 with Config

use of io.helidon.config.Config in project helidon by oracle.

the class FactoryMethodConfigMapperTest method testAmbiguousFromMethods.

// 
// static from method
// 
@Test
public void testAmbiguousFromMethods() {
    Config config = Config.empty();
    ConfigMappingException ex = assertThrows(ConfigMappingException.class, () -> {
        config.as(AmbiguousFromMethodsBean.class).get();
    });
    assertThat(ex.getMessage(), stringContainsInOrder(List.of(AmbiguousFromMethodsBean.class.getName(), "No mapper configured")));
}
Also used : Config(io.helidon.config.Config) ConfigMappingException(io.helidon.config.ConfigMappingException) Test(org.junit.jupiter.api.Test)

Example 14 with Config

use of io.helidon.config.Config in project helidon by oracle.

the class FactoryMethodConfigMapperTest method testTransientConstructor.

@Test
public void testTransientConstructor() {
    Config config = Config.create(ConfigSources.create(ObjectNode.builder().addValue("app.number", "1").addValue("app.uri", "this:is/my?uri").addValue("app.path", "/this/is/my.path").addValue("app.unused", "true").addList("app.numbers", ListNode.builder().addValue("1").addValue("2").build()).addList("app.uris", ListNode.builder().addValue("this:is/my?uri").addValue("http://another/uri").build()).addList("app.paths", ListNode.builder().addValue("/this/is/my.path").addValue("/and/another.path").build()).build()));
    ConstructorBean bean = config.get("app").as(ConstructorBean.class).get();
    assertThat(bean.getNumber(), is(1));
    assertThat(bean.getUri(), is(URI.create("this:is/my?uri")));
    assertThat(bean.getCustom(), is(CustomType.from("/this/is/my.path")));
    assertThat(bean.getNumbers(), contains(1, 2));
    assertThat(bean.getUris(), contains(URI.create("this:is/my?uri"), URI.create("http://another/uri")));
    assertThat(bean.getCustoms(), contains(CustomType.from("/this/is/my.path"), CustomType.from("/and/another.path")));
}
Also used : Config(io.helidon.config.Config) Test(org.junit.jupiter.api.Test)

Example 15 with Config

use of io.helidon.config.Config in project helidon by oracle.

the class FactoryMethodConfigMapperTest method testMissingParamsConstructor.

@Test
public void testMissingParamsConstructor() {
    Config config = Config.create(ConfigSources.create(Map.of("app.number", "1")));
    ConfigMappingException ex = assertThrows(ConfigMappingException.class, () -> {
        config.get("app").as(ConstructorBean.class).get();
    });
    assertThat(ex.getMessage(), stringContainsInOrder(List.of("'app'", "ConstructorBean", "Missing value for parameter 'uri'.")));
}
Also used : Config(io.helidon.config.Config) ConfigMappingException(io.helidon.config.ConfigMappingException) 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