@Test
  public void shouldAppendWithoutRecalculating() {
    state.recording().startRecording();
    presenter.setZoom(4000);
    presenter.getTimelineView();
    presenter.sessionManager = mockSessionManager();

    triggerMeasurement(measurement1);
    List<Measurement> result = presenter.getTimelineView();

    assertThat(result).contains(measurement1, measurements.get(3)).excludes(measurements.get(2));
  }
  @Test
  public void shouldAverageTimelineOnTheFly() {
    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.onEvent(EVENT);
    presenter.getTimelineView();
    triggerMeasurement(measurement1);
    triggerMeasurement(measurement2);

    assertThat(presenter.getTimelineView()).contains(expected, measurement2);
  }
  @Test
  public void timelineViewShouldBeEmptyWithoutASession() {
    when(presenter.sessionManager.isSessionSaved()).thenReturn(false);
    when(presenter.sessionManager.isSessionStarted()).thenReturn(false);

    assertThat(presenter.getTimelineView()).isEmpty();
  }
  @Test
  public void shouldNotCluster() {
    state.recording().startRecording();
    presenter.setZoom(4000);

    assertThat(presenter.getTimelineView()).contains(measurements.get(3), measurements.get(2));
  }
 @Test
 public void shouldAllowToZoomOutAfterMoreDataArrives() {
   state.recording().startRecording();
   presenter.setZoom(8000);
   presenter.getTimelineView();
   triggerMeasurement(measurement1);
   assertThat(presenter.canZoomOut()).isTrue();
 }
  @Test
  public void shouldShowLastNMillis() {
    state.recording().startRecording();
    presenter.setZoom(100);

    List<Measurement> result = presenter.getTimelineView();

    assertThat(result).contains(measurements.get(3));
    assertThat(result).excludes(measurements.get(2));
  }
  @Test
  public void shouldHandleEmptyList() {
    when(stream.getMeasurements()).thenReturn(new ArrayList<Measurement>());

    assertThat(presenter.getTimelineView()).isEmpty();
  }