Bean implements Parcelable { public void connect(Context context, BeanListener listener) { lastKnownContext = context; beanListener = listener; gattClient.connect(context, device); } Bean(BluetoothDevice device);  Bean(BluetoothDevice device, GattClient client, final Handler handler); String describe(); boolean isConnected(); Context getLastKnownContext(); BeanListener getBeanListener(); void connect(Context context, BeanListener listener); void disconnect(); BluetoothDevice getDevice(); void readRemoteRssi(); void readRadioConfig(Callback<RadioConfig> callback); void setLed(LedColor color); void readLed(Callback<LedColor> callback); void setAdvertising(boolean enable); void readTemperature(Callback<Integer> callback); void readAcceleration(Callback<Acceleration> callback); void readSketchMetadata(Callback<SketchMetadata> callback); void readScratchData(ScratchBank bank, Callback<ScratchData> callback); void setAccelerometerRange(AccelerometerRange range); void readAccelerometerRange(Callback<AccelerometerRange> callback); void setScratchData(ScratchBank bank, byte[] data); void setScratchData(ScratchBank bank, String data); void setRadioConfig(RadioConfig config); void setRadioConfig(RadioConfig config, boolean save); void sendSerialMessage(byte[] value); void setPin(int pin, boolean active); void sendSerialMessage(String value); void readDeviceInfo(final Callback<DeviceInfo> callback); void readFirmwareVersion(final Callback<String> callback); void readHardwareVersion(final Callback<String> callback); void setArduinoEnabled(boolean enable); void readArduinoPowerState(final Callback<Boolean> callback); void readBatteryLevel(final Callback<BatteryLevel> callback); void endSerialGate(); void programWithSketch(SketchHex hex, Callback<UploadProgress> onProgress, Runnable onComplete); OADProfile.OADApproval programWithFirmware(FirmwareBundle bundle, OADProfile.OADListener listener); boolean firmwareUpdateInProgress(); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); static final Creator<Bean> CREATOR; }
@Test public void testBeanConnection() { BeanListener mockListener = mock(BeanListener.class); bean.connect(mockContext, mockListener); testListener.onConnected(); for (Runnable r : handlerRunnables) { r.run(); } verify(mockListener).onConnected(); }