@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)); }
@Test public void check_should_set_alarm_off_when_pressure_is_in_range() { when(sensorMock.popNextPressurePsiValue()).thenReturn(17.00); alarm.check(); assertThat(alarm.isAlarmOn(), is(false)); when(sensorMock.popNextPressurePsiValue()).thenReturn(21.00); alarm.check(); assertThat(alarm.isAlarmOn(), is(false)); }
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); }
@Test public void check_should_set_alarm_on_when_pressure_falls_down_range() { when(sensorMock.popNextPressurePsiValue()).thenReturn(16.00); alarm.check(); assertThat(alarm.isAlarmOn(), is(true)); }
@Test public void shouldSkipMeasurementsFromDisabledStreams() { sessionManager.state.recording().startRecording(); when(sensor.isEnabled()).thenReturn(false); triggerMeasurement(); assertThat(sessionManager.getMeasurementStreams().isEmpty(), equalTo(true)); }
@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)); }