### Question:
PressureNotification implements BluetoothNotification<byte[]> { @Override public void run(byte[] bytes) { float pressure = decodePressure(new byte[]{0x00, bytes[5], bytes[4], bytes[3]}); SensorLog sensorLog = new SensorLog(config.getId(), ImmutableMap.of("pressure", pressure)); processor.onNext(sensorLog); } PressureNotification(SensorConfig config, FlowableProcessor<SensorLog> processor); @Override void run(byte[] bytes); static final String PRESSURE_VALUE_ID; }### Answer:
@Test public void producesValidSensorLog() { Faker faker = new Faker(); double pressure = faker.number().randomDouble(2, 0, 5000); int pressureNorm = (int)(pressure * 100); SensorConfig config = new SensorConfig("someId", "sensortag",null); ReplayProcessor<SensorLog> processor = ReplayProcessor.create(10); PressureNotification notification = new PressureNotification(config, processor); notification.run(new byte[] { 0, 0, 0, (byte)(pressureNorm & 0xff), (byte)(pressureNorm >> 8 & 0xff), (byte)(pressureNorm >> 16 & 0xff) }); SensorLog createdLog = processor.blockingFirst(); assertThat(createdLog).isNotNull(); assertThat(createdLog.getSensorId()).matches(config.getId()); assertThat(createdLog.getAttributeValue()).containsKey(PressureNotification.PRESSURE_VALUE_ID); assertThat((float)createdLog.getAttributeValue().get(PressureNotification.PRESSURE_VALUE_ID)).isWithin(0.1f).of((float)pressure); }