Added integration test for issue.
@@ -6,6 +6,8 @@ import io.bootique.BQModuleProvider;
import io.bootique.BQRuntime;
import io.bootique.annotation.BQConfig;
import io.bootique.annotation.BQConfigProperty;
+import io.bootique.help.ConsoleAppender;
+import io.bootique.help.config.ConfigSectionMapGenerator;
import io.bootique.meta.module.ModulesMetadata;
import io.bootique.unit.BQInternalTestFactory;
import org.junit.Rule;
@@ -15,9 +17,11 @@ import org.mockito.Mockito;
import java.lang.reflect.Type;
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
public class ConfigMetadataIT {
@@ -79,6 +83,67 @@ public class ConfigMetadataIT {
walkThrough);
}
+ @Test
+ public void testRecurciveConfig() {
+ BQRuntime runtime = runtimeFactory.app().module(new BQModuleProvider() {
+ @Override
+ public Module module() {
+ return Mockito.mock(Module.class);
+ }
+
+ @Override
+ public Map<String, Type> configs() {
+ return Collections.singletonMap("pf", TestRecursiveConfig.class);
+ }
+
+ @Override
+ public BQModule.Builder moduleBuilder() {
+ return BQModuleProvider.super
+ .moduleBuilder()
+ .name("my");
+ }
+ }).createRuntime();
+
+ Collection<ConfigMetadataNode> configs = runtime
+ .getInstance(ModulesMetadata.class)
+ .getModules()
+ .stream()
+ .filter(mmd -> "my".equals(mmd.getName()))
+ .findFirst()
+ .get()
+ .getConfigs();
+
+ assertEquals(1, configs.size());
+
+ ConfigValueMetadata cm = (ConfigValueMetadata) configs.iterator().next();
+ assertTrue("pf".equals(cm.getName()));
+
+ StringBuilder buffer = new StringBuilder();
+ ConsoleAppender out = new ConsoleAppender(buffer, 300);
+
+ cm.accept(new ConfigSectionMapGenerator(TestRecursiveConfig.class, out));
+ String help = buffer.toString();
+ assertNotNull(help);
+
+ assertEquals(help, "<value>:\n" +
+ " #\n" +
+ " # Resolved as 'io.bootique.meta.config.ConfigMetadataIT$TestRecursiveConfig'.\n" +
+ " #\n" +
+ "\n" +
+ " p3:\n" +
+ " #\n" +
+ " # Resolved as 'io.bootique.meta.config.ConfigMetadataIT$TestRecursiveConfig'.\n" +
+ " #\n" +
+ " p4:\n" +
+ " #\n" +
+ " # Resolved as 'List<io.bootique.meta.config.ConfigMetadataIT$TestRecursiveConfig>'.\n" +
+ " #\n" +
+ " -\n" +
+ " #\n" +
+ " # Resolved as 'io.bootique.meta.config.ConfigMetadataIT$TestRecursiveConfig'.\n" +
+ " #\n");
+ }
+
@BQConfig
public static class TestConfig {
@@ -94,4 +159,16 @@ public class ConfigMetadataIT {
this.p2 = p2;
}
}
+
+ @BQConfig
+ public static class TestRecursiveConfig {
+
+ @BQConfigProperty
+ public void setP3(TestRecursiveConfig v) {
+ }
+
+ @BQConfigProperty
+ public void setP4(List<TestRecursiveConfig> v) {
+ }
+ }
}
