PrimaryReplicaReplicationRuleAlgorithmProviderConfigurationYamlSwapper implements YamlRuleConfigurationSwapper<YamlPrimaryReplicaReplicationRuleConfiguration, AlgorithmProvidedPrimaryReplicaReplicationRuleConfiguration> { @Override public AlgorithmProvidedPrimaryReplicaReplicationRuleConfiguration swapToObject(final YamlPrimaryReplicaReplicationRuleConfiguration yamlConfig) { Collection<PrimaryReplicaReplicationDataSourceRuleConfiguration> dataSources = new LinkedList<>(); for (Entry<String, YamlPrimaryReplicaReplicationDataSourceRuleConfiguration> entry : yamlConfig.getDataSources().entrySet()) { dataSources.add(swapToObject(entry.getKey(), entry.getValue())); } AlgorithmProvidedPrimaryReplicaReplicationRuleConfiguration ruleConfig = new AlgorithmProvidedPrimaryReplicaReplicationRuleConfiguration(); ruleConfig.setDataSources(dataSources); return ruleConfig; }  @Override YamlPrimaryReplicaReplicationRuleConfiguration swapToYamlConfiguration(final AlgorithmProvidedPrimaryReplicaReplicationRuleConfiguration data); @Override AlgorithmProvidedPrimaryReplicaReplicationRuleConfiguration swapToObject(final YamlPrimaryReplicaReplicationRuleConfiguration yamlConfig); @Override Class<AlgorithmProvidedPrimaryReplicaReplicationRuleConfiguration> getTypeClass(); @Override String getRuleTagName(); @Override int getOrder();  }
@Test public void assertSwapToObject() { AlgorithmProvidedPrimaryReplicaReplicationRuleConfiguration actual = swapper.swapToObject(createYamlPrimaryReplicaReplicationRuleConfiguration()); assertNotNull(actual); assertNotNull(actual.getDataSources()); assertTrue(actual.getDataSources().iterator().hasNext()); PrimaryReplicaReplicationDataSourceRuleConfiguration ruleConfig = actual.getDataSources().iterator().next(); assertNotNull(ruleConfig); assertThat(ruleConfig.getName(), is("name")); assertThat(ruleConfig.getPrimaryDataSourceName(), is("primaryDataSourceName")); assertThat(ruleConfig.getLoadBalancerName(), is("loadBalancerName")); assertThat(ruleConfig.getReplicaDataSourceNames(), is(Collections.singletonList("replicaDataSourceName"))); assertThat(actual.getLoadBalanceAlgorithms(), is(Collections.emptyMap())); }