### Question:
MelodicExtractor { public QueueState extractedAndSetHarmony(QueueState queueState) { for (ProgressionUnit pUnit : queueState.getStructure()) { for (int i = 0; i < pUnit.getProgressionUnitBars().size(); i++) { List<HarmonyExtraction> extractions = createHarmonicExtractionForBar(pUnit.getProgressionUnitBars().get(i)); pUnit.getProgressionUnitBars().get(i).setHarmonicExtractions(extractions); } } return queueState; }  QueueState extractedAndSetHarmony(QueueState queueState); List<HarmonyExtraction> createHarmonicExtractionForBar(ProgressionUnitBar progressionUnitBar); HarmonyExtraction extractedAndSetHarmony(ProgressionUnitBar progressionUnitBar, int noteIndex); int getCurrentBarIndex(int barCount, int currentBar, int index);  }### Answer:
@Test public void shouldExtractHarmoniesAtIndexFromFourBarLoop() { setupFourBarExample(); int noteIndex = 4; HarmonyExtraction extraction = melodicExtractor.extractedAndSetHarmony(progressionUnitBar, noteIndex); assertThat(extraction.getChordname()).isEqualToIgnoringCase("cmaj7"); assertThat(extraction.getHarmonies()).isEqualTo(Arrays.asList("L", "H", "A","B","C","D")); }
@Test public void shouldExtractHarmoniesAtIndexFromTwoBarLoop() { setupTwoBarExample(); int noteIndex = 4; HarmonyExtraction extraction = melodicExtractor.extractedAndSetHarmony(progressionUnitBar, noteIndex); assertThat(extraction.getChordname()).isEqualToIgnoringCase("cmaj7"); assertThat(extraction.getHarmonies()).isEqualTo(Arrays.asList("L", "H", "C","D")); }