UaaMapUtils { public static <K extends Comparable<? super K>, V> String prettyPrintYaml(Map<K,V> map) { DumperOptions dump = new DumperOptions(); dump.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); dump.setPrettyFlow(true); dump.setIndent(2); dump.setCanonical(false); dump.setExplicitStart(true); Yaml yaml = new Yaml(dump); return yaml.dump(sortByKeys(map)); }  static Map<String, Object> flatten(Map<String, Object> map); static Map<String, Object> getPropertiesStartingWith(ConfigurableEnvironment aEnv,
                                                                String aKeyPrefix); static Map<String, Object> getAllProperties(ConfigurableEnvironment aEnv); static Map<String, Object> getAllProperties(PropertySource<?> aPropSource); @SafeVarargs static Map<K, V> map(E... entries); static Map.Entry<K, V> entry(K key, V value); static Map<K, V> sortByKeys(Map<K,V> map); static String prettyPrintYaml(Map<K,V> map); static Map<String, ?> redactValues(Map<String, ?> map);  }
@Test public void print_sorted_yaml() { String expected = "---\n" + "secondA:\n" + " thirdA:\n" + " keyA: valueA\n" + " thirdB:\n" + " keyB: valueB\n" + "secondB:\n" + " thirdB:\n" + " keyB: valueB\n" + " thirdC:\n" + " emptyMap: {\n" + " }\n" + " emptyString: ''\n" + " keyC: valueC\n" + " nullValue: null\n"; assertEquals(expected, prettyPrintYaml(top)); }