### Question:
HarmonicKeyUtils { public static List<String> findCompatibleKeys(List<HiveChord> hiveChords) { List<String> compatibleKeys = new ArrayList<>(); for (Map.Entry<String, List<HiveChord>> chordList : KEYS.entrySet()) { boolean allMatch = true; for (HiveChord chordInList : hiveChords) { if (!isChordInKey(chordInList, chordList.getValue())) { allMatch = false; } } if (allMatch) { compatibleKeys.add(chordList.getKey()); } } return compatibleKeys; }  static List<String> findCompatibleKeys(List<HiveChord> hiveChords); static Map<ProgressionUnit.ProgressionType, List<String>> convertProgressionsToChordLists(List<ProgressionUnit> progressionUnits); static HashMap<String, List<HiveChord>> KEYS; }### Answer:
@Test public void shouldMatchCMajor() { List<HiveChord> hiveChords = new ArrayList<>(); hiveChords.add(new HiveChord("cmaj7")); hiveChords.add(new HiveChord("dmin")); hiveChords.add(new HiveChord("gdom7")); List<String> compatibleKeys = HarmonicKeyUtils.findCompatibleKeys(hiveChords); assertThat(compatibleKeys).contains(KeyNames.C_MAJOR); assertThat(compatibleKeys).hasSize(1); }
@Test public void shouldFindThreeMatchingKeys() { List<HiveChord> hiveChords = new ArrayList<>(); hiveChords.add(new HiveChord("dmaj")); List<String> compatibleKeys = HarmonicKeyUtils.findCompatibleKeys(hiveChords); assertThat(compatibleKeys).hasSize(3); assertThat(compatibleKeys).contains(KeyNames.G_MAJOR, KeyNames.D_MAJOR, KeyNames.A_MAJOR); }
@Test public void shouldFindGmajWithDimTriads() { List<HiveChord> hiveChords = new ArrayList<>(); hiveChords.add(new HiveChord("f#dim")); List<String> compatibleKeys = HarmonicKeyUtils.findCompatibleKeys(hiveChords); assertThat(compatibleKeys).hasSize(1); assertThat(compatibleKeys).contains(KeyNames.G_MAJOR); }
@Test public void shouldFindGSharpWhenPassedDimTriad() { List<HiveChord> hiveChords = Arrays.asList(new HiveChord("gdim")); List<String> compatibleKeys = HarmonicKeyUtils.findCompatibleKeys(hiveChords); assertThat(compatibleKeys).hasSize(1); assertThat(compatibleKeys).contains(KeyNames.GS_MAJOR); }