YamlRuleConfigurationSwapperEngine { public Collection<RuleConfiguration> swapToRuleConfigurations(final Collection<YamlRuleConfiguration> yamlRuleConfigs) { Collection<RuleConfiguration> result = new LinkedList<>(); Collection<Class<?>> ruleConfigurationTypes = yamlRuleConfigs.stream().map(YamlRuleConfiguration::getRuleConfigurationType).collect(Collectors.toList()); for (Entry<Class<?>, YamlRuleConfigurationSwapper> entry : OrderedSPIRegistry.getRegisteredServicesByClass(ruleConfigurationTypes, YamlRuleConfigurationSwapper.class).entrySet()) { result.addAll(swapToRuleConfigurations(yamlRuleConfigs, entry.getKey(), entry.getValue())); } return result; }  @SuppressWarnings("unchecked") Collection<YamlRuleConfiguration> swapToYamlConfigurations(final Collection<RuleConfiguration> ruleConfigurations); Collection<RuleConfiguration> swapToRuleConfigurations(final Collection<YamlRuleConfiguration> yamlRuleConfigs); @SneakyThrows(ReflectiveOperationException.class) static Map<String, Class<?>> getYamlShortcuts();  }
@Test public void assertSwapToRuleConfigurations() { FixtureYamlRuleConfiguration yamlRuleConfig = new FixtureYamlRuleConfiguration(); yamlRuleConfig.setName("test"); Collection<RuleConfiguration> actual = new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(Collections.singletonList(yamlRuleConfig)); assertThat(actual.size(), is(1)); assertThat(((FixtureRuleConfiguration) actual.iterator().next()).getName(), is("test")); }