### Question:
TemperatureNotification implements BluetoothNotification<byte[]> { @Override public void run(byte[] bytes) { float ambientTemp = decodeTemperature(bytes[0], bytes[1]); SensorLog sensorLog = new SensorLog(config.getId(), ImmutableMap.of(TEMP_VALUE_ID, ambientTemp)); processor.onNext(sensorLog); } TemperatureNotification(SensorConfig config, FlowableProcessor<SensorLog> processor); @Override void run(byte[] bytes); static final String TEMP_VALUE_ID; }### Answer:
@Test public void producesValidSensorLog() { Faker faker = new Faker(); int temp = faker.number().numberBetween(-50, 50); float decimal = (float)faker.number().randomDouble(5, 0, 1); SensorConfig config = new SensorConfig("someId", "nordic", null); ReplayProcessor<SensorLog> processor = ReplayProcessor.create(10); TemperatureNotification notification = new TemperatureNotification(config, processor); notification.run(new byte[] { (byte)temp, (byte)(decimal * 256) }); SensorLog createdLog = processor.blockingFirst(); assertThat(createdLog).isNotNull(); assertThat(createdLog.getSensorId()).matches(config.getId()); assertThat(createdLog.getAttributeValue()).containsKey(TemperatureNotification.TEMP_VALUE_ID); assertThat((float)createdLog.getAttributeValue().get(TemperatureNotification.TEMP_VALUE_ID)).isWithin(0.01f).of(temp + decimal); }