EncryptTableRuleConfigurationYamlSwapper implements YamlSwapper<YamlEncryptTableRuleConfiguration, EncryptTableRuleConfiguration> { @Override public EncryptTableRuleConfiguration swapToObject(final YamlEncryptTableRuleConfiguration yamlConfig) { Collection<EncryptColumnRuleConfiguration> columns = new LinkedList<>(); for (Entry<String, YamlEncryptColumnRuleConfiguration> entry : yamlConfig.getColumns().entrySet()) { YamlEncryptColumnRuleConfiguration yamlEncryptColumnRuleConfig = entry.getValue(); yamlEncryptColumnRuleConfig.setLogicColumn(entry.getKey()); columns.add(columnYamlSwapper.swapToObject(yamlEncryptColumnRuleConfig)); } return new EncryptTableRuleConfiguration(yamlConfig.getName(), columns); }  @Override YamlEncryptTableRuleConfiguration swapToYamlConfiguration(final EncryptTableRuleConfiguration data); @Override EncryptTableRuleConfiguration swapToObject(final YamlEncryptTableRuleConfiguration yamlConfig);  }
@Test public void assertSwapToObject() { YamlEncryptColumnRuleConfiguration encryptColumnRuleConfig = new YamlEncryptColumnRuleConfiguration(); encryptColumnRuleConfig.setLogicColumn("encrypt_column"); encryptColumnRuleConfig.setCipherColumn("encrypt_cipher"); encryptColumnRuleConfig.setAssistedQueryColumn("encrypt_assisted"); encryptColumnRuleConfig.setPlainColumn("encrypt_plain"); encryptColumnRuleConfig.setEncryptorName("test_encryptor"); Map<String, YamlEncryptColumnRuleConfiguration> columns = new LinkedHashMap<>(1); columns.put("test_column", encryptColumnRuleConfig); YamlEncryptTableRuleConfiguration yamlEncryptTableRuleConfig = new YamlEncryptTableRuleConfiguration(); yamlEncryptTableRuleConfig.setName("test_table"); yamlEncryptTableRuleConfig.setColumns(columns); EncryptTableRuleConfiguration actualEncryptTableRuleConfig = tableRuleConfigYamlSwapper.swapToObject(yamlEncryptTableRuleConfig); assertNotNull(actualEncryptTableRuleConfig); assertThat(actualEncryptTableRuleConfig.getName(), is("test_table")); Collection<EncryptColumnRuleConfiguration> actualColumns = actualEncryptTableRuleConfig.getColumns(); assertFalse(actualColumns.isEmpty()); assertThat(actualColumns.size(), is(1)); }