ProcessorConfig { public static ProcessorConfig mergeProcessorConfigs(ProcessorConfig ... processorConfigs) { Map<String, TreeMap> configs = mergeConfig(processorConfigs); Set<String> excludes = mergeExcludes(processorConfigs); List<String> includes = mergeIncludes(processorConfigs); return new ProcessorConfig(includes, excludes, configs); } ProcessorConfig();  ProcessorConfig(List<String> includes, Set<String> excludes, Map<String, TreeMap> config); String getConfig(String name, String key); Map<String, String> getConfigMap(String name); List<T> prepareProcessors(List<T> namedList, String type); boolean use(String inc); static ProcessorConfig cloneProcessorConfig(ProcessorConfig processorConfig); static ProcessorConfig mergeProcessorConfigs(ProcessorConfig ... processorConfigs); static final ProcessorConfig EMPTY; }
@Test public void merge() { Yaml yaml = new Yaml(); List<Map> data = (List<Map>) yaml.load(getClass().getResourceAsStream("/fabric8/config/ProcessorConfigTest.yml")); for (Map entry : data) { List<Map> inputs = (List<Map>) entry.get("input"); ArrayList<ProcessorConfig> processorConfigs = new ArrayList<>(); for (Map input : inputs) { processorConfigs.add(extractProcessorConfig(input)); } ProcessorConfig merged = ProcessorConfig.mergeProcessorConfigs(processorConfigs.toArray(new ProcessorConfig[0])); ProcessorConfig expected = extractProcessorConfig((Map) entry.get("merged")); assertEquals(expected.includes, merged.includes); assertEquals(expected.excludes, merged.excludes); assertEquals(expected.config.keySet(), merged.config.keySet()); for (Map.Entry<String, TreeMap> configEntry : merged.config.entrySet()) { TreeMap<String, String> expectedValues = expected.config.get(configEntry.getKey()); TreeMap<String, String> mergedValues = configEntry.getValue(); assertEquals(expectedValues.size(),mergedValues.size()); for (Map.Entry<String, String> valEntry : mergedValues.entrySet()) { assertEquals(expectedValues.get(valEntry.getKey()), valEntry.getValue()); } } } }