UserConfigBuilder { public static UserConfigRepo build(Element producerSpec, ConfigDefinitionStore configDefinitionStore, DeployLogger deployLogger) { final Map<ConfigDefinitionKey, ConfigPayloadBuilder> builderMap = new LinkedHashMap<>(); if (producerSpec == null) { log.log(Level.FINEST, "In getUserConfigs. producerSpec is null"); } log.log(Level.FINE, "getUserConfigs for " + producerSpec); for (Element configE : XML.getChildren(producerSpec, "config")) { buildElement(configE, builderMap, configDefinitionStore, deployLogger); } return new UserConfigRepo(builderMap); }  static UserConfigRepo build(Element producerSpec, ConfigDefinitionStore configDefinitionStore, DeployLogger deployLogger); static final Logger log; }
@Test public void require_that_simple_config_is_resolved() { Element configRoot = getDocument("<config name=\"test.simpletypes\">" + " <intval>13</intval>" + "</config>" + "<config name=\"test.simpletypes\" version=\"1\">" + " <stringval>foolio</stringval>" + "</config>"); UserConfigRepo map = UserConfigBuilder.build(configRoot, configDefinitionStore, new BaseDeployLogger()); assertFalse(map.isEmpty()); ConfigDefinitionKey key = new ConfigDefinitionKey("simpletypes", "test"); assertNotNull(map.get(key)); SimpletypesConfig config = createConfig(SimpletypesConfig.class, map.get(key)); assertThat(config.intval(), is(13)); assertThat(config.stringval(), is("foolio")); }
@Test public void require_that_arrays_config_is_resolved() { Element configRoot = getDocument("<config name=\"test.arraytypes\">" + " <intarr operation=\"append\">13</intarr>" + " <intarr operation=\"append\">10</intarr>" + " <intarr operation=\"append\">1337</intarr>" + "</config>"); UserConfigRepo map = UserConfigBuilder.build(configRoot, configDefinitionStore, new BaseDeployLogger()); assertFalse(map.isEmpty()); ConfigDefinitionKey key = new ConfigDefinitionKey("arraytypes", "test"); assertNotNull(map.get(key)); ArraytypesConfig config = createConfig(ArraytypesConfig.class, map.get(key)); assertThat(config.intarr().size(), is(3)); assertThat(config.intarr(0), is(13)); assertThat(config.intarr(1), is(10)); assertThat(config.intarr(2), is(1337)); }
@Test public void no_exception_when_config_class_does_not_exist() { Element configRoot = getDocument("<config name=\"is.unknown\">" + " <foo>1</foo>" + "</config>"); UserConfigRepo repo = UserConfigBuilder.build(configRoot, configDefinitionStore, new BaseDeployLogger()); ConfigPayloadBuilder builder = repo.get(new ConfigDefinitionKey("unknown", "is")); assertNotNull(builder); }