### Question:
MelodicGenerator { public RhythmicAccents getBeatLoopAltBarAccents(ProgressionUnitBar pBar, int barPosition) { if (pBar.getBeatLoopAlt() != null && pBar.getBeatLoopAlt().getRhythmicAccents() != null) { switch (barPosition) { case 0: switch (pBar.getBeatLoopAlt().getBarCount()) { case 1: case 2: case 3: case 4: return pBar.getBeatLoopAlt().getRhythmicAccents().get(0); default: throw new RuntimeException("UNSUPPORTED BAR COUNT"); } case 1: switch (pBar.getBeatLoopAlt().getBarCount()) { case 1: return pBar.getBeatLoopAlt().getRhythmicAccents().get(0); case 2: case 3: case 4: return pBar.getBeatLoopAlt().getRhythmicAccents().get(1); default: throw new RuntimeException("UNSUPPORTED BAR COUNT"); } case 2: switch (pBar.getBeatLoopAlt().getBarCount()) { case 1: case 2: return pBar.getBeatLoopAlt().getRhythmicAccents().get(0); case 3: case 4: return pBar.getBeatLoopAlt().getRhythmicAccents().get(2); default: throw new RuntimeException("UNSUPPORTED BAR COUNT"); } case 3: switch (pBar.getBeatLoopAlt().getBarCount()) { case 1: return pBar.getBeatLoopAlt().getRhythmicAccents().get(0); case 2: return pBar.getBeatLoopAlt().getRhythmicAccents().get(1); case 3: case 4: return pBar.getBeatLoopAlt().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_Position3_2BarBeatLoopAlt (){ BeatLoop beatLoop = new BeatLoop(); beatLoop.setBarCount(2); beatLoop.setRhythmicAccents(Arrays.asList(createAccentsByPosition(0), createAccentsByPosition(1))); ProgressionUnitBar progressionUnitBar = new ProgressionUnitBar(); progressionUnitBar.setBeatLoopAlt(beatLoop); RhythmicAccents result = melodicGenerator.getBeatLoopAltBarAccents(progressionUnitBar, 3); assertThat(result.getTwoOne()).isEqualToIgnoringCase("1"); }
@Test public void shouldExtract_Position3_4BarBeatLoopAlt (){ BeatLoop beatLoop = new BeatLoop(); beatLoop.setBarCount(4); beatLoop.setRhythmicAccents(Arrays.asList(createAccentsByPosition(0), createAccentsByPosition(1), createAccentsByPosition(2), createAccentsByPosition(3))); ProgressionUnitBar progressionUnitBar = new ProgressionUnitBar(); progressionUnitBar.setBeatLoopAlt(beatLoop); RhythmicAccents result = melodicGenerator.getBeatLoopAltBarAccents(progressionUnitBar, 3); assertThat(result.getFourOne()).isEqualToIgnoringCase("1"); }