@Test public void producesValidSensorLog() { Faker faker = new Faker(); int humidity = faker.number().numberBetween(0, 100); SensorConfig config = new SensorConfig("someId", "", null); ReplayProcessor<SensorLog> processor = ReplayProcessor.create(10); HumidityNotification notification = new HumidityNotification(config, processor); notification.run(new byte[] { (byte)(humidity & 0xff) }); SensorLog createdLog = processor.blockingFirst(); assertThat(createdLog).isNotNull(); assertThat(createdLog.getSensorId()).matches(config.getId()); assertThat(createdLog.getAttributeValue()).containsExactly(HumidityNotification.HUMIDITY_VALUE_ID, humidity); }
@Override public void run(byte[] bytes) { int relativeHumidity = decodeHumidity(bytes[0]); SensorLog sensorLog = new SensorLog(config.getId(), ImmutableMap.of("relative_humidity", relativeHumidity)); processor.onNext(sensorLog); }
HumidityNotification implements BluetoothNotification<byte[]> { @Override public void run(byte[] bytes) { int relativeHumidity = decodeHumidity(bytes[0]); SensorLog sensorLog = new SensorLog(config.getId(), ImmutableMap.of("relative_humidity", relativeHumidity)); processor.onNext(sensorLog); } }
HumidityNotification implements BluetoothNotification<byte[]> { @Override public void run(byte[] bytes) { int relativeHumidity = decodeHumidity(bytes[0]); SensorLog sensorLog = new SensorLog(config.getId(), ImmutableMap.of("relative_humidity", relativeHumidity)); processor.onNext(sensorLog); } HumidityNotification(SensorConfig config, FlowableProcessor<SensorLog> processor); }
HumidityNotification implements BluetoothNotification<byte[]> { @Override public void run(byte[] bytes) { int relativeHumidity = decodeHumidity(bytes[0]); SensorLog sensorLog = new SensorLog(config.getId(), ImmutableMap.of("relative_humidity", relativeHumidity)); processor.onNext(sensorLog); } HumidityNotification(SensorConfig config, FlowableProcessor<SensorLog> processor); @Override void run(byte[] bytes); }
HumidityNotification implements BluetoothNotification<byte[]> { @Override public void run(byte[] bytes) { int relativeHumidity = decodeHumidity(bytes[0]); SensorLog sensorLog = new SensorLog(config.getId(), ImmutableMap.of("relative_humidity", relativeHumidity)); processor.onNext(sensorLog); } HumidityNotification(SensorConfig config, FlowableProcessor<SensorLog> processor); @Override void run(byte[] bytes); static final String HUMIDITY_VALUE_ID; }