GovernanceConfigurationYamlSwapper implements YamlSwapper<YamlGovernanceConfiguration, GovernanceConfiguration> { @Override public YamlGovernanceConfiguration swapToYamlConfiguration(final GovernanceConfiguration data) { YamlGovernanceConfiguration result = new YamlGovernanceConfiguration(); result.setName(data.getName()); result.setRegistryCenter(governanceCenterConfigurationSwapper.swapToYamlConfiguration(data.getRegistryCenterConfiguration())); if (data.getAdditionalConfigCenterConfiguration().isPresent()) { result.setAdditionalConfigCenter(governanceCenterConfigurationSwapper.swapToYamlConfiguration(data.getAdditionalConfigCenterConfiguration().get())); } return result; }  @Override YamlGovernanceConfiguration swapToYamlConfiguration(final GovernanceConfiguration data); @Override GovernanceConfiguration swapToObject(final YamlGovernanceConfiguration yamlConfig);  }
@Test public void assertSwapToYamlGovernanceConfigurationWithoutAdditionalConfigCenterConfiguration() { GovernanceConfiguration expected = createGovernanceConfigurationWithoutAdditionalConfigCenterConfiguration(); YamlGovernanceConfiguration actual = new GovernanceConfigurationYamlSwapper().swapToYamlConfiguration(expected); assertThat(actual.getName(), is(expected.getName())); assertThat(actual.isOverwrite(), is(expected.isOverwrite())); assertThat(actual.getRegistryCenter().getType(), is(expected.getRegistryCenterConfiguration().getType())); assertThat(actual.getRegistryCenter().getServerLists(), is(expected.getRegistryCenterConfiguration().getServerLists())); assertThat(actual.getRegistryCenter().getProps(), is(expected.getRegistryCenterConfiguration().getProps())); assertFalse(expected.getAdditionalConfigCenterConfiguration().isPresent()); }
@Test public void assertSwapToYamlGovernanceConfigurationWithAdditionalConfigCenterConfiguration() { GovernanceConfiguration expected = createGovernanceConfigurationWithAdditionalConfigCenterConfiguration(); YamlGovernanceConfiguration actual = new GovernanceConfigurationYamlSwapper().swapToYamlConfiguration(expected); assertThat(actual.getName(), is(expected.getName())); assertThat(actual.isOverwrite(), is(expected.isOverwrite())); assertThat(actual.getRegistryCenter().getType(), is(expected.getRegistryCenterConfiguration().getType())); assertThat(actual.getRegistryCenter().getServerLists(), is(expected.getRegistryCenterConfiguration().getServerLists())); assertThat(actual.getRegistryCenter().getProps(), is(expected.getRegistryCenterConfiguration().getProps())); assertTrue(expected.getAdditionalConfigCenterConfiguration().isPresent()); assertThat(actual.getAdditionalConfigCenter().getType(), is(expected.getAdditionalConfigCenterConfiguration().get().getType())); assertThat(actual.getAdditionalConfigCenter().getServerLists(), is(expected.getAdditionalConfigCenterConfiguration().get().getServerLists())); assertThat(actual.getAdditionalConfigCenter().getProps(), is(expected.getAdditionalConfigCenterConfiguration().get().getProps())); }