### Question:
MeasurementIntervalDataCallback extends ProfileReadResponse implements MeasurementIntervalCallback { @Override public void onDataReceived(@NonNull final BluetoothDevice device, @NonNull final Data data) { super.onDataReceived(device, data); if (data.size() != 2) { onInvalidDataReceived(device, data); return; } final int interval = data.getIntValue(Data.FORMAT_UINT16, 0); onMeasurementIntervalReceived(device, interval); } MeasurementIntervalDataCallback(); protected  MeasurementIntervalDataCallback(final Parcel in); @Override void onDataReceived(@NonNull final BluetoothDevice device, @NonNull final Data data);  }### Answer:
@Test public void onMeasurementIntervalReceived() { final ProfileReadResponse response = new MeasurementIntervalDataCallback() { @Override public void onMeasurementIntervalReceived(@NonNull final BluetoothDevice device, final int interval) { called = true; assertEquals("Interval", 60, interval); } }; called = false; final Data data = new Data(new byte[] { 60, 0 }); response.onDataReceived(null, data); assertTrue(response.isValid()); assertTrue(called); }
@Test public void onInvalidDataReceived() { final ProfileReadResponse response = new MeasurementIntervalDataCallback() { @Override public void onMeasurementIntervalReceived(@NonNull final BluetoothDevice device, final int interval) { called = true; } }; called = false; final Data data = new Data(new byte[] { 60 }); response.onDataReceived(null, data); assertFalse(called); assertFalse(response.isValid()); }