### Question:
SetAmbienceLoopsAnalyticsEvent implements IEventChain { @Override public QueueState set(QueueState queueState ) { for (ProgressionUnit progressionUnit : queueState.getStructure()) { for (int i = 0; i < progressionUnit.getProgressionUnitBars().size(); i++) { if (i < progressionUnit.getProgressionUnitBars().size()) { if (progressionUnit.getProgressionUnitBars().get(i).getAmbienceLoop() != null) { progressionUnit.getProgressionUnitBars().get(i).getCompositionTimeSlot().setAmbientLoopId(progressionUnit.getProgressionUnitBars().get(i).getAmbienceLoop().getId()); } else if (progressionUnit.getProgressionUnitBars().get(i - 1).getAmbienceLoop() != null) { progressionUnit.getProgressionUnitBars().get(i).getCompositionTimeSlot().setAmbientLoopId(progressionUnit.getProgressionUnitBars().get(i - 1).getAmbienceLoop().getId()); } else if (progressionUnit.getProgressionUnitBars().get(i - 2).getAmbienceLoop() != null) { progressionUnit.getProgressionUnitBars().get(i).getCompositionTimeSlot().setAmbientLoopId(progressionUnit.getProgressionUnitBars().get(i - 2).getAmbienceLoop().getId()); } else if (progressionUnit.getProgressionUnitBars().get(i - 3).getAmbienceLoop() != null) { progressionUnit.getProgressionUnitBars().get(i).getCompositionTimeSlot().setAmbientLoopId(progressionUnit.getProgressionUnitBars().get(i - 3).getAmbienceLoop().getId()); } } } } return queueState; }  @Override QueueState set(QueueState queueState );  }### Answer:
@Test public void shouldSetCorrectAnalytics() throws IOException, InterruptedException { assertThat(queueState.getStructure().get(0).getProgressionUnitBars().get(0).getCompositionTimeSlot().getFxArpeggioDelayId()).isNull(); assertThat(queueState.getStructure().get(1).getProgressionUnitBars().get(1).getCompositionTimeSlot().getFxArpeggioDelayId()).isNull(); assertThat(queueState.getStructure().get(2).getProgressionUnitBars().get(3).getCompositionTimeSlot().getFxArpeggioDelayId()).isNull(); assertThat(queueState.getStructure().get(3).getProgressionUnitBars().get(0).getCompositionTimeSlot().getFxArpeggioDelayId()).isNull(); queueState = setArpeggioFXAnalyticsEvent.set(queueState); assertThat(queueState.getStructure().get(0).getProgressionUnitBars().get(0).getCompositionTimeSlot().getFxArpeggioDelayId()).isEqualTo(888); assertThat(queueState.getStructure().get(1).getProgressionUnitBars().get(1).getCompositionTimeSlot().getFxArpeggioDelayId()).isEqualTo(888); assertThat(queueState.getStructure().get(2).getProgressionUnitBars().get(3).getCompositionTimeSlot().getFxArpeggioDelayId()).isEqualTo(999); assertThat(queueState.getStructure().get(3).getProgressionUnitBars().get(0).getCompositionTimeSlot().getFxArpeggioDelayId()).isEqualTo(999); }