@Test
  public void shouldStartASession() {
    sessionManager.startMobileSession(false);

    verify(sessionManager.locationHelper, times(2)).start();
    verify(sessionManager.audioReader).start();
    assertThat(sessionManager.isSessionStarted(), equalTo(true));
  }
  @Test
  public void shouldNotStopSensorsDuringASession() {
    sessionManager.startMobileSession(false);
    sessionManager.stopSensors();

    verify(sessionManager.locationHelper, never()).stop();
    verify(sessionManager.audioReader, never()).stop();
    assertThat(sessionManager.isSessionStarted(), equalTo(true));
  }
  @Test
  public void shouldStopSensors() {
    sessionManager.startSensors();
    sessionManager.stopSensors();

    verify(sessionManager.audioReader).stop();
    verify(sessionManager.locationHelper).stop();
    assertThat(sessionManager.isSessionStarted(), equalTo(false));
  }
  @Ignore("Fix session persistence")
  @Test
  public void shouldStopASession() {
    triggerMeasurement(11);
    sessionManager.finishSession(0);

    verify(sessionManager.audioReader, never()).stop();
    verify(sessionManager.locationHelper).stop();
    verify(sessionManager.sessionRepository).save(Mockito.any(Session.class));
    assertThat(sessionManager.isSessionStarted(), equalTo(false));
  }
  @Test
  public void shouldDiscardASession() {
    sessionManager.startMobileSession(false);
    sessionManager.getSession().setId(1234);

    triggerMeasurement(13.5);
    sessionManager.discardSession();

    verify(sessionManager.audioReader, never()).stop();
    verify(sessionManager.locationHelper).stop();
    verify(sessionManager.sessionRepository, never()).save(Mockito.any(Session.class));
    assertThat(sessionManager.getMeasurementStreams().isEmpty(), equalTo(true));
    assertThat(sessionManager.isSessionStarted(), equalTo(false));
  }
 private SessionManager mockSessionManager() {
   SessionManager result = mock(SessionManager.class);
   when(result.isSessionStarted()).thenReturn(true);
   return result;
 }