AuthenticationYamlSwapper implements YamlSwapper<YamlAuthenticationConfiguration, Authentication> { @Override public YamlAuthenticationConfiguration swapToYamlConfiguration(final Authentication data) { YamlAuthenticationConfiguration result = new YamlAuthenticationConfiguration(); result.setUsers(Maps.transformValues(data.getUsers(), proxyUserYamlSwapper::swapToYamlConfiguration)); return result; }  @Override YamlAuthenticationConfiguration swapToYamlConfiguration(final Authentication data); @Override Authentication swapToObject(final YamlAuthenticationConfiguration yamlConfig);  }
@Test public void assertSwapToYaml() { Authentication authentication = new Authentication(); authentication.getUsers().put("user1", new ProxyUser("pwd1", Collections.singleton("db1"))); authentication.getUsers().put("user2", new ProxyUser("pwd2", Collections.singleton("db2"))); YamlAuthenticationConfiguration actual = new AuthenticationYamlSwapper().swapToYamlConfiguration(authentication); assertThat(actual.getUsers().size(), is(2)); assertThat(actual.getUsers().get("user1").getPassword(), is("pwd1")); assertThat(actual.getUsers().get("user1").getAuthorizedSchemas(), is("db1")); assertThat(actual.getUsers().get("user2").getPassword(), is("pwd2")); assertThat(actual.getUsers().get("user2").getAuthorizedSchemas(), is("db2")); }