EndConsumerHelper { public static boolean validate(Disposable upstream, Disposable next, Class<?> observer) { ObjectHelper.requireNonNull(next, "next is null"); if (upstream != null) { next.dispose(); if (upstream != DisposableHelper.DISPOSED) { reportDoubleSubscription(observer); } return false; } return true; } private  EndConsumerHelper(); static boolean validate(Disposable upstream, Disposable next, Class<?> observer); static boolean setOnce(AtomicReference<Disposable> upstream, Disposable next, Class<?> observer); static boolean validate(Subscription upstream, Subscription next, Class<?> subscriber); static boolean setOnce(AtomicReference<Subscription> upstream, Subscription next, Class<?> subscriber); static String composeMessage(String consumer); static void reportDoubleSubscription(Class<?> consumer);  }
@Test public void validateDisposable() { Disposable d1 = Disposables.empty(); assertFalse(EndConsumerHelper.validate(DisposableHelper.DISPOSED, d1, getClass())); assertTrue(d1.isDisposed()); assertTrue(errors.toString(), errors.isEmpty()); }
@Test public void validateSubscription() { BooleanSubscription d1 = new BooleanSubscription(); assertFalse(EndConsumerHelper.validate(SubscriptionHelper.CANCELLED, d1, getClass())); assertTrue(d1.isCancelled()); assertTrue(errors.toString(), errors.isEmpty()); }