### Question:
AirQualityNotification implements BluetoothNotification<byte[]> { @Override public void run(byte[] bytes) { int eCO2 = decodeECO2(bytes[1], bytes[0]); int tvoc = decodeTVOC(bytes[3], bytes[2]); SensorLog sensorLog = new SensorLog(config.getId(), ImmutableMap.of(CO2_VALUE_ID, eCO2, TVOC_VALUE_ID, tvoc)); processor.onNext(sensorLog); } AirQualityNotification(SensorConfig config, FlowableProcessor<SensorLog> processor); @Override void run(byte[] bytes); static final String CO2_VALUE_ID; static final String TVOC_VALUE_ID; }### Answer:
@Test public void producesValidSensorLog() { int eCO2 = 400; byte[] eCO2bytes = Ints.toByteArray(eCO2); int TVOC = 121; byte[] TVOCbytes = Ints.toByteArray(TVOC); SensorConfig config = new SensorConfig("someId", "sensortag", null); ReplayProcessor<SensorLog> processor = ReplayProcessor.create(10); AirQualityNotification notification = new AirQualityNotification(config, processor); notification.run(new byte[] { eCO2bytes[3], eCO2bytes[2], TVOCbytes[3], TVOCbytes[2] }); SensorLog createdLog = processor.blockingFirst(); assertThat(createdLog).isNotNull(); assertThat(createdLog.getSensorId()).matches(config.getId()); assertThat(createdLog.getAttributeValue()).containsExactly(AirQualityNotification.CO2_VALUE_ID, eCO2, AirQualityNotification.TVOC_VALUE_ID, TVOC); }