@Test public void shouldProvidePeakForEachStream() { MeasurementStream stream = mock(MeasurementStream.class); when(stream.getPeak()).thenReturn(11.0); String name = sensor.getSensorName(); when(stream.getSensorName()).thenReturn(name); sessionManager.session.add(stream); assertThat(sessionManager.getPeak(sensor), equalTo(11.0)); }
@Test public void shouldStoreLastMeasurementForEachSensor() { triggerMeasurement("LHC", 150); triggerMeasurement("LHC2", 123); Sensor sensor2 = mock(Sensor.class); when(sensor2.getSensorName()).thenReturn("LHC2"); assertThat(sessionManager.getNow(sensor), equalTo(150.0)); assertThat(sessionManager.getNow(sensor2), equalTo(123.0)); }
private void mockSensors() { sessionManager.locationHelper = mock(LocationHelper.class); sessionManager.audioReader = mock(SimpleAudioReader.class); sessionManager.externalSensors = mock(ExternalSensors.class); sessionManager.eventBus = mock(EventBus.class); sessionManager.sensorManager = mock(SensorManager.class); sensor = mock(Sensor.class); when(sensor.isEnabled()).thenReturn(true); when(sensor.getSensorName()).thenReturn("LHC"); when(sessionManager.locationHelper.getLastLocation()).thenReturn(location); when(sessionManager.sensorManager.getSensorByName(Mockito.any(String.class))) .thenReturn(sensor); }