### Question:
MelodicGenerator { public RhythmicAccents getHarmonicLoopAltBarAccents(ProgressionUnitBar pBar, int barPosition) { if (pBar.getHarmonicLoopAlt() != null && pBar.getHarmonicLoopAlt().getRhythmicAccents() != null) { switch (barPosition) { case 0: switch (pBar.getHarmonicLoopAlt().getBarCount()) { case 1: case 2: case 3: case 4: return pBar.getHarmonicLoopAlt().getRhythmicAccents().get(0); default: throw new RuntimeException("UNSUPPORTED BAR COUNT"); } case 1: switch (pBar.getHarmonicLoopAlt().getBarCount()) { case 1: return pBar.getHarmonicLoopAlt().getRhythmicAccents().get(0); case 2: case 3: case 4: return pBar.getHarmonicLoopAlt().getRhythmicAccents().get(1); default: throw new RuntimeException("UNSUPPORTED BAR COUNT"); } case 2: switch (pBar.getHarmonicLoopAlt().getBarCount()) { case 1: case 2: return pBar.getHarmonicLoopAlt().getRhythmicAccents().get(0); case 3: case 4: return pBar.getHarmonicLoopAlt().getRhythmicAccents().get(2); default: throw new RuntimeException("UNSUPPORTED BAR COUNT"); } case 3: switch (pBar.getHarmonicLoopAlt().getBarCount()) { case 1: return pBar.getHarmonicLoopAlt().getRhythmicAccents().get(0); case 2: return pBar.getHarmonicLoopAlt().getRhythmicAccents().get(1); case 3: case 4: return pBar.getHarmonicLoopAlt().getRhythmicAccents().get(3); default: throw new RuntimeException("UNSUPPORTED BAR COUNT"); } default: throw new RuntimeException("UNSUPPORTED BAR INDEX"); } } return null; }  QueueState setMelodicPositions(QueueState queueState); RhythmicAccents getHarmonicLoopAltBarAccents(ProgressionUnitBar pBar, int barPosition); RhythmicAccents getHarmonicLoopBarAccents(ProgressionUnitBar pBar, int barPosition); RhythmicAccents getBeatLoopAltBarAccents(ProgressionUnitBar pBar, int barPosition); RhythmicAccents getBeatLoopBarAccents(ProgressionUnitBar pBar, int barPosition); RhythmicAccents sumRhythmicAccents(List<RhythmicAccents> accents); RhythmicAccents setAccentsAboveMean(RhythmicAccents rhythmicAccents, int mean); Integer extractMeanfromAccents(RhythmicAccents rhythmicAccents); Map<ProgressionType, List<HarmonyExtraction>> createTypeToExtractionMap(QueueState queueState);  }### Answer:
@Test public void shouldExtract_Position0_1BarHarmonicLoopAlt (){ HarmonicLoop harmLoop = new HarmonicLoop(); harmLoop.setBarCount(1); harmLoop.setRhythmicAccents(Arrays.asList(createAccentsByPosition(0))); ProgressionUnitBar progressionUnitBar = new ProgressionUnitBar(); progressionUnitBar.setHarmonicLoopAlt(harmLoop); RhythmicAccents result = melodicGenerator.getHarmonicLoopAltBarAccents(progressionUnitBar, 0); assertThat(result.getOneOne()).isEqualToIgnoringCase("1"); }
@Test public void shouldExtract_Position2_2BarHarmonicLoopAlt (){ HarmonicLoop harmLoop = new HarmonicLoop(); harmLoop.setBarCount(2); harmLoop.setRhythmicAccents(Arrays.asList(createAccentsByPosition(0),createAccentsByPosition(1))); ProgressionUnitBar progressionUnitBar = new ProgressionUnitBar(); progressionUnitBar.setHarmonicLoopAlt(harmLoop); RhythmicAccents result = melodicGenerator.getHarmonicLoopAltBarAccents(progressionUnitBar, 2); assertThat(result.getOneOne()).isEqualToIgnoringCase("1"); }