### Question:
HatPatternSelector { public QueueState setSelectedPatterns(Map<ProgressionUnit.ProgressionType, HatPattern> typeToSelectedPatten, QueueState queueState) { for (ProgressionUnit pUnit : queueState.getStructure()) { HatPattern hatPattern = typeToSelectedPatten.get(pUnit.getType()); for (int i = 0; i < pUnit.getProgressionUnitBars().size(); i++) { pUnit.getProgressionUnitBars().get(i).setHatPattern(hatPattern); } } return queueState; }  QueueState setSelectedPatterns(Map<ProgressionUnit.ProgressionType, HatPattern> typeToSelectedPatten, QueueState queueState);  }### Answer:
@Test public void shouldSetSelectedPattern() { queueState = hatPatternSelector.setSelectedPatterns(typeToSelectedPatten, queueState); List<ProgressionUnit> structure = queueState.getStructure(); assertThat(structure.get(0).getProgressionUnitBars().get(0).getHatPattern().getId()).isEqualTo(3); assertThat(structure.get(0).getProgressionUnitBars().get(1).getHatPattern().getId()).isEqualTo(3); assertThat(structure.get(0).getProgressionUnitBars().get(2).getHatPattern().getId()).isEqualTo(3); assertThat(structure.get(0).getProgressionUnitBars().get(3).getHatPattern().getId()).isEqualTo(3); assertThat(structure.get(1).getProgressionUnitBars().get(0).getHatPattern().getId()).isEqualTo(2); assertThat(structure.get(1).getProgressionUnitBars().get(1).getHatPattern().getId()).isEqualTo(2); assertThat(structure.get(1).getProgressionUnitBars().get(2).getHatPattern().getId()).isEqualTo(2); assertThat(structure.get(1).getProgressionUnitBars().get(3).getHatPattern().getId()).isEqualTo(2); assertThat(structure.get(2).getProgressionUnitBars().get(0).getHatPattern().getId()).isEqualTo(1); assertThat(structure.get(2).getProgressionUnitBars().get(1).getHatPattern().getId()).isEqualTo(1); assertThat(structure.get(2).getProgressionUnitBars().get(2).getHatPattern().getId()).isEqualTo(1); assertThat(structure.get(2).getProgressionUnitBars().get(3).getHatPattern().getId()).isEqualTo(1); }