CacheSubject extends Subject<T, T> { @Nonnull public static <T> CacheSubject<T> create(@Nonnull CacheCreator<T> cacheCreator) { return create(cacheCreator, true); } private  CacheSubject(@Nonnull final CacheCreator<T> cacheCreator,
                         @Nonnull DelegateOnSubscribe<T> delegateOnSubscribe,
                         final boolean skipFirstNull,
                         final boolean skipNextNull); @Nonnull static CacheSubject<T> create(@Nonnull CacheCreator<T> cacheCreator); @Nonnull static CacheSubject<T> create(@Nonnull CacheCreator<T> cacheCreator, final boolean skipFirstNull); @Nonnull static CacheSubject<T> create(@Nonnull CacheCreator<T> cacheCreator, final boolean skipFirstNull, final boolean skipNextNull); @Nonnull static ConnectableObservable<T> behavior(final @Nonnull Observable<T> observable,
                                                        final @Nonnull CacheSubject.CacheCreator<T> cacheCreator); @Nonnull static Observable.Transformer<T, T> behaviorRefCount(
            final @Nonnull CacheSubject.CacheCreator<T> cacheCreator); @Override boolean hasObservers(); @Override void onCompleted(); @Override void onError(Throwable e); @Override void onNext(T t);  }
@Test public void testSubscribeToEmptyCacheAndSkipEmpty_doNotCallOnNext() throws Exception { final TestSubscriber<String> subscriber = new TestSubscriber<>(); final CacheSubject<String> subject = CacheSubject.create(new CacheSubject.InMemoryCache<String>(null), true); subject.subscribe(subscriber); assert_().that(subscriber.getOnNextEvents()).isEmpty(); }
@Test public void testSubscribeToEmptyCacheAndDoNotSkipEmpty_callOnNext() throws Exception { final TestSubscriber<String> subscriber = new TestSubscriber<>(); final CacheSubject<String> subject = CacheSubject.create(new CacheSubject.InMemoryCache<String>(null), false); subject.subscribe(subscriber); assert_().that(subscriber.getOnNextEvents()).containsExactly((String) null); }