CompletableSubject extends Completable implements CompletableObserver { @CheckReturnValue @NonNull public static CompletableSubject create() { return new CompletableSubject(); } CompletableSubject(); @CheckReturnValue @NonNull static CompletableSubject create(); @Override void onSubscribe(Disposable d); @Override void onError(Throwable e); @Override void onComplete(); @Nullable Throwable getThrowable(); boolean hasThrowable(); boolean hasComplete(); boolean hasObservers();  }
@Test public void cancelOnArrival() { CompletableSubject.create() .test(true) .assertEmpty(); }
@Test public void cancelOnArrival2() { CompletableSubject cs = CompletableSubject.create(); cs.test(); cs .test(true) .assertEmpty(); }
@Test public void dispose() { TestHelper.checkDisposed(CompletableSubject.create()); }
@Test public void disposeTwice() { CompletableSubject.create() .subscribe(new CompletableObserver() { @Override public void onSubscribe(Disposable d) { assertFalse(d.isDisposed()); d.dispose(); d.dispose(); assertTrue(d.isDisposed()); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } }); }
@Test public void addRemoveRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { final CompletableSubject cs = CompletableSubject.create(); final TestObserver<Void> to = cs.test(); Runnable r1 = new Runnable() { @Override public void run() { cs.test(); } }; Runnable r2 = new Runnable() { @Override public void run() { to.cancel(); } }; TestHelper.race(r1, r2); } }