BehaviorSubject extends Subject<T> { @Override public void onSubscribe(Disposable s) { if (terminalEvent.get() != null) { s.dispose(); } } @SuppressWarnings("unchecked")  BehaviorSubject();   BehaviorSubject(T defaultValue); @CheckReturnValue @NonNull static BehaviorSubject<T> create(); @CheckReturnValue @NonNull static BehaviorSubject<T> createDefault(T defaultValue); @Override void onSubscribe(Disposable s); @Override void onNext(T t); @Override void onError(Throwable t); @Override void onComplete(); @Override boolean hasObservers(); @Override @Nullable Throwable getThrowable(); @Nullable T getValue(); Object[] getValues(); @SuppressWarnings("unchecked") T[] getValues(T[] array); @Override boolean hasComplete(); @Override boolean hasThrowable(); boolean hasValue();  }
@Test public void onSubscribe() { BehaviorSubject<Object> p = BehaviorSubject.create(); Disposable bs = Disposables.empty(); p.onSubscribe(bs); assertFalse(bs.isDisposed()); p.onComplete(); bs = Disposables.empty(); p.onSubscribe(bs); assertTrue(bs.isDisposed()); }