List<DynamicTest> () { List<NamedFailure> failures = new ArrayList<>(); Map<String, Map<Shortcut, List<String>>> expectedDuplicates = collectExpectedDuplicatedShortcuts(); Map<String, Map<Shortcut, List<String>>> actualDuplicates = collectActualDuplicatedShortcuts(); Set<String> allKeymaps = ContainerUtil.union(expectedDuplicates.keySet(), actualDuplicates.keySet()); Collection<String> newKeymaps = ContainerUtil.subtract(allKeymaps, expectedDuplicates.keySet()); Collection<String> missingKeymaps = ContainerUtil.subtract(allKeymaps, actualDuplicates.keySet()); for (String keymap : newKeymaps) { failures.add(new NamedFailure("new keymap: " + keymap, "Modify 'known duplicates list' test data")); } for (String keymap : missingKeymaps) { failures.add(new NamedFailure("missing keymap: " + keymap, "Modify 'known duplicates list' test data")); } for (String keymap : ContainerUtil.sorted(allKeymaps)) { Map<Shortcut, List<String>> actual = ContainerUtil.notNullize(actualDuplicates.get(keymap)); Map<Shortcut, List<String>> expected = ContainerUtil.notNullize(expectedDuplicates.get(keymap)); for (Shortcut shortcut : ContainerUtil.union(actual.keySet(), expected.keySet())) { List<String> actualActions = Objects.requireNonNullElse(actual.get(shortcut), Collections.emptyList()); if (Objects.requireNonNullElse(expected.get(shortcut), Collections.emptyList()).containsAll(actualActions)) { continue; } String key = getText(shortcut); String replacement = " {\"" + key + '"' + ", " + " ".repeat(Math.max(0, KEY_LENGTH - key.length())) + (actualActions.isEmpty() ? "NO_DUPLICATES" : actualActions.stream().sorted().map(a -> '"' + a + '"').collect(Collectors.joining(", ")) ) + "},\n"; String message = String.format(""" Shortcut conflicts found in keymap '%s': Please specify 'use-shortcut-of' attribute for your action if it is similar to another action (but it won't appear in Settings/Keymap), reassign shortcut, or, if absolutely must, modify the 'known duplicates list' %s""", keymap, replacement); failures.add(new NamedFailure("duplicate shortcut in keymap " + keymap + ": " + key, message)); } } return DynamicTests.asDynamicTests(failures, "duplicate shortcuts"); }