### Question:
CorePeripheral implements Peripheral { @Override public Single<byte[]> read(UUID svc, UUID chr) { final SingleSubject<Pair<UUID, byte[]>> scopedSubject = SingleSubject.create(); return scopedSubject .filter(chrPair -> chrPair.first.equals(chr)) .flatMapSingle(chrPair -> Single.just(chrPair.second)) .doOnSubscribe(disposable -> processRead(scopedSubject, svc, chr)) .doFinally(() -> clearReadSubject(scopedSubject)); } CorePeripheral(BluetoothDevice device, Context context); @Override Observable<ConnectableState> connect(); @Override Observable<Boolean> connected(); @Override Single<byte[]> read(UUID svc, UUID chr); @Override Completable write(UUID svc, UUID chr, byte[] data); @Override Completable registerNotification(UUID svc, UUID chr); @Override Completable registerNotification(UUID svc, UUID chr, @Nullable Preprocessor preprocessor); @Override Completable unregisterNotification(UUID svc, UUID chr); @Override Observable<byte[]> notification(UUID chr); @TargetApi(21) @Override Single<Integer> requestMtu(int mtu); @Override Single<Integer> readRssi(); @Override int getMaxWriteLength(); @Override void disconnect();  }### Answer:
@Test public void read_disconnected() { readTestObserver = corePeripheral.read(svcUuid, chrUuid).test(); readTestObserver.assertError( throwable -> { PeripheralError error = (PeripheralError) throwable; return error != null && error.getCode() == DISCONNECTED; }); }