DataSourceConfigurationYamlSwapper implements YamlSwapper<YamlDataSourceConfiguration, DataSourceConfiguration> { @Override public YamlDataSourceConfiguration swapToYamlConfiguration(final DataSourceConfiguration config) { YamlDataSourceConfiguration result = new YamlDataSourceConfiguration(); result.setDataSourceClassName(config.getDataSourceClassName()); result.setProps(config.getProps()); return result; }  @Override YamlDataSourceConfiguration swapToYamlConfiguration(final DataSourceConfiguration config); @Override DataSourceConfiguration swapToObject(final YamlDataSourceConfiguration yamlConfig);  }
@Test public void assertSwapToYaml() { DataSourceConfiguration dataSourceConfig = new DataSourceConfiguration("xxx.jdbc.driver"); dataSourceConfig.getProps().put("url", "xx:xxx"); dataSourceConfig.getProps().put("username", "root"); YamlDataSourceConfiguration actual = dataSourceConfigurationYamlSwapper.swapToYamlConfiguration(dataSourceConfig); 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")); }