@Before
  public void setup() {
    measurements = new ArrayList<Measurement>();
    for (int i = 0; i < 4; i++) {
      measurements.add(new Measurement(i, i, i, new Date(0, 0, 0, 0, 1, 2 * i)));
    }

    sensor = mock(Sensor.class);
    when(sensor.getSensorName()).thenReturn("LHC");

    presenter.sensorManager = mock(SensorManager.class);
    when(presenter.sensorManager.getVisibleSensor()).thenReturn(sensor);
    presenter.onEvent(new ViewStreamEvent(sensor));

    stream = mock(MeasurementStream.class);
    when(stream.getMeasurements()).thenReturn(measurements);

    presenter.sessionManager = mockSessionManager();
    when(presenter.sessionManager.getMeasurementStream("LHC")).thenReturn(stream);
    when(presenter.sessionManager.isSessionStarted()).thenReturn(true);

    listener = mock(MeasurementPresenter.Listener.class);
    presenter.registerListener(listener);

    presenter.settingsHelper = mock(SettingsHelper.class);
    when(presenter.settingsHelper.getAveragingTime()).thenReturn(1);
    EVENT = new SessionChangeEvent(new Session());
  }
  @Test
  public void shouldNotifyListenersAboutNewAveragedMeasurements() {
    state.recording().startRecording();
    when(presenter.settingsHelper.getAveragingTime()).thenReturn(4);
    Measurement expected = new Measurement(3.5, 3.5, 3.5, new Date(0, 0, 0, 0, 1, 5));
    presenter.registerListener(listener);

    triggerMeasurement(measurement1);
    triggerMeasurement(measurement2);
    triggerMeasurement(new Measurement(0, 0, 0, new Date(0, 0, 0, 0, 1, 10)));

    verify(listener, atLeastOnce()).onAveragedMeasurement(expected);
  }