ReplaySubject extends Subject<T> { @CheckReturnValue @NonNull public static <T> ReplaySubject<T> createWithTimeAndSize(long maxAge, TimeUnit unit, Scheduler scheduler, int maxSize) { return new ReplaySubject<T>(new SizeAndTimeBoundReplayBuffer<T>(maxSize, maxAge, unit, scheduler)); } @SuppressWarnings("unchecked")  ReplaySubject(ReplayBuffer<T> buffer); @CheckReturnValue @NonNull static ReplaySubject<T> create(); @CheckReturnValue @NonNull static ReplaySubject<T> create(int capacityHint); @CheckReturnValue @NonNull static ReplaySubject<T> createWithSize(int maxSize); @CheckReturnValue @NonNull static ReplaySubject<T> createWithTime(long maxAge, TimeUnit unit, Scheduler scheduler); @CheckReturnValue @NonNull static ReplaySubject<T> createWithTimeAndSize(long maxAge, TimeUnit unit, Scheduler scheduler, int maxSize); @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(); @Experimental void cleanupBuffer(); Object[] getValues(); T[] getValues(T[] array); @Override boolean hasComplete(); @Override boolean hasThrowable(); boolean hasValue();  }
@Test public void createWithTimeAndSizeInvalidCapacity() { try { ReplaySubject.createWithTimeAndSize(1, TimeUnit.DAYS, Schedulers.computation(), -99); fail("Didn't throw IllegalArgumentException"); } catch (IllegalArgumentException ex) { assertEquals("maxSize > 0 required but it was -99", ex.getMessage()); } }