### Question:
SensorLocationDataCallback extends ProfileReadResponse implements SensorLocationCallback { @Override public void onDataReceived(@NonNull final BluetoothDevice device, @NonNull final Data data) { super.onDataReceived(device, data); if (data.size() != 1) { onInvalidDataReceived(device, data); return; } final int location = data.getIntValue(Data.FORMAT_UINT8, 0); onSensorLocationReceived(device, location); } SensorLocationDataCallback(); protected  SensorLocationDataCallback(final Parcel in); @Override void onDataReceived(@NonNull final BluetoothDevice device, @NonNull final Data data);  }### Answer:
@Test public void onSensorLocationReceived() { final ProfileReadResponse callback = new SensorLocationDataCallback() { @Override public void onSensorLocationReceived(@NonNull final BluetoothDevice device, final int location) { called = true; assertEquals("Location", SensorLocationCallback.SENSOR_LOCATION_REAR_WHEEL, location); } }; called = false; final Data data = new Data(new byte[] { 12 }); callback.onDataReceived(null, data); assertTrue(called); assertTrue(callback.isValid()); }
@Test public void onInvalidDataReceived() { final ProfileReadResponse callback = new SensorLocationDataCallback() { @Override public void onSensorLocationReceived(@NonNull final BluetoothDevice device, final int location) { called = true; } }; called = false; final Data data = new Data(new byte[] { 0x01, 0x02 }); callback.onDataReceived(null, data); assertFalse(called); assertFalse(callback.isValid()); }