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());
}
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());
}
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")));
}
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")));
}
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'.")));
}
Aggregations