### Question:
BeatLoopSelector implements IBeatLoopSelector { @Override public IWeightableLoop selectByWeightAndBarCount(List<? extends IWeightableLoop> weightables, int maxBarCount) { List<IWeightableLoop> filteredByBarCount = new ArrayList<>(); weightables.forEach(weightable -> { if(weightable.getBarCount() <= maxBarCount){ filteredByBarCount.add(weightable); } }); return selectByWeight(filteredByBarCount); }  @Override BeatLoop selectBeatLoop(List<BeatLoop> beatLoops); @Override IWeightableLoop selectByWeight(List<? extends IWeightableLoop> weightables); @Override IWeightableLoop selectByWeightAndBarCount(List<? extends IWeightableLoop> weightables, int maxBarCount);  }### Answer:
@Test public void ShouldSelectByWeightAndBarCount(){ BeatLoop beatLoopAltOptionOne = new BeatLoop(); beatLoopAltOptionOne.setBarCount(4); beatLoopAltOptionOne.setFileName("beatLoopAltOptionOne"); BeatLoop beatLoopAltOptionTwo = new BeatLoop(); beatLoopAltOptionTwo.setBarCount(2); beatLoopAltOptionTwo.setFileName("beatLoopAltOptionTwo"); BeatLoop beatLoopAltOptionThree = new BeatLoop(); beatLoopAltOptionThree.setBarCount(3); beatLoopAltOptionThree.setFileName("beatLoopAltOptionThree"); ProgressionUnitBar progressionUnitBar = new ProgressionUnitBar(); progressionUnitBar.getBeatLoopAltOptions().add(beatLoopAltOptionOne); progressionUnitBar.getBeatLoopAltOptions().add(beatLoopAltOptionTwo); progressionUnitBar.getBeatLoopAltOptions().add(beatLoopAltOptionThree); BeatLoop beatSelection = (BeatLoop) beatLoopAltSelector.selectByWeightAndBarCount(progressionUnitBar.getBeatLoopAltOptions(), 2); Assert.assertTrue(beatSelection.getFileName().equalsIgnoreCase(beatLoopAltOptionTwo.getFileName())); }