RuleSchemaMetaDataYamlSwapper implements YamlSwapper<YamlRuleSchemaMetaData, RuleSchemaMetaData> { @Override public RuleSchemaMetaData swapToObject(final YamlRuleSchemaMetaData yamlConfig) { SchemaMetaData configured = Optional.ofNullable(yamlConfig.getConfiguredSchemaMetaData()).map(this::convertSchema).orElse(new SchemaMetaData()); Map<String, Collection<String>> unconfigured = Optional.ofNullable(yamlConfig.getUnconfiguredSchemaMetaDataMap()).orElse(new HashMap<>()); return new RuleSchemaMetaData(configured, unconfigured); }  @Override YamlRuleSchemaMetaData swapToYamlConfiguration(final RuleSchemaMetaData metaData); @Override RuleSchemaMetaData swapToObject(final YamlRuleSchemaMetaData yamlConfig);  }
@Test public void assertSwapToRuleSchemaMetaData() { YamlRuleSchemaMetaData yamlRuleSchemaMetaData = YamlEngine.unmarshal(readYAML(META_DATA_YAM), YamlRuleSchemaMetaData.class); RuleSchemaMetaData ruleSchemaMetaData = new RuleSchemaMetaDataYamlSwapper().swapToObject(yamlRuleSchemaMetaData); assertNotNull(ruleSchemaMetaData); assertNotNull(ruleSchemaMetaData.getConfiguredSchemaMetaData()); assertNotNull(ruleSchemaMetaData.getConfiguredSchemaMetaData()); assertThat(ruleSchemaMetaData.getConfiguredSchemaMetaData().getAllTableNames(), is(Collections.singleton("t_order"))); assertThat(ruleSchemaMetaData.getConfiguredSchemaMetaData().get("t_order").getIndexes().keySet(), is(Collections.singleton("primary"))); assertThat(ruleSchemaMetaData.getConfiguredSchemaMetaData().getAllColumnNames("t_order").size(), is(1)); assertThat(ruleSchemaMetaData.getConfiguredSchemaMetaData().get("t_order").getColumns().keySet(), is(Collections.singleton("id"))); assertThat(ruleSchemaMetaData.getUnconfiguredSchemaMetaDataMap().keySet(), is(Collections.singleton("ds_0"))); assertThat(ruleSchemaMetaData.getUnconfiguredSchemaMetaDataMap().get("ds_0"), is(Collections.singletonList("t_user"))); }