DataSourceConfigurationYamlSwapper implements YamlSwapper<YamlDataSourceConfiguration, DataSourceConfiguration> { @Override public DataSourceConfiguration swapToObject(final YamlDataSourceConfiguration yamlConfig) { DataSourceConfiguration result = new DataSourceConfiguration(yamlConfig.getDataSourceClassName()); result.getProps().putAll(yamlConfig.getProps()); return result; }  @Override YamlDataSourceConfiguration swapToYamlConfiguration(final DataSourceConfiguration config); @Override DataSourceConfiguration swapToObject(final YamlDataSourceConfiguration yamlConfig);  }
@Test public void assertSwapToConfiguration() { YamlDataSourceConfiguration yamlConfig = new YamlDataSourceConfiguration(); yamlConfig.setDataSourceClassName("xxx.jdbc.driver"); yamlConfig.getProps().put("url", "xx:xxx"); yamlConfig.getProps().put("username", "root"); DataSourceConfiguration actual = dataSourceConfigurationYamlSwapper.swapToObject(yamlConfig); assertThat(actual.getDataSourceClassName(), is("xxx.jdbc.driver")); assertThat(actual.getProps().size(), is(2)); assertThat(actual.getProps().get("url").toString(), is("xx:xxx")); assertThat(actual.getProps().get("username").toString(), is("root")); }