static List<ConfigProperty> convert( List<JndiBindingsType.JndiBinding.ConfigProperty> properties) { return properties.stream().map(p -> { ConfigProperty prop = new ConfigProperty(); prop.setName(p.getName()); prop.setType(p.getType()); prop.setValue(p.getValue()); return prop; }).collect(Collectors.toList()); } }
@Test public void validJson() { JndiBindingsType.JndiBinding.ConfigProperty configProperty = converter.convertFromText("{'name':'name','type':'type','value':'value'}", null, null); assertThat(configProperty.getName()).isEqualTo("name"); assertThat(configProperty.getType()).isEqualTo("type"); assertThat(configProperty.getValue()).isEqualTo("value"); }
@Test public void configPropertyIsProperlyParsed() { GfshParseResult result = gfsh.parse(COMMAND + " --type=SIMPLE --name=name --jdbc-driver-class=driver --connection-url=url " + "--datasource-config-properties={'name':'name1','type':'type1','value':'value1'},{'name':'name2','type':'type2','value':'value2'}"); JndiBindingsType.JndiBinding.ConfigProperty[] configProperties = (JndiBindingsType.JndiBinding.ConfigProperty[]) result .getParamValue("datasource-config-properties"); assertThat(configProperties).hasSize(2); assertThat(configProperties[0].getValue()).isEqualTo("value1"); assertThat(configProperties[1].getValue()).isEqualTo("value2"); }
addTableRow(tabularData, confProp.getName(), confProp.getValue());
binding.getConnPooledDatasourceClass()); for (JndiBindingsType.JndiBinding.ConfigProperty confProp : binding.getConfigProperties()) { addTableRow(tabularData, confProp.getName(), confProp.getValue());
@Test public void validWhenTypeMissing() { JndiBindingsType.JndiBinding.ConfigProperty configProperty = converter.convertFromText("{'name':'name','value':'value'}", null, null); assertThat(configProperty.getName()).isEqualTo("name"); assertThat(configProperty.getType()).isNull(); assertThat(configProperty.getValue()).isEqualTo("value"); }