### Question:
OptionsFilter { public List<HarmonicLoop> filterByProcessingState(List<HarmonicLoop> harmonicLoops, ProcessingState processingState) { if (processingState.getProcessingPattern() == ProcessingPattern.TWO_BAR) { switch (processingState.getCurrentState()) { case C1_L3: return harmonicLoops.stream().filter(harmonicLoop -> !harmonicLoop.getBarCount().equals(4)).collect(Collectors.toList()); case C2_L4: return harmonicLoops.stream().filter(harmonicLoop -> harmonicLoop.getBarCount().equals(1)).collect(Collectors.toList()); case C4_L2: return harmonicLoops.stream().filter(harmonicLoop -> harmonicLoop.getBarCount().equals(1)).collect(Collectors.toList()); default: return harmonicLoops; } } else if (processingState.getProcessingPattern() == ProcessingPattern.FOUR_BAR) { switch (processingState.getCurrentState()) { case C1_L1: return harmonicLoops.stream().filter(harmonicLoop -> harmonicLoop.getBarCount().equals(4)).collect(Collectors.toList()); default: return harmonicLoops; } } throw new RuntimeException("No Processing State set!"); }  List<HarmonicLoop> filterByProcessingState(List<HarmonicLoop> harmonicLoops, ProcessingState processingState);  }### Answer:
@Test public void shouldFilter4BarOptions_whenProcessingStateIsL3(){ SourceData sourceData = createSourceData(); ProcessingState processingState = new ProcessingState(); processingState.setProcessingPattern(ProcessingPattern.TWO_BAR); processingState.setCurrentState(ProcessingState.ProcessingStates.C1_L3); List<HarmonicLoop> harmonicLoops = optionsFilter.filterByProcessingState(sourceData.getHarmonicLoops(0), processingState); assertThat(harmonicLoops).hasSize(2); }
@Test public void shouldFilterAllBut4BarOptions_whenProcessingStateIsC1_L3(){ SourceData sourceData = createSourceData(); ProcessingState processingState = new ProcessingState(); processingState.setProcessingPattern(ProcessingPattern.FOUR_BAR); processingState.setCurrentState(ProcessingState.ProcessingStates.C1_L1); List<HarmonicLoop> harmonicLoops = optionsFilter.filterByProcessingState(sourceData.getHarmonicLoops(0), processingState); assertThat(harmonicLoops).hasSize(1); assertThat(harmonicLoops.get(0).getFileName()).isEqualToIgnoringCase("loopFourBar"); }