@Test public void ShouldSetBeatLoopAltOptions() { SourceData sourceData = queueHelpers.getSourceData(); BeatLoop beatLoopA = new BeatLoop(); beatLoopA.setBarCount(2); BeatLoop beatLoopB = new BeatLoop(); beatLoopB.setBarCount(1); ProgressionUnitBar pUnitBarA = new ProgressionUnitBar(); pUnitBarA.setBeatLoop(beatLoopA); ProgressionUnitBar pUnitBarB = new ProgressionUnitBar(); pUnitBarB.setBeatLoop(beatLoopA); ProgressionUnitBar pUnitBarC = new ProgressionUnitBar(); pUnitBarC.setBeatLoop(beatLoopB); ProgressionUnitBar pUnitBarD = new ProgressionUnitBar(); pUnitBarD.setBeatLoop(beatLoopB); List<ProgressionUnitBar> pBars = Arrays.asList(pUnitBarA, pUnitBarB, pUnitBarC,pUnitBarD); ProgressionUnit progressionUnit = new ProgressionUnit(); progressionUnit.setProgressionUnitBars(pBars); progressionUnit.getProgressionUnitBars().forEach(pUnitBar -> { beatLoopAltOptions.setBeatLoopOptions(pUnitBar, sourceData.getBeatLoops(1)); }); progressionUnit.getProgressionUnitBars().forEach(pUnitBar -> { assertThat(pUnitBar.getBeatLoopAltOptions()).isNotNull(); assertThat(progressionUnit.getProgressionUnitBars().size()).isGreaterThan(0); }); List<ProgressionUnitBar> bars = progressionUnit.getProgressionUnitBars(); bars.get(0).getBeatLoopAltOptions().forEach(option -> assertThat(option.getBarCount()).isEqualTo(2)); bars.get(1).getBeatLoopAltOptions().forEach(option -> assertThat(option.getBarCount()).isEqualTo(2)); bars.get(2).getBeatLoopAltOptions().forEach(option -> assertThat(option.getBarCount()).isEqualTo(1)); bars.get(3).getBeatLoopAltOptions().forEach(option -> assertThat(option.getBarCount()).isEqualTo(1)); }
@Override public void setBeatLoopOptions(ProgressionUnitBar pUnitBar, List<BeatLoop> beatLoops) { List<BeatLoop> filteredOptions = beatLoops.stream().filter(beatLoop -> beatLoop.getBarCount() == pUnitBar.getBeatLoop().getBarCount()).collect(Collectors.toList()); List<BeatLoop> filteredAndClonedOptions = CloneUtils.cloneBeatLoops(filteredOptions); pUnitBar.setBeatLoopAltOptions(filteredAndClonedOptions); }
BeatLoopAltOptions implements IBeatLoopOptions { @Override public void setBeatLoopOptions(ProgressionUnitBar pUnitBar, List<BeatLoop> beatLoops) { List<BeatLoop> filteredOptions = beatLoops.stream().filter(beatLoop -> beatLoop.getBarCount() == pUnitBar.getBeatLoop().getBarCount()).collect(Collectors.toList()); List<BeatLoop> filteredAndClonedOptions = CloneUtils.cloneBeatLoops(filteredOptions); pUnitBar.setBeatLoopAltOptions(filteredAndClonedOptions); } }
BeatLoopAltOptions implements IBeatLoopOptions { @Override public void setBeatLoopOptions(ProgressionUnitBar pUnitBar, List<BeatLoop> beatLoops) { List<BeatLoop> filteredOptions = beatLoops.stream().filter(beatLoop -> beatLoop.getBarCount() == pUnitBar.getBeatLoop().getBarCount()).collect(Collectors.toList()); List<BeatLoop> filteredAndClonedOptions = CloneUtils.cloneBeatLoops(filteredOptions); pUnitBar.setBeatLoopAltOptions(filteredAndClonedOptions); }  }
BeatLoopAltOptions implements IBeatLoopOptions { @Override public void setBeatLoopOptions(ProgressionUnitBar pUnitBar, List<BeatLoop> beatLoops) { List<BeatLoop> filteredOptions = beatLoops.stream().filter(beatLoop -> beatLoop.getBarCount() == pUnitBar.getBeatLoop().getBarCount()).collect(Collectors.toList()); List<BeatLoop> filteredAndClonedOptions = CloneUtils.cloneBeatLoops(filteredOptions); pUnitBar.setBeatLoopAltOptions(filteredAndClonedOptions); }  @Override void setBeatLoopOptions(ProgressionUnitBar pUnitBar, List<BeatLoop> beatLoops); }
BeatLoopAltOptions implements IBeatLoopOptions { @Override public void setBeatLoopOptions(ProgressionUnitBar pUnitBar, List<BeatLoop> beatLoops) { List<BeatLoop> filteredOptions = beatLoops.stream().filter(beatLoop -> beatLoop.getBarCount() == pUnitBar.getBeatLoop().getBarCount()).collect(Collectors.toList()); List<BeatLoop> filteredAndClonedOptions = CloneUtils.cloneBeatLoops(filteredOptions); pUnitBar.setBeatLoopAltOptions(filteredAndClonedOptions); }  @Override void setBeatLoopOptions(ProgressionUnitBar pUnitBar, List<BeatLoop> beatLoops);  }