From 1dfa37f08e8688a97038beea2549bfd72c2dbd26 Mon Sep 17 00:00:00 2001 From: Ben Christensen Date: Thu, 21 Aug 2014 14:41:09 -0700 Subject: [PATCH 1/2] Deprecation Removal Removing all deprecated methods and types for 1.0 https://github.com/ReactiveX/RxJava/issues/1001 --- rxjava/src/main/java/rx/Observable.java | 922 +----------------- rxjava/src/main/java/rx/Subscriber.java | 7 - .../rx/observables/GroupedObservable.java | 21 - .../rx/plugins/RxJavaDefaultSchedulers.java | 50 - .../RxJavaDefaultSchedulersDefault.java | 49 - .../main/java/rx/plugins/RxJavaPlugins.java | 44 - .../main/java/rx/schedulers/Schedulers.java | 6 +- rxjava/src/test/java/rx/CovarianceTest.java | 8 +- rxjava/src/test/java/rx/ObservableTests.java | 4 +- .../operators/BlockingOperatorLatestTest.java | 4 +- .../operators/OnSubscribeCacheTest.java | 2 +- .../OnSubscribeCombineLatestTest.java | 2 +- ...eMapTest.java => OperatorFlatMapTest.java} | 22 +- .../operators/OperatorOnErrorFlatMapTest.java | 118 --- .../operators/OperatorWindowTest.java | 2 +- .../operators/OperatorZipIterableTest.java | 20 +- .../internal/operators/OperatorZipTest.java | 6 +- .../rx/schedulers/AbstractSchedulerTests.java | 6 +- 18 files changed, 46 insertions(+), 1247 deletions(-) delete mode 100644 rxjava/src/main/java/rx/plugins/RxJavaDefaultSchedulers.java delete mode 100644 rxjava/src/main/java/rx/plugins/RxJavaDefaultSchedulersDefault.java rename rxjava/src/test/java/rx/internal/operators/{OperatorMergeMapTest.java => OperatorFlatMapTest.java} (91%) delete mode 100644 rxjava/src/test/java/rx/internal/operators/OperatorOnErrorFlatMapTest.java diff --git a/rxjava/src/main/java/rx/Observable.java b/rxjava/src/main/java/rx/Observable.java index 962533339f..7edf2b4168 100644 --- a/rxjava/src/main/java/rx/Observable.java +++ b/rxjava/src/main/java/rx/Observable.java @@ -110,34 +110,6 @@ public interface Operator extends Func1, Subscriber< // cover for generics insanity } - /** - * @deprecated use {@link #create(OnSubscribe)} - */ - @Deprecated - public final static Observable create(final OnSubscribeFunc f) { - return new Observable(new OnSubscribe() { - - @Override - public void call(Subscriber observer) { - Subscription s = f.onSubscribe(observer); - if (s != null && s != observer) { - observer.add(s); - } - } - - }); - } - - /** - * @deprecated use {@link OnSubscribe} - */ - @Deprecated - public static interface OnSubscribeFunc extends Function { - - public Subscription onSubscribe(Observer op); - - } - /** * Lifts a function to the current Observable and returns a new Observable that when subscribed to will pass * the values of the current Observable through the Operator function. @@ -1088,32 +1060,6 @@ public final static Observable empty() { return from(new ArrayList()); } - /** - * Returns an Observable that emits no items to the {@link Observer} and immediately invokes its - * {@link Observer#onCompleted onCompleted} method on the specified Scheduler. - *

- * - *

- *
Scheduler:
- *
you specify which {@link Scheduler} this operator will use
- *
- * - * @param scheduler - * the Scheduler to use to call the {@link Observer#onCompleted onCompleted} method - * @param - * the type of the items (ostensibly) emitted by the Observable - * @return an Observable that emits no items to the {@link Observer} but immediately invokes the - * {@link Observer}'s {@link Observer#onCompleted() onCompleted} method with the specified - * {@code scheduler} - * @see RxJava wiki: empty - * @see MSDN: Observable.Empty(IScheduler) - * @deprecated use {@link #subscribeOn} to schedule - */ - @Deprecated - public final static Observable empty(Scheduler scheduler) { - return Observable. empty().subscribeOn(scheduler); - } - /** * Returns an Observable that invokes an {@link Observer}'s {@link Observer#onError onError} method when the * Observer subscribes to it. @@ -1137,33 +1083,6 @@ public final static Observable error(Throwable exception) { return new ThrowObservable(exception); } - /** - * Returns an Observable that invokes an {@link Observer}'s {@link Observer#onError onError} method on the - * specified Scheduler. - *

- * - *

- *
Scheduler:
- *
you specify which {@link Scheduler} this operator will use
- *
- * - * @param exception - * the particular Throwable to pass to {@link Observer#onError onError} - * @param scheduler - * the Scheduler on which to call {@link Observer#onError onError} - * @param - * the type of the items (ostensibly) emitted by the Observable - * @return an Observable that invokes the {@link Observer}'s {@link Observer#onError onError} method, on - * the specified Scheduler - * @see RxJava wiki: error - * @see MSDN: Observable.Throw - * @deprecated use {@link #subscribeOn} to schedule - */ - @Deprecated - public final static Observable error(Throwable exception, Scheduler scheduler) { - return Observable. error(exception).subscribeOn(scheduler); - } - /** * Converts a {@link Future} into an Observable. *

@@ -1273,362 +1192,6 @@ public final static Observable from(Iterable iterable) { return create(new OnSubscribeFromIterable(iterable)); } - /** - * Converts an {@link Iterable} sequence into an Observable that operates on the specified Scheduler, - * emitting each item from the sequence. - *

- * - *

- *
Scheduler:
- *
you specify which {@link Scheduler} this operator will use
- *
- * - * @param iterable - * the source {@link Iterable} sequence - * @param scheduler - * the Scheduler on which the Observable is to emit the items of the Iterable - * @param - * the type of items in the {@link Iterable} sequence and the type of items to be emitted by the - * resulting Observable - * @return an Observable that emits each item in the source {@link Iterable} sequence, on the specified - * Scheduler - * @see RxJava wiki: from - * @see MSDN: Observable.ToObservable - * @deprecated use {@link #subscribeOn} to schedule the work - */ - @Deprecated - public final static Observable from(Iterable iterable, Scheduler scheduler) { - return from(iterable).subscribeOn(scheduler); - } - - /** - * Converts an item into an Observable that emits that item. - *

- * - *

- *
Scheduler:
- *
{@code from} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param t1 - * the item - * @param - * the type of the item - * @return an Observable that emits the item - * @see RxJava wiki: from - * @deprecated use {@link #just} instead - */ - @Deprecated - public final static Observable from(T t1) { - return just(t1); - } - - /** - * Converts two items into an Observable that emits those items. - *

- * - *

- *
Scheduler:
- *
{@code from} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param t1 - * first item - * @param t2 - * second item - * @param - * the type of these items - * @return an Observable that emits each item - * @see RxJava wiki: from - * @deprecated use {@link #just} instead - */ - @Deprecated - // suppress unchecked because we are using varargs inside the method - @SuppressWarnings("unchecked") - public final static Observable from(T t1, T t2) { - return from(Arrays.asList(t1, t2)); - } - - /** - * Converts three items into an Observable that emits those items. - *

- * - *

- *
Scheduler:
- *
{@code from} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param t1 - * first item - * @param t2 - * second item - * @param t3 - * third item - * @param - * the type of these items - * @return an Observable that emits each item - * @see RxJava wiki: from - * @deprecated use {@link #just} instead - */ - @Deprecated - // suppress unchecked because we are using varargs inside the method - @SuppressWarnings("unchecked") - public final static Observable from(T t1, T t2, T t3) { - return from(Arrays.asList(t1, t2, t3)); - } - - /** - * Converts four items into an Observable that emits those items. - *

- * - *

- *
Scheduler:
- *
{@code from} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param t1 - * first item - * @param t2 - * second item - * @param t3 - * third item - * @param t4 - * fourth item - * @param - * the type of these items - * @return an Observable that emits each item - * @see RxJava wiki: from - * @deprecated use {@link #just} instead - */ - @Deprecated - // suppress unchecked because we are using varargs inside the method - @SuppressWarnings("unchecked") - public final static Observable from(T t1, T t2, T t3, T t4) { - return from(Arrays.asList(t1, t2, t3, t4)); - } - - /** - * Converts five items into an Observable that emits those items. - *

- * - *

- *
Scheduler:
- *
{@code from} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param t1 - * first item - * @param t2 - * second item - * @param t3 - * third item - * @param t4 - * fourth item - * @param t5 - * fifth item - * @param - * the type of these items - * @return an Observable that emits each item - * @see RxJava wiki: from - * @deprecated use {@link #just} instead - */ - @Deprecated - // suppress unchecked because we are using varargs inside the method - @SuppressWarnings("unchecked") - public final static Observable from(T t1, T t2, T t3, T t4, T t5) { - return from(Arrays.asList(t1, t2, t3, t4, t5)); - } - - /** - * Converts six items into an Observable that emits those items. - *

- * - *

- *
Scheduler:
- *
{@code from} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param t1 - * first item - * @param t2 - * second item - * @param t3 - * third item - * @param t4 - * fourth item - * @param t5 - * fifth item - * @param t6 - * sixth item - * @param - * the type of these items - * @return an Observable that emits each item - * @see RxJava wiki: from - * @deprecated use {@link #just} instead - */ - @Deprecated - // suppress unchecked because we are using varargs inside the method - @SuppressWarnings("unchecked") - public final static Observable from(T t1, T t2, T t3, T t4, T t5, T t6) { - return from(Arrays.asList(t1, t2, t3, t4, t5, t6)); - } - - /** - * Converts seven items into an Observable that emits those items. - *

- * - *

- *
Scheduler:
- *
{@code from} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param t1 - * first item - * @param t2 - * second item - * @param t3 - * third item - * @param t4 - * fourth item - * @param t5 - * fifth item - * @param t6 - * sixth item - * @param t7 - * seventh item - * @param - * the type of these items - * @return an Observable that emits each item - * @see RxJava wiki: from - * @deprecated use {@link #just} instead - */ - @Deprecated - // suppress unchecked because we are using varargs inside the method - @SuppressWarnings("unchecked") - public final static Observable from(T t1, T t2, T t3, T t4, T t5, T t6, T t7) { - return from(Arrays.asList(t1, t2, t3, t4, t5, t6, t7)); - } - - /** - * Converts eight items into an Observable that emits those items. - *

- * - *

- *
Scheduler:
- *
{@code from} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param t1 - * first item - * @param t2 - * second item - * @param t3 - * third item - * @param t4 - * fourth item - * @param t5 - * fifth item - * @param t6 - * sixth item - * @param t7 - * seventh item - * @param t8 - * eighth item - * @param - * the type of these items - * @return an Observable that emits each item - * @see RxJava wiki: from - * @deprecated use {@link #just} instead - */ - @Deprecated - // suppress unchecked because we are using varargs inside the method - @SuppressWarnings("unchecked") - public final static Observable from(T t1, T t2, T t3, T t4, T t5, T t6, T t7, T t8) { - return from(Arrays.asList(t1, t2, t3, t4, t5, t6, t7, t8)); - } - - /** - * Converts nine items into an Observable that emits those items. - *

- * - *

- *
Scheduler:
- *
{@code from} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param t1 - * first item - * @param t2 - * second item - * @param t3 - * third item - * @param t4 - * fourth item - * @param t5 - * fifth item - * @param t6 - * sixth item - * @param t7 - * seventh item - * @param t8 - * eighth item - * @param t9 - * ninth item - * @param - * the type of these items - * @return an Observable that emits each item - * @see RxJava wiki: from - * @deprecated use {@link #just} instead - */ - @Deprecated - // suppress unchecked because we are using varargs inside the method - @SuppressWarnings("unchecked") - public final static Observable from(T t1, T t2, T t3, T t4, T t5, T t6, T t7, T t8, T t9) { - return from(Arrays.asList(t1, t2, t3, t4, t5, t6, t7, t8, t9)); - } - - /** - * Converts ten items into an Observable that emits those items. - *

- * - *

- *
Scheduler:
- *
{@code from} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param t1 - * first item - * @param t2 - * second item - * @param t3 - * third item - * @param t4 - * fourth item - * @param t5 - * fifth item - * @param t6 - * sixth item - * @param t7 - * seventh item - * @param t8 - * eighth item - * @param t9 - * ninth item - * @param t10 - * tenth item - * @param - * the type of these items - * @return an Observable that emits each item - * @see RxJava wiki: from - * @deprecated use {@link #just} instead - */ - @Deprecated - // suppress unchecked because we are using varargs inside the method - @SuppressWarnings("unchecked") - public final static Observable from(T t1, T t2, T t3, T t4, T t5, T t6, T t7, T t8, T t9, T t10) { - return from(Arrays.asList(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10)); - } - /** * Converts an Array into an Observable that emits the items in the Array. *

@@ -1650,31 +1213,6 @@ public final static Observable from(T[] array) { return from(Arrays.asList(array)); } - /** - * Converts an Array into an Observable that emits the items in the Array on a specified Scheduler. - *

- * - *

- *
Scheduler:
- *
you specify which {@link Scheduler} this operator will use
- *
- * - * @param items - * the source Array - * @param scheduler - * the Scheduler on which the Observable emits the items of the Array - * @param - * the type of items in the Array and the type of items to be emitted by the resulting Observable - * @return an Observable that emits each item in the source Array - * @see RxJava wiki: from - * @see MSDN: Observable.ToObservable - * @deprecated use {@link #subscribeOn} to schedule the work - */ - @Deprecated - public final static Observable from(T[] items, Scheduler scheduler) { - return from(Arrays.asList(items), scheduler); - } - /** * Returns an Observable that emits a sequential number every specified interval of time. *

@@ -2087,67 +1625,6 @@ public final static Observable merge(Iterable - * - *

- * You can combine the items emitted by multiple Observables so that they appear as a single Observable, by - * using the {@code merge} method. - *

- *
Scheduler:
- *
you specify which {@link Scheduler} this operator will use
- *
- * - * @param sequences - * the Iterable of Observables - * @param maxConcurrent - * the maximum number of Observables that may be subscribed to concurrently - * @param scheduler - * the Scheduler on which to traverse the Iterable of Observables - * @return an Observable that emits items that are the result of flattening the items emitted by the - * Observables in the Iterable - * @throws IllegalArgumentException - * if {@code maxConcurrent} is less than or equal to 0 - * @see RxJava wiki: merge - * @see MSDN: Observable.Merge - * @deprecated use {@link #subscribeOn} to schedule - */ - @Deprecated - public final static Observable merge(Iterable> sequences, int maxConcurrent, Scheduler scheduler) { - return merge(from(sequences, scheduler), maxConcurrent); - } - - /** - * Flattens an Iterable of Observables into one Observable, without any transformation, subscribing to these - * Observables on a specified Scheduler. - *

- * - *

- * You can combine the items emitted by multiple Observables so that they appear as a single Observable, by - * using the {@code merge} method. - *

- *
Scheduler:
- *
you specify which {@link Scheduler} this operator will use
- *
- * - * @param sequences - * the Iterable of Observables - * @param scheduler - * the Scheduler on which to traverse the Iterable of Observables - * @return an Observable that emits items that are the result of flattening the items emitted by the - * Observables in the Iterable - * @see RxJava wiki: merge - * @see MSDN: Observable.Merge - * @deprecated use {@link #subscribeOn} to schedule - */ - @Deprecated - public final static Observable merge(Iterable> sequences, Scheduler scheduler) { - return merge(from(sequences, scheduler)); - } - /** * Flattens an Observable that emits Observables into a single Observable that emits the items emitted by * those Observables, without any transformation. @@ -2479,33 +1956,6 @@ public final static Observable merge(Observable[] sequences) return merge(from(sequences)); } - /** - * Flattens an Array of Observables into one Observable, without any transformation, traversing the array on - * a specified Scheduler. - *

- * - *

- * You can combine items emitted by multiple Observables so that they appear as a single Observable, by - * using the {@code merge} method. - *

- *
Scheduler:
- *
you specify which {@link Scheduler} this operator will use
- *
- * - * @param sequences - * the Array of Observables - * @param scheduler - * the Scheduler on which to traverse the Array - * @return an Observable that emits all of the items emitted by the Observables in the Array - * @see RxJava wiki: merge - * @see MSDN: Observable.Merge - * @deprecated use {@link #subscribeOn} to schedule - */ - @Deprecated - public final static Observable merge(Observable[] sequences, Scheduler scheduler) { - return merge(from(sequences, scheduler)); - } - /** * Flattens an Observable that emits Observables into one Observable, in a way that allows an Observer to * receive all successfully emitted items from all of the source Observables without being interrupted by @@ -3208,41 +2658,11 @@ public final static Observable timer(long delay, TimeUnit unit, Scheduler * @see RxJava wiki: using * @see MSDN: Observable.Using */ - public final static Observable using( - final Func0 resourceFactory, - final Func1> observableFactory, - final Action1 disposeAction) { - return create(new OnSubscribeUsing(resourceFactory, observableFactory, disposeAction)); - } - - /** - * Constructs an Observable that creates a dependent resource object. - *

- * - *

- *
Scheduler:
- *
{@code using} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param resourceFactory - * the factory function to create a resource object that depends on the Observable - * @param observableFactory - * the factory function to create an Observable - * @return the Observable whose lifetime controls the lifetime of the dependent resource object - * @see RxJava wiki: using - * @see MSDN: Observable.Using - * @deprecated use the other {@code using} method with different overloads - */ - @Deprecated - public final static Observable using(Func0 resourceFactory, Func1> observableFactory) { - return create(new OnSubscribeUsing(resourceFactory, observableFactory, new Action1() { - - @Override - public void call(Resource r) { - r.unsubscribe(); - } - - })); + public final static Observable using( + final Func0 resourceFactory, + final Func1> observableFactory, + final Action1 disposeAction) { + return create(new OnSubscribeUsing(resourceFactory, observableFactory, disposeAction)); } /** @@ -5759,151 +5179,6 @@ public final Observable> materialize() { return lift(new OperatorMaterialize()); } - /** - * Returns an Observable that emits the results of applying a specified function to each item emitted by the - * source Observable, where that function returns an Observable, and then merging those resulting - * Observables and emitting the results of this merger. - *

- * - *

- *
Scheduler:
- *
{@code mergeMap} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param func - * a function that, when applied to an item emitted by the source Observable, returns an - * Observable - * @return an Observable that emits the result of applying the transformation function to each item emitted - * by the source Observable and merging the results of the Observables obtained from these - * transformations - * @see RxJava wiki: flatMap - * @see #flatMap(Func1) - * @deprecated use {@link #flatMap} - */ - @Deprecated - public final Observable mergeMap(Func1> func) { - return merge(map(func)); - } - - /** - * Returns an Observable that applies a function to each item emitted or notification raised by the source - * Observable and then flattens the Observables returned from these functions and emits the resulting items. - *

- * - *

- *
Scheduler:
- *
{@code mergeMap} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param - * the result type - * @param onNext - * a function that returns an Observable to merge for each item emitted by the source Observable - * @param onError - * a function that returns an Observable to merge for an onError notification from the source - * Observable - * @param onCompleted - * a function that returns an Observable to merge for an onCompleted notification from the source - * Observable - * @return an Observable that emits the results of merging the Observables returned from applying the - * specified functions to the emissions and notifications of the source Observable - * @see RxJava wiki: flatMap - * @deprecated use {@link #flatMap} - */ - @Deprecated - public final Observable mergeMap( - Func1> onNext, - Func1> onError, - Func0> onCompleted) { - return merge(mapNotification(onNext, onError, onCompleted)); - } - - /** - * Returns an Observable that emits the results of a specified function to the pair of values emitted by the - * source Observable and a specified collection Observable. - *

- * - *

- *
Scheduler:
- *
{@code mergeMap} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param - * the type of items emitted by the collection Observable - * @param - * the type of items emitted by the resulting Observable - * @param collectionSelector - * a function that returns an Observable for each item emitted by the source Observable - * @param resultSelector - * a function that combines one item emitted by each of the source and collection Observables and - * returns an item to be emitted by the resulting Observable - * @return an Observable that emits the results of applying a function to a pair of values emitted by the - * source Observable and the collection Observable - * @see RxJava wiki: flatMap - * @deprecated use {@link #flatMap} - */ - @Deprecated - public final Observable mergeMap(Func1> collectionSelector, - Func2 resultSelector) { - return flatMap(collectionSelector, resultSelector); - } - - /** - * Returns an Observable that merges each item emitted by the source Observable with the values in an - * Iterable corresponding to that item that is generated by a selector. - *

- * - *

- *
Scheduler:
- *
{@code mergeMapIterable} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param - * the type of item emitted by the resulting Observable - * @param collectionSelector - * a function that returns an Iterable sequence of values for when given an item emitted by the - * source Observable - * @return an Observable that emits the results of merging the items emitted by the source Observable with - * the values in the Iterables corresponding to those items, as generated by {@code collectionSelector} - * @see RxJava wiki: flatMapIterable - * @deprecated use {@link #flatMapIterable} - */ - @Deprecated - public final Observable mergeMapIterable(Func1> collectionSelector) { - return merge(map(OperatorMapPair.convertSelector(collectionSelector))); - } - - /** - * Returns an Observable that emits the results of applying a function to the pair of values from the source - * Observable and an Iterable corresponding to that item that is generated by a selector. - *

- * - *

- *
Scheduler:
- *
{@code mergeMapIterable} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param - * the collection element type - * @param - * the type of item emited by the resulting Observable - * @param collectionSelector - * a function that returns an Iterable sequence of values for each item emitted by the source - * Observable - * @param resultSelector - * a function that returns an item based on the item emitted by the source Observable and the - * Iterable returned for that item by the {@code collectionSelector} - * @return an Observable that emits the items returned by {@code resultSelector} for each item in the source - * Observable - * @see RxJava wiki: flatMapIterable - * @deprecated use {@link #flatMapIterable} - */ - @Deprecated - public final Observable mergeMapIterable(Func1> collectionSelector, - Func2 resultSelector) { - return mergeMap(OperatorMapPair.convertSelector(collectionSelector), resultSelector); - } - /** * Flattens this and another Observable into a single Observable, without any transformation. *

@@ -5960,43 +5235,6 @@ public final Observable multicast( return create(new OnSubscribeMulticastSelector(this, subjectFactory, selector)); } - /** - * Returns a {@link ConnectableObservable} that upon connection causes the source Observable to push results - * into the specified subject. A Connectable Observable resembles an ordinary Observable, except that it - * does not begin emitting items when it is subscribed to, but only when its {@code connect} method - * is called. - *

- *
Backpressure Support:
- *
This operator does not support backpressure because multicasting means the stream is "hot" with - * multiple subscribers. Each child will need to manage backpressure independently using operators such - * as {@link #onBackpressureDrop} and {@link #onBackpressureBuffer}.
- *
Scheduler:
- *
{@code multicast} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param subject - * the {@link Subject} for the {@link ConnectableObservable} to push source items into - * @param - * the type of items emitted by the resulting {@code ConnectableObservable} - * @return a {@link ConnectableObservable} that upon connection causes the source Observable to push results - * into the specified {@link Subject} - * @see RxJava wiki: Observable.publish and Observable.multicast - * @see MSDN: Observable.Multicast - * @deprecated use {@link #multicast(Func0)} instead. This one caused nuanced bugs as it retains state. - */ - @Deprecated - public final ConnectableObservable multicast(final Subject subject) { - return new OperatorMulticast(this, new Func0>() { - - @Override - public Subject call() { - // same one every time, no factory behavior - return subject; - } - - }); - } - /** * Returns a {@link ConnectableObservable} that upon connection causes the source Observable to push results * into the specified subject. A Connectable Observable resembles an ordinary Observable, except that it @@ -6205,30 +5443,6 @@ public final Observable onErrorReturn(Func1 resumeFun return lift(new OperatorOnErrorReturn(resumeFunction)); } - /** - * Intercepts {@code onError} notifications from the source Observable and replaces them with the - * {@code onNext} emissions of an Observable returned by a specified function. This allows the source - * sequence to continue even if it issues multiple {@code onError} notifications. - *

- * - *

- *
Scheduler:
- *
{@code onErrorFlatMap} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param resumeFunction - * a function that accepts an {@link OnErrorThrowable} representing the Throwable issued by the - * source Observable, and returns an Observable that emits items that will be emitted in place - * of the error - * @return the original Observable, with appropriately modified behavior - * @see RxJava wiki: onErrorFlatMap - * @deprecated see https://github.com/ReactiveX/RxJava/issues/1465 - */ - @Deprecated - public final Observable onErrorFlatMap(final Func1> resumeFunction) { - return lift(new OperatorOnErrorFlatMap(resumeFunction)); - } - /** * Instructs an Observable to pass control to another Observable rather than invoking * {@link Observer#onError onError} if it encounters an {@link java.lang.Exception}. @@ -8002,31 +7216,6 @@ public final Observable startWith(Iterable values) { return concat(Observable. from(values), this); } - /** - * Returns an Observable that emits the items in a specified {@link Iterable}, on a specified - * {@link Scheduler}, before it begins to emit items emitted by the source Observable. - *

- * - *

- *
Scheduler:
- *
you specify which {@link Scheduler} this operator will use
- *
- * - * @param values - * an Iterable that contains the items you want the modified Observable to emit first - * @param scheduler - * the Scheduler to emit the prepended values on - * @return an Observable that emits the items in the specified {@link Iterable} and then emits the items - * emitted by the source Observable - * @see RxJava wiki: startWith - * @see MSDN: Observable.StartWith - * @deprecated use {@link #subscribeOn} to schedule - */ - @Deprecated - public final Observable startWith(Iterable values, Scheduler scheduler) { - return concat(from(values, scheduler), this); - } - /** * Returns an Observable that emits a specified item before it begins to emit items emitted by the source * Observable. @@ -8288,31 +7477,6 @@ public final Observable startWith(T t1, T t2, T t3, T t4, T t5, T t6, T t7, T return concat(just(t1, t2, t3, t4, t5, t6, t7, t8, t9), this); } - /** - * Returns an Observable that emits the items from a specified array, on a specified Scheduler, before it - * begins to emit items emitted by the source Observable. - *

- * - *

- *
Scheduler:
- *
you specify which {@link Scheduler} this operator will use
- *
- * - * @param values - * the items you want the modified Observable to emit first - * @param scheduler - * the Scheduler to emit the prepended values on - * @return an Observable that emits the items from {@code values}, on {@code scheduler}, before it begins to - * emit items emitted by the source Observable. - * @see RxJava wiki: startWith - * @see MSDN: Observable.StartWith - * @deprecated use {@link #subscribeOn} to schedule - */ - @Deprecated - public final Observable startWith(T[] values, Scheduler scheduler) { - return startWith(Arrays.asList(values), scheduler); - } - /** * Subscribes to an Observable but ignore its emissions and notifications. *
@@ -9624,18 +8788,6 @@ public final Observable> timestamp(Scheduler scheduler) { return lift(new OperatorTimestamp(scheduler)); } - /** - * Converts an Observable into a {@link BlockingObservable} (an Observable with blocking operators). - * - * @return a {@code BlockingObservable} version of this Observable - * @see RxJava wiki: Blocking Observable Operators - * @deprecated use {@link #toBlocking()} instead - */ - @Deprecated - public final BlockingObservable toBlockingObservable() { - return BlockingObservable.from(this); - } - /** * Converts an Observable into a {@link BlockingObservable} (an Observable with blocking operators). *
@@ -10282,39 +9434,6 @@ public final Observable> window(Observable boundary) { return lift(new OperatorWindowWithObservable(boundary)); } - /** - * Returns an Observable that emits items that are the result of applying a specified function to pairs of - * values, one each from the source Observable and a specified Iterable sequence. - *

- * - *

- * Note that the {@code other} Iterable is evaluated as items are observed from the source Observable; it is - * not pre-consumed. This allows you to zip infinite streams on either side. - *

- *
Scheduler:
- *
{@code zip} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param - * the type of items in the {@code other} Iterable - * @param - * the type of items emitted by the resulting Observable - * @param other - * the Iterable sequence - * @param zipFunction - * a function that combines the pairs of items from the Observable and the Iterable to generate - * the items to be emitted by the resulting Observable - * @return an Observable that pairs up values from the source Observable and the {@code other} Iterable - * sequence and emits the results of {@code zipFunction} applied to these pairs - * @see RxJava wiki: zip - * @see MSDN: Observable.Zip - * @deprecated use {@link #zipWith} - */ - @Deprecated - public final Observable zip(Iterable other, Func2 zipFunction) { - return lift(new OperatorZipIterable(other, zipFunction)); - } - /** * Returns an Observable that emits items that are the result of applying a specified function to pairs of * values, one each from the source Observable and a specified Iterable sequence. @@ -10346,37 +9465,6 @@ public final Observable zipWith(Iterable other, Func2(other, zipFunction)); } - /** - * Returns an Observable that emits items that are the result of applying a specified function to pairs of - * values, one each from the source Observable and another specified Observable. - *

- * - *

- *
Scheduler:
- *
{@code zip} does not operate by default on a particular {@link Scheduler}.
- *
- * - * @param - * the type of items emitted by the {@code other} Observable - * @param - * the type of items emitted by the resulting Observable - * @param other - * the other Observable - * @param zipFunction - * a function that combines the pairs of items from the two Observables to generate the items to - * be emitted by the resulting Observable - * @return an Observable that pairs up values from the source Observable and the {@code other} Observable - * and emits the results of {@code zipFunction} applied to these pairs - * @see RxJava wiki: zip - * @see MSDN: Observable.Zip - * @deprecated use {@link #zipWith} instead. Changed to match naming convention of {@link #mergeWith}, - * {@link #concatWith}, etc. - */ - @Deprecated - public final Observable zip(Observable other, Func2 zipFunction) { - return zip(this, other, zipFunction); - } - /** * Returns an Observable that emits items that are the result of applying a specified function to pairs of * values, one each from the source Observable and another specified Observable. diff --git a/rxjava/src/main/java/rx/Subscriber.java b/rxjava/src/main/java/rx/Subscriber.java index 04dd96469b..9895209561 100644 --- a/rxjava/src/main/java/rx/Subscriber.java +++ b/rxjava/src/main/java/rx/Subscriber.java @@ -40,13 +40,6 @@ public abstract class Subscriber implements Observer, Subscription { /* protected by `this` */ private long requested = Long.MIN_VALUE; // default to not set - @Deprecated - protected Subscriber(CompositeSubscription cs) { - this.op = null; - this.cs = new SubscriptionList(); - add(cs); - } - protected Subscriber() { this.op = null; this.cs = new SubscriptionList(); diff --git a/rxjava/src/main/java/rx/observables/GroupedObservable.java b/rxjava/src/main/java/rx/observables/GroupedObservable.java index 37b19d3e7e..490a9b1190 100644 --- a/rxjava/src/main/java/rx/observables/GroupedObservable.java +++ b/rxjava/src/main/java/rx/observables/GroupedObservable.java @@ -38,27 +38,6 @@ public class GroupedObservable extends Observable { private final K key; - /** - * Converts an {@link Observable} into a {@code GroupedObservable} with a particular key. - * - * @param key - * the key to identify the group of items emitted by this {@code GroupedObservable} - * @param o - * the {@link Observable} to convert - * @return a {@code GroupedObservable} representation of {@code o}, with key {@code key} - * @deprecated Use Observable.groupBy with element selector instead. - */ - @Deprecated - public static GroupedObservable from(K key, final Observable o) { - return new GroupedObservable(key, new OnSubscribe() { - - @Override - public void call(Subscriber s) { - o.unsafeSubscribe(s); - } - }); - } - public GroupedObservable(K key, OnSubscribe onSubscribe) { super(onSubscribe); this.key = key; diff --git a/rxjava/src/main/java/rx/plugins/RxJavaDefaultSchedulers.java b/rxjava/src/main/java/rx/plugins/RxJavaDefaultSchedulers.java deleted file mode 100644 index a27d7efb1d..0000000000 --- a/rxjava/src/main/java/rx/plugins/RxJavaDefaultSchedulers.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.plugins; - -import rx.Scheduler; - -/** - * Define alternate Scheduler implementations to be returned by the {@code Schedulers} factory methods. - *

- * See {@link RxJavaPlugins} or the RxJava GitHub Wiki for information on configuring plugins: - * https://github.com/ReactiveX/RxJava/wiki/Plugins. - */ -@Deprecated -public abstract class RxJavaDefaultSchedulers { - - /** - * Scheduler to return from {@link rx.schedulers.Schedulers#computation()} or null if default should be - * used. - * - * This instance should be or behave like a stateless singleton; - */ - public abstract Scheduler getComputationScheduler(); - - /** - * Scheduler to return from {@link rx.schedulers.Schedulers#io()} or null if default should be used. - * - * This instance should be or behave like a stateless singleton; - */ - public abstract Scheduler getIOScheduler(); - - /** - * Scheduler to return from {@link rx.schedulers.Schedulers#newThread()} or null if default should be used. - * - * This instance should be or behave like a stateless singleton; - */ - public abstract Scheduler getNewThreadScheduler(); -} diff --git a/rxjava/src/main/java/rx/plugins/RxJavaDefaultSchedulersDefault.java b/rxjava/src/main/java/rx/plugins/RxJavaDefaultSchedulersDefault.java deleted file mode 100644 index 0e2cd4300e..0000000000 --- a/rxjava/src/main/java/rx/plugins/RxJavaDefaultSchedulersDefault.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.plugins; - -import rx.Scheduler; - -/** - * Default implementation of {@link RxJavaErrorHandler} that does nothing. - * - * @ExcludeFromJavadoc - */ -@Deprecated -public class RxJavaDefaultSchedulersDefault extends RxJavaDefaultSchedulers { - - private static RxJavaDefaultSchedulersDefault INSTANCE = new RxJavaDefaultSchedulersDefault(); - - public static RxJavaDefaultSchedulers getInstance() { - return INSTANCE; - } - - @Override - public Scheduler getComputationScheduler() { - return null; - } - - @Override - public Scheduler getIOScheduler() { - return null; - } - - @Override - public Scheduler getNewThreadScheduler() { - return null; - } - -} diff --git a/rxjava/src/main/java/rx/plugins/RxJavaPlugins.java b/rxjava/src/main/java/rx/plugins/RxJavaPlugins.java index caf4fa83f5..a8a58c4633 100644 --- a/rxjava/src/main/java/rx/plugins/RxJavaPlugins.java +++ b/rxjava/src/main/java/rx/plugins/RxJavaPlugins.java @@ -34,8 +34,6 @@ public class RxJavaPlugins { private final AtomicReference errorHandler = new AtomicReference(); private final AtomicReference observableExecutionHook = new AtomicReference(); - //deprecated - private final AtomicReference schedulerOverrides = new AtomicReference(); private final AtomicReference schedulersHook = new AtomicReference(); /** @@ -169,48 +167,6 @@ private static Object getPluginImplementationViaProperty(Class pluginClass) { } } - /** - * Retrieves the instance of {@link RxJavaDefaultSchedulers} to use based on order of precedence as defined - * in the {@link RxJavaPlugins} class header. - *

- * Override the default by calling {@link #registerDefaultSchedulers(RxJavaDefaultSchedulers)} or by setting - * the property {@code rxjava.plugin.RxJavaDefaultSchedulers.implementation} with the full classname to - * load. - * - * @return the {@link RxJavaDefaultSchedulers} implementation in use - */ - public RxJavaDefaultSchedulers getDefaultSchedulers() { - if (schedulerOverrides.get() == null) { - // check for an implementation from System.getProperty first - Object impl = getPluginImplementationViaProperty(RxJavaDefaultSchedulers.class); - if (impl == null) { - // nothing set via properties so initialize with default - schedulerOverrides.compareAndSet(null, RxJavaDefaultSchedulersDefault.getInstance()); - // we don't return from here but call get() again in case of thread-race so the winner will always get returned - } else { - // we received an implementation from the system property so use it - schedulerOverrides.compareAndSet(null, (RxJavaDefaultSchedulers) impl); - } - } - return schedulerOverrides.get(); - } - - /** - * Registers an {@link RxJavaDefaultSchedulers} implementation as a global override of any injected or - * default implementations. - * - * @param impl - * {@link RxJavaDefaultSchedulers} implementation - * @throws IllegalStateException - * if called more than once or after the default was initialized (if usage occurs before trying - * to register) - */ - public void registerDefaultSchedulers(RxJavaDefaultSchedulers impl) { - if (!schedulerOverrides.compareAndSet(null, impl)) { - throw new IllegalStateException("Another strategy was already registered: " + schedulerOverrides.get()); - } - } - /** * Retrieves the instance of {@link RxJavaSchedulersHook} to use based on order of precedence as defined * in the {@link RxJavaPlugins} class header. diff --git a/rxjava/src/main/java/rx/schedulers/Schedulers.java b/rxjava/src/main/java/rx/schedulers/Schedulers.java index 37dea765d8..c560c4b7a7 100644 --- a/rxjava/src/main/java/rx/schedulers/Schedulers.java +++ b/rxjava/src/main/java/rx/schedulers/Schedulers.java @@ -32,21 +32,21 @@ public final class Schedulers { private static final Schedulers INSTANCE = new Schedulers(); private Schedulers() { - Scheduler c = RxJavaPlugins.getInstance().getDefaultSchedulers().getComputationScheduler(); + Scheduler c = RxJavaPlugins.getInstance().getSchedulersHook().getComputationScheduler(); if (c != null) { computationScheduler = c; } else { computationScheduler = new EventLoopsScheduler(); } - Scheduler io = RxJavaPlugins.getInstance().getDefaultSchedulers().getIOScheduler(); + Scheduler io = RxJavaPlugins.getInstance().getSchedulersHook().getIOScheduler(); if (io != null) { ioScheduler = io; } else { ioScheduler = new CachedThreadScheduler(); } - Scheduler nt = RxJavaPlugins.getInstance().getDefaultSchedulers().getNewThreadScheduler(); + Scheduler nt = RxJavaPlugins.getInstance().getSchedulersHook().getNewThreadScheduler(); if (nt != null) { newThreadScheduler = nt; } else { diff --git a/rxjava/src/test/java/rx/CovarianceTest.java b/rxjava/src/test/java/rx/CovarianceTest.java index 55781cceb3..769733d704 100644 --- a/rxjava/src/test/java/rx/CovarianceTest.java +++ b/rxjava/src/test/java/rx/CovarianceTest.java @@ -61,12 +61,12 @@ public Integer call(Media t1, Media t2) { @Test public void testCovarianceOfCompose() { - Observable movie = Observable. from(new HorrorMovie()); + Observable movie = Observable. just(new HorrorMovie()); Observable movie2 = movie.compose(new Transformer() { @Override public Observable call(Observable t1) { - return Observable.from(new Movie()); + return Observable.just(new Movie()); } }); @@ -74,11 +74,11 @@ public Observable call(Observable t1) { @Test public void testCovarianceOfCompose2() { - Observable movie = Observable. from(new HorrorMovie()); + Observable movie = Observable. just(new HorrorMovie()); Observable movie2 = movie.compose(new Transformer() { @Override public Observable call(Observable t1) { - return Observable.from(new HorrorMovie()); + return Observable.just(new HorrorMovie()); } }); } diff --git a/rxjava/src/test/java/rx/ObservableTests.java b/rxjava/src/test/java/rx/ObservableTests.java index 15991767e0..a76298a801 100644 --- a/rxjava/src/test/java/rx/ObservableTests.java +++ b/rxjava/src/test/java/rx/ObservableTests.java @@ -959,7 +959,7 @@ public void testIgnoreElements() { @Test public void testJustWithScheduler() { TestScheduler scheduler = new TestScheduler(); - Observable observable = Observable.from(Arrays.asList(1, 2), scheduler); + Observable observable = Observable.from(Arrays.asList(1, 2)).subscribeOn(scheduler); @SuppressWarnings("unchecked") Observer observer = mock(Observer.class); @@ -977,7 +977,7 @@ public void testJustWithScheduler() { @Test public void testStartWithWithScheduler() { TestScheduler scheduler = new TestScheduler(); - Observable observable = Observable.just(3, 4).startWith(Arrays.asList(1, 2), scheduler); + Observable observable = Observable.just(3, 4).startWith(Arrays.asList(1, 2)).subscribeOn(scheduler); @SuppressWarnings("unchecked") Observer observer = mock(Observer.class); diff --git a/rxjava/src/test/java/rx/internal/operators/BlockingOperatorLatestTest.java b/rxjava/src/test/java/rx/internal/operators/BlockingOperatorLatestTest.java index e62a5a94f1..35410714f8 100644 --- a/rxjava/src/test/java/rx/internal/operators/BlockingOperatorLatestTest.java +++ b/rxjava/src/test/java/rx/internal/operators/BlockingOperatorLatestTest.java @@ -115,7 +115,7 @@ public void testSimpleJustNext() { public void testHasNextThrows() { TestScheduler scheduler = new TestScheduler(); - BlockingObservable source = Observable. error(new RuntimeException("Forced failure!"), scheduler).toBlocking(); + BlockingObservable source = Observable. error(new RuntimeException("Forced failure!")).subscribeOn(scheduler).toBlocking(); Iterable iter = source.latest(); @@ -130,7 +130,7 @@ public void testHasNextThrows() { public void testNextThrows() { TestScheduler scheduler = new TestScheduler(); - BlockingObservable source = Observable. error(new RuntimeException("Forced failure!"), scheduler).toBlocking(); + BlockingObservable source = Observable. error(new RuntimeException("Forced failure!")).subscribeOn(scheduler).toBlocking(); Iterable iter = source.latest(); Iterator it = iter.iterator(); diff --git a/rxjava/src/test/java/rx/internal/operators/OnSubscribeCacheTest.java b/rxjava/src/test/java/rx/internal/operators/OnSubscribeCacheTest.java index e45496bd32..ac16b554d0 100644 --- a/rxjava/src/test/java/rx/internal/operators/OnSubscribeCacheTest.java +++ b/rxjava/src/test/java/rx/internal/operators/OnSubscribeCacheTest.java @@ -114,7 +114,7 @@ public Integer call(Long t1) { Observable source2 = source1 .repeat(4) - .zip(Observable.timer(0, 10, TimeUnit.MILLISECONDS, Schedulers.newThread()), new Func2() { + .zipWith(Observable.timer(0, 10, TimeUnit.MILLISECONDS, Schedulers.newThread()), new Func2() { @Override public Integer call(Integer t1, Long t2) { return t1; diff --git a/rxjava/src/test/java/rx/internal/operators/OnSubscribeCombineLatestTest.java b/rxjava/src/test/java/rx/internal/operators/OnSubscribeCombineLatestTest.java index e1201b3e7d..31f772e272 100644 --- a/rxjava/src/test/java/rx/internal/operators/OnSubscribeCombineLatestTest.java +++ b/rxjava/src/test/java/rx/internal/operators/OnSubscribeCombineLatestTest.java @@ -791,7 +791,7 @@ public void testBackpressure() { int NUM = RxRingBuffer.SIZE * 4; TestSubscriber ts = new TestSubscriber(); - Observable.combineLatest(Observable.from("one", "two"), + Observable.combineLatest(Observable.just("one", "two"), Observable.range(2, NUM), combineLatestFunction). observeOn(Schedulers.computation()).subscribe(ts); diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorMergeMapTest.java b/rxjava/src/test/java/rx/internal/operators/OperatorFlatMapTest.java similarity index 91% rename from rxjava/src/test/java/rx/internal/operators/OperatorMergeMapTest.java rename to rxjava/src/test/java/rx/internal/operators/OperatorFlatMapTest.java index ccd977152c..d97c3c09f5 100644 --- a/rxjava/src/test/java/rx/internal/operators/OperatorMergeMapTest.java +++ b/rxjava/src/test/java/rx/internal/operators/OperatorFlatMapTest.java @@ -34,7 +34,7 @@ import rx.functions.Func1; import rx.functions.Func2; -public class OperatorMergeMapTest { +public class OperatorFlatMapTest { @Test public void testNormal() { @SuppressWarnings("unchecked") @@ -58,7 +58,7 @@ public Integer call(Integer t1, Integer t2) { List source = Arrays.asList(16, 32, 64); - Observable.from(source).mergeMapIterable(func, resFunc).subscribe(o); + Observable.from(source).flatMapIterable(func, resFunc).subscribe(o); for (Integer s : source) { for (Integer v : list) { @@ -90,7 +90,7 @@ public Integer call(Integer t1, Integer t2) { List source = Arrays.asList(16, 32, 64); - Observable.from(source).mergeMapIterable(func, resFunc).subscribe(o); + Observable.from(source).flatMapIterable(func, resFunc).subscribe(o); verify(o, never()).onCompleted(); verify(o, never()).onNext(any()); @@ -120,7 +120,7 @@ public Integer call(Integer t1, Integer t2) { List source = Arrays.asList(16, 32, 64); - Observable.from(source).mergeMapIterable(func, resFunc).subscribe(o); + Observable.from(source).flatMapIterable(func, resFunc).subscribe(o); verify(o, never()).onCompleted(); verify(o, never()).onNext(any()); @@ -148,7 +148,7 @@ public Integer call(Integer t1, Integer t2) { List source = Arrays.asList(16, 32, 64); - Observable.from(source).mergeMap(func, resFunc).subscribe(o); + Observable.from(source).flatMap(func, resFunc).subscribe(o); verify(o, never()).onCompleted(); verify(o, never()).onNext(any()); @@ -186,7 +186,7 @@ public void testFlatMapTransformsNormal() { @SuppressWarnings("unchecked") Observer o = mock(Observer.class); - source.mergeMap(just(onNext), just(onError), just0(onCompleted)).subscribe(o); + source.flatMap(just(onNext), just(onError), just0(onCompleted)).subscribe(o); verify(o, times(3)).onNext(1); verify(o, times(3)).onNext(2); @@ -213,7 +213,7 @@ Observable. error(new RuntimeException("Forced failure!")) @SuppressWarnings("unchecked") Observer o = mock(Observer.class); - source.mergeMap(just(onNext), just(onError), just0(onCompleted)).subscribe(o); + source.flatMap(just(onNext), just(onError), just0(onCompleted)).subscribe(o); verify(o, times(3)).onNext(1); verify(o, times(3)).onNext(2); @@ -253,7 +253,7 @@ public void testFlatMapTransformsOnNextFuncThrows() { @SuppressWarnings("unchecked") Observer o = mock(Observer.class); - source.mergeMap(funcThrow(1, onError), just(onError), just0(onCompleted)).subscribe(o); + source.flatMap(funcThrow(1, onError), just(onError), just0(onCompleted)).subscribe(o); verify(o).onError(any(TestException.class)); verify(o, never()).onNext(any()); @@ -271,7 +271,7 @@ public void testFlatMapTransformsOnErrorFuncThrows() { @SuppressWarnings("unchecked") Observer o = mock(Observer.class); - source.mergeMap(just(onNext), funcThrow((Throwable) null, onError), just0(onCompleted)).subscribe(o); + source.flatMap(just(onNext), funcThrow((Throwable) null, onError), just0(onCompleted)).subscribe(o); verify(o).onError(any(TestException.class)); verify(o, never()).onNext(any()); @@ -289,7 +289,7 @@ public void testFlatMapTransformsOnCompletedFuncThrows() { @SuppressWarnings("unchecked") Observer o = mock(Observer.class); - source.mergeMap(just(onNext), just(onError), funcThrow0(onCompleted)).subscribe(o); + source.flatMap(just(onNext), just(onError), funcThrow0(onCompleted)).subscribe(o); verify(o).onError(any(TestException.class)); verify(o, never()).onNext(any()); @@ -307,7 +307,7 @@ public void testFlatMapTransformsMergeException() { @SuppressWarnings("unchecked") Observer o = mock(Observer.class); - source.mergeMap(just(onNext), just(onError), funcThrow0(onCompleted)).subscribe(o); + source.flatMap(just(onNext), just(onError), funcThrow0(onCompleted)).subscribe(o); verify(o).onError(any(TestException.class)); verify(o, never()).onNext(any()); diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorOnErrorFlatMapTest.java b/rxjava/src/test/java/rx/internal/operators/OperatorOnErrorFlatMapTest.java deleted file mode 100644 index 6acf5c49ee..0000000000 --- a/rxjava/src/test/java/rx/internal/operators/OperatorOnErrorFlatMapTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.internal.operators; - -import static org.junit.Assert.assertEquals; - -import java.util.Arrays; - -import org.junit.Test; - -import rx.Observable; -import rx.exceptions.OnErrorThrowable; -import rx.functions.Func1; -import rx.observers.TestSubscriber; - -public class OperatorOnErrorFlatMapTest { - - @Test - public void ignoreErrorsAndContinueEmitting() { - TestSubscriber ts = new TestSubscriber(); - Observable.just(1, 2, 3, 4, 5, 6).map(new Func1() { - - @Override - public String call(Integer v) { - if (v < 2 || v > 5) { - return "Value=" + v; - } - throw new RuntimeException("error in map function: " + v); - } - - }).onErrorFlatMap(new Func1>() { - - @Override - public Observable call(OnErrorThrowable t) { - return Observable.empty(); - } - - }).subscribe(ts); - - ts.assertTerminalEvent(); - System.out.println(ts.getOnErrorEvents()); - assertEquals(0, ts.getOnErrorEvents().size()); - System.out.println(ts.getOnNextEvents()); - ts.assertReceivedOnNext(Arrays.asList("Value=1", "Value=6")); - } - - @Test - public void spliceAndContinueEmitting() { - TestSubscriber ts = new TestSubscriber(); - Observable.just(1, 2, 3, 4, 5, 6).map(new Func1() { - - @Override - public String call(Integer v) { - if (v < 2 || v > 5) { - return "Value=" + v; - } - throw new RuntimeException("error in map function: " + v); - } - - }).onErrorFlatMap(new Func1>() { - - @Override - public Observable call(OnErrorThrowable t) { - return Observable.just("Error=" + t.getValue()); - } - - }).subscribe(ts); - - ts.assertTerminalEvent(); - System.out.println(ts.getOnErrorEvents()); - assertEquals(0, ts.getOnErrorEvents().size()); - System.out.println(ts.getOnNextEvents()); - ts.assertReceivedOnNext(Arrays.asList("Value=1", "Error=2", "Error=3", "Error=4", "Error=5", "Value=6")); - } - - @Test - public void testOnErrorFlatMapAfterFlatMap() { - TestSubscriber ts = new TestSubscriber(); - Observable.just(1, 2, 3).flatMap(new Func1>() { - - @Override - public Observable call(Integer i) { - System.out.println("i: " + i); - if (i == 1) { - return Observable.error(new RuntimeException("error")); - } else { - return Observable.just(i); - } - } - - }).onErrorFlatMap(new Func1>() { - - @Override - public Observable call(OnErrorThrowable t) { - System.err.println(t); - return Observable.just(-1); - } - - }).subscribe(ts); - // we won't receive a terminal event so don't wait for one - ts.assertNoErrors(); - ts.assertReceivedOnNext(Arrays.asList(-1, 2, 3)); - } - -} diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorWindowTest.java b/rxjava/src/test/java/rx/internal/operators/OperatorWindowTest.java index 4d6151fdf0..61c7858116 100644 --- a/rxjava/src/test/java/rx/internal/operators/OperatorWindowTest.java +++ b/rxjava/src/test/java/rx/internal/operators/OperatorWindowTest.java @@ -98,7 +98,7 @@ public void testSkipAndCountGaplessWindows() { @Test public void testOverlappingWindows() { - Observable subject = Observable.from(new String[] { "zero", "one", "two", "three", "four", "five" }, Schedulers.trampoline()); + Observable subject = Observable.from(new String[] { "zero", "one", "two", "three", "four", "five" }); Observable> windowed = subject.window(3, 1); List> windows = toLists(windowed); diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorZipIterableTest.java b/rxjava/src/test/java/rx/internal/operators/OperatorZipIterableTest.java index ca5d6e84ce..15ae12570d 100644 --- a/rxjava/src/test/java/rx/internal/operators/OperatorZipIterableTest.java +++ b/rxjava/src/test/java/rx/internal/operators/OperatorZipIterableTest.java @@ -95,7 +95,7 @@ public void testZipIterableSameSize() { Iterable r2 = Arrays.asList("1", "2", "3"); - r1.zip(r2, zipr2).subscribe(o); + r1.zipWith(r2, zipr2).subscribe(o); r1.onNext("one-"); r1.onNext("two-"); @@ -121,7 +121,7 @@ public void testZipIterableEmptyFirstSize() { Iterable r2 = Arrays.asList("1", "2", "3"); - r1.zip(r2, zipr2).subscribe(o); + r1.zipWith(r2, zipr2).subscribe(o); r1.onCompleted(); @@ -142,7 +142,7 @@ public void testZipIterableEmptySecond() { Iterable r2 = Arrays.asList(); - r1.zip(r2, zipr2).subscribe(o); + r1.zipWith(r2, zipr2).subscribe(o); r1.onNext("one-"); r1.onNext("two-"); @@ -165,7 +165,7 @@ public void testZipIterableFirstShorter() { Iterable r2 = Arrays.asList("1", "2", "3"); - r1.zip(r2, zipr2).subscribe(o); + r1.zipWith(r2, zipr2).subscribe(o); r1.onNext("one-"); r1.onNext("two-"); @@ -189,7 +189,7 @@ public void testZipIterableSecondShorter() { Iterable r2 = Arrays.asList("1", "2"); - r1.zip(r2, zipr2).subscribe(o); + r1.zipWith(r2, zipr2).subscribe(o); r1.onNext("one-"); r1.onNext("two-"); @@ -214,7 +214,7 @@ public void testZipIterableFirstThrows() { Iterable r2 = Arrays.asList("1", "2", "3"); - r1.zip(r2, zipr2).subscribe(o); + r1.zipWith(r2, zipr2).subscribe(o); r1.onNext("one-"); r1.onNext("two-"); @@ -243,7 +243,7 @@ public Iterator iterator() { } }; - r1.zip(r2, zipr2).subscribe(o); + r1.zipWith(r2, zipr2).subscribe(o); r1.onNext("one-"); r1.onNext("two-"); @@ -295,7 +295,7 @@ public void remove() { }; - r1.zip(r2, zipr2).subscribe(o); + r1.zipWith(r2, zipr2).subscribe(o); r1.onNext("one-"); r1.onError(new TestException()); @@ -340,7 +340,7 @@ public void remove() { }; - r1.zip(r2, zipr2).subscribe(o); + r1.zipWith(r2, zipr2).subscribe(o); r1.onError(new TestException()); @@ -374,7 +374,7 @@ public String call(Integer t1) { SquareStr squareStr = new SquareStr(); - o.map(squareStr).zip(it, concat2Strings).take(2).subscribe(printer); + o.map(squareStr).zipWith(it, concat2Strings).take(2).subscribe(printer); assertEquals(2, squareStr.counter.get()); } diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorZipTest.java b/rxjava/src/test/java/rx/internal/operators/OperatorZipTest.java index f9eff7adef..e015c9943c 100644 --- a/rxjava/src/test/java/rx/internal/operators/OperatorZipTest.java +++ b/rxjava/src/test/java/rx/internal/operators/OperatorZipTest.java @@ -804,7 +804,7 @@ public void onNext(Integer args) { @Test public void testStart() { Observable os = OBSERVABLE_OF_5_INTEGERS - .zip(OBSERVABLE_OF_5_INTEGERS, new Func2() { + .zipWith(OBSERVABLE_OF_5_INTEGERS, new Func2() { @Override public String call(Integer a, Integer b) { @@ -832,7 +832,7 @@ public void call(String s) { public void testStartAsync() throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); Observable os = ASYNC_OBSERVABLE_OF_INFINITE_INTEGERS(new CountDownLatch(1)).onBackpressureBuffer() - .zip(ASYNC_OBSERVABLE_OF_INFINITE_INTEGERS(new CountDownLatch(1)).onBackpressureBuffer(), new Func2() { + .zipWith(ASYNC_OBSERVABLE_OF_INFINITE_INTEGERS(new CountDownLatch(1)).onBackpressureBuffer(), new Func2() { @Override public String call(Integer a, Integer b) { @@ -857,7 +857,7 @@ public void testStartInfiniteAndFinite() throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); final CountDownLatch infiniteObservable = new CountDownLatch(1); Observable os = OBSERVABLE_OF_5_INTEGERS - .zip(ASYNC_OBSERVABLE_OF_INFINITE_INTEGERS(infiniteObservable), new Func2() { + .zipWith(ASYNC_OBSERVABLE_OF_INFINITE_INTEGERS(infiniteObservable), new Func2() { @Override public String call(Integer a, Integer b) { diff --git a/rxjava/src/test/java/rx/schedulers/AbstractSchedulerTests.java b/rxjava/src/test/java/rx/schedulers/AbstractSchedulerTests.java index 94acb530a3..afb7d1617c 100644 --- a/rxjava/src/test/java/rx/schedulers/AbstractSchedulerTests.java +++ b/rxjava/src/test/java/rx/schedulers/AbstractSchedulerTests.java @@ -112,13 +112,13 @@ public void call() { @Test public final void testNestedScheduling() { - Observable ids = Observable.from(Arrays.asList(1, 2), getScheduler()); + Observable ids = Observable.from(Arrays.asList(1, 2)).subscribeOn(getScheduler()); Observable m = ids.flatMap(new Func1>() { @Override public Observable call(Integer id) { - return Observable.from(Arrays.asList("a-" + id, "b-" + id), getScheduler()) + return Observable.from(Arrays.asList("a-" + id, "b-" + id)).subscribeOn(getScheduler()) .map(new Func1() { @Override @@ -406,7 +406,7 @@ public final void testSubscribeOnNestedConcurrency() throws InterruptedException final Scheduler scheduler = getScheduler(); Observable o = Observable.just("one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten") - .mergeMap(new Func1>() { + .flatMap(new Func1>() { @Override public Observable call(final String v) { From 22048a3b89112a924ece815eb9531fd8b1bea1c1 Mon Sep 17 00:00:00 2001 From: Ben Christensen Date: Thu, 21 Aug 2014 14:51:58 -0700 Subject: [PATCH 2/2] Remove Deprecated Usage in Contrib Modules --- .../test/java/rx/util/async/AsyncTest.java | 4 +- .../operators/OperatorDeferFutureTest.java | 2 +- .../operators/OperatorForEachFutureTest.java | 4 +- .../src/main/java/rx/Statement.java | 4 +- .../operators/OperatorConditionalsTest.java | 52 +++++++++---------- .../src/test/java/rx/debug/DebugHookTest.java | 2 +- .../rx/joins/operators/OperatorJoinsTest.java | 8 +-- .../math/operators/OperatorAverageTest.java | 24 ++++----- .../rx/math/operators/OperatorMinMaxTest.java | 16 +++--- .../rx/math/operators/OperatorSumTest.java | 24 ++++----- 10 files changed, 70 insertions(+), 70 deletions(-) diff --git a/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/AsyncTest.java b/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/AsyncTest.java index d156ca4ab4..7427e3c2fe 100644 --- a/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/AsyncTest.java +++ b/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/AsyncTest.java @@ -705,7 +705,7 @@ public String call() { return "one"; } }; - assertEquals("one", Async.start(func).toBlockingObservable().single()); + assertEquals("one", Async.start(func).toBlocking().single()); } @Test(expected = RuntimeException.class) @@ -716,7 +716,7 @@ public String call() { throw new RuntimeException("Some error"); } }; - Async.start(func).toBlockingObservable().single(); + Async.start(func).toBlocking().single(); } @Test diff --git a/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorDeferFutureTest.java b/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorDeferFutureTest.java index 2386165ebc..5d79797a3b 100644 --- a/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorDeferFutureTest.java +++ b/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorDeferFutureTest.java @@ -56,7 +56,7 @@ public Observable call() throws Exception { if (!ready.await(1000, TimeUnit.MILLISECONDS)) { throw new IllegalStateException("Not started in time"); } - return Observable.from(1); + return Observable.just(1); } }); } diff --git a/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorForEachFutureTest.java b/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorForEachFutureTest.java index 3075c79942..96a55f4529 100644 --- a/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorForEachFutureTest.java +++ b/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorForEachFutureTest.java @@ -55,7 +55,7 @@ public void testSimple() { final ExecutorService exec = Executors.newCachedThreadPool(); try { - Observable source = Observable.from(1, 2, 3) + Observable source = Observable.just(1, 2, 3) .subscribeOn(Schedulers.computation()); final AtomicInteger sum = new AtomicInteger(); @@ -128,7 +128,7 @@ public void call(Integer t1) { @Test public void testSimpleScheduled() { - Observable source = Observable.from(1, 2, 3) + Observable source = Observable.just(1, 2, 3) .subscribeOn(Schedulers.computation()); final AtomicInteger sum = new AtomicInteger(); diff --git a/rxjava-contrib/rxjava-computation-expressions/src/main/java/rx/Statement.java b/rxjava-contrib/rxjava-computation-expressions/src/main/java/rx/Statement.java index 224d71424e..5948212264 100644 --- a/rxjava-contrib/rxjava-computation-expressions/src/main/java/rx/Statement.java +++ b/rxjava-contrib/rxjava-computation-expressions/src/main/java/rx/Statement.java @@ -74,7 +74,7 @@ public static Observable switchCase(Func0 caseSelector, */ public static Observable switchCase(Func0 caseSelector, Map> mapOfCases, Scheduler scheduler) { - return switchCase(caseSelector, mapOfCases, Observable. empty(scheduler)); + return switchCase(caseSelector, mapOfCases, Observable. empty().subscribeOn(scheduler)); } /** @@ -179,7 +179,7 @@ public static Observable ifThen(Func0 condition, Observable Observable ifThen(Func0 condition, Observable then, Scheduler scheduler) { - return ifThen(condition, then, Observable. empty(scheduler)); + return ifThen(condition, then, Observable. empty().subscribeOn(scheduler)); } /** diff --git a/rxjava-contrib/rxjava-computation-expressions/src/test/java/rx/operators/OperatorConditionalsTest.java b/rxjava-contrib/rxjava-computation-expressions/src/test/java/rx/operators/OperatorConditionalsTest.java index c927a0613c..5319881ab9 100644 --- a/rxjava-contrib/rxjava-computation-expressions/src/test/java/rx/operators/OperatorConditionalsTest.java +++ b/rxjava-contrib/rxjava-computation-expressions/src/test/java/rx/operators/OperatorConditionalsTest.java @@ -184,8 +184,8 @@ void observeSequenceError(Observable source, Class source1 = Observable.from(1, 2, 3); - Observable source2 = Observable.from(4, 5, 6); + Observable source1 = Observable.just(1, 2, 3); + Observable source2 = Observable.just(4, 5, 6); Map> map = new HashMap>(); map.put(1, source1); @@ -200,8 +200,8 @@ public void testSimple() { @Test public void testDefaultCase() { - Observable source1 = Observable.from(1, 2, 3); - Observable source2 = Observable.from(4, 5, 6); + Observable source1 = Observable.just(1, 2, 3); + Observable source2 = Observable.just(4, 5, 6); Map> map = new HashMap>(); map.put(1, source1); @@ -215,7 +215,7 @@ public void testDefaultCase() { @Test public void testCaseSelectorThrows() { - Observable source1 = Observable.from(1, 2, 3); + Observable source1 = Observable.just(1, 2, 3); Map> map = new HashMap>(); map.put(1, source1); @@ -228,8 +228,8 @@ public void testCaseSelectorThrows() { @Test public void testMapGetThrows() { - Observable source1 = Observable.from(1, 2, 3); - Observable source2 = Observable.from(4, 5, 6); + Observable source1 = Observable.just(1, 2, 3); + Observable source2 = Observable.just(4, 5, 6); Map> map = new HashMap>() { private static final long serialVersionUID = -4342868139960216388L; @@ -254,7 +254,7 @@ public Observable get(Object key) { @Test public void testMapContainsKeyThrows() { - Observable source1 = Observable.from(1, 2, 3); + Observable source1 = Observable.just(1, 2, 3); Map> map = new HashMap>() { private static final long serialVersionUID = 1975411728567003983L; @@ -278,7 +278,7 @@ public boolean containsKey(Object key) { @Test public void testChosenObservableThrows() { - Observable source1 = Observable.from(1, 2, 3); + Observable source1 = Observable.just(1, 2, 3); Observable source2 = Observable.error(new RuntimeException("Forced failure")); Map> map = new HashMap>(); @@ -293,7 +293,7 @@ public void testChosenObservableThrows() { @Test public void testIfThen() { - Observable source1 = Observable.from(1, 2, 3); + Observable source1 = Observable.just(1, 2, 3); Observable result = Statement.ifThen(condition, source1); @@ -305,8 +305,8 @@ public void testIfThen() { @Test public void testIfThenElse() { - Observable source1 = Observable.from(1, 2, 3); - Observable source2 = Observable.from(4, 5, 6); + Observable source1 = Observable.just(1, 2, 3); + Observable source2 = Observable.just(4, 5, 6); Observable result = Statement.ifThen(condition, source1, source2); @@ -318,7 +318,7 @@ public void testIfThenElse() { @Test public void testIfThenConditonThrows() { - Observable source1 = Observable.from(1, 2, 3); + Observable source1 = Observable.just(1, 2, 3); Observable result = Statement.ifThen(conditionError, source1); @@ -343,7 +343,7 @@ public void testIfThenObservableThrows() { @Test public void testIfThenElseObservableThrows() { - Observable source1 = Observable.from(1, 2, 3); + Observable source1 = Observable.just(1, 2, 3); Observable source2 = Observable.error(new RuntimeException("Forced failure!")); Observable result = Statement.ifThen(condition, source1, source2); @@ -356,7 +356,7 @@ public void testIfThenElseObservableThrows() { @Test public void testDoWhile() { - Observable source1 = Observable.from(1, 2, 3); + Observable source1 = Observable.just(1, 2, 3); Observable result = Statement.doWhile(source1, condition); @@ -365,7 +365,7 @@ public void testDoWhile() { @Test public void testDoWhileOnce() { - Observable source1 = Observable.from(1, 2, 3); + Observable source1 = Observable.just(1, 2, 3); condition.call(); // toggle to false Observable result = Statement.doWhile(source1, condition); @@ -375,7 +375,7 @@ public void testDoWhileOnce() { @Test public void testDoWhileConditionThrows() { - Observable source1 = Observable.from(1, 2, 3); + Observable source1 = Observable.just(1, 2, 3); Observable result = Statement.doWhile(source1, conditionError); observeError(result, RuntimeException.class, 1, 2, 3); @@ -383,7 +383,7 @@ public void testDoWhileConditionThrows() { @Test public void testDoWhileSourceThrows() { - Observable source1 = Observable.concat(Observable.from(1, 2, 3), + Observable source1 = Observable.concat(Observable.just(1, 2, 3), Observable. error(new RuntimeException("Forced failure!"))); Observable result = Statement.doWhile(source1, condition); @@ -404,7 +404,7 @@ public Boolean call() { @Test public void testDoWhileManyTimes() { - Observable source1 = Observable.from(1, 2, 3).subscribeOn(Schedulers.trampoline()); + Observable source1 = Observable.just(1, 2, 3).subscribeOn(Schedulers.trampoline()); List expected = new ArrayList(numRecursion * 3); for (int i = 0; i < numRecursion; i++) { @@ -420,7 +420,7 @@ public void testDoWhileManyTimes() { @Test public void testWhileDo() { - Observable source1 = Observable.from(1, 2, 3); + Observable source1 = Observable.just(1, 2, 3); Observable result = Statement.whileDo(source1, countdown(2)); observe(result, 1, 2, 3, 1, 2, 3); @@ -428,7 +428,7 @@ public void testWhileDo() { @Test public void testWhileDoOnce() { - Observable source1 = Observable.from(1, 2, 3); + Observable source1 = Observable.just(1, 2, 3); Observable result = Statement.whileDo(source1, countdown(1)); observe(result, 1, 2, 3); @@ -436,7 +436,7 @@ public void testWhileDoOnce() { @Test public void testWhileDoZeroTimes() { - Observable source1 = Observable.from(1, 2, 3); + Observable source1 = Observable.just(1, 2, 3); Observable result = Statement.whileDo(source1, countdown(0)); observe(result); @@ -444,7 +444,7 @@ public void testWhileDoZeroTimes() { @Test public void testWhileDoManyTimes() { - Observable source1 = Observable.from(1, 2, 3).subscribeOn(Schedulers.trampoline()); + Observable source1 = Observable.just(1, 2, 3).subscribeOn(Schedulers.trampoline()); List expected = new ArrayList(numRecursion * 3); for (int i = 0; i < numRecursion; i++) { @@ -460,7 +460,7 @@ public void testWhileDoManyTimes() { @Test public void testWhileDoConditionThrows() { - Observable source1 = Observable.from(1, 2, 3); + Observable source1 = Observable.just(1, 2, 3); Observable result = Statement.whileDo(source1, conditionError); observeError(result, RuntimeException.class, 1, 2, 3); @@ -468,7 +468,7 @@ public void testWhileDoConditionThrows() { @Test public void testWhileDoConditionThrowsImmediately() { - Observable source1 = Observable.from(1, 2, 3); + Observable source1 = Observable.just(1, 2, 3); conditionError.call(); Observable result = Statement.whileDo(source1, conditionError); @@ -477,7 +477,7 @@ public void testWhileDoConditionThrowsImmediately() { @Test public void testWhileDoSourceThrows() { - Observable source1 = Observable.concat(Observable.from(1, 2, 3), + Observable source1 = Observable.concat(Observable.just(1, 2, 3), Observable. error(new RuntimeException("Forced failure!"))); Observable result = Statement.whileDo(source1, condition); diff --git a/rxjava-contrib/rxjava-debug/src/test/java/rx/debug/DebugHookTest.java b/rxjava-contrib/rxjava-debug/src/test/java/rx/debug/DebugHookTest.java index cb1419f3f2..2e4d901c71 100644 --- a/rxjava-contrib/rxjava-debug/src/test/java/rx/debug/DebugHookTest.java +++ b/rxjava-contrib/rxjava-debug/src/test/java/rx/debug/DebugHookTest.java @@ -95,7 +95,7 @@ public void testSimple() { final DebugHook hook = new DebugHook(listener); RxJavaPlugins.getInstance().registerObservableExecutionHook(hook); - Observable.from(1).subscribe(Subscribers.empty()); + Observable.just(1).subscribe(Subscribers.empty()); final InOrder inOrder = inOrder(listener); inOrder.verify(listener).start(subscribe()); diff --git a/rxjava-contrib/rxjava-joins/src/test/java/rx/joins/operators/OperatorJoinsTest.java b/rxjava-contrib/rxjava-joins/src/test/java/rx/joins/operators/OperatorJoinsTest.java index 4d9e01f2a8..73f8cf7a8c 100644 --- a/rxjava-contrib/rxjava-joins/src/test/java/rx/joins/operators/OperatorJoinsTest.java +++ b/rxjava-contrib/rxjava-joins/src/test/java/rx/joins/operators/OperatorJoinsTest.java @@ -386,8 +386,8 @@ public void whenArgumentNull2() { @Test public void whenMultipleSymmetric() { - Observable source1 = Observable.from(1, 2, 3); - Observable source2 = Observable.from(4, 5, 6); + Observable source1 = Observable.just(1, 2, 3); + Observable source2 = Observable.just(4, 5, 6); Observable m = JoinObservable.when(JoinObservable.from(source1).and(source2).then(add)).toObservable(); m.subscribe(observer); @@ -401,8 +401,8 @@ public void whenMultipleSymmetric() { @Test public void whenMultipleAsymSymmetric() { - Observable source1 = Observable.from(1, 2, 3); - Observable source2 = Observable.from(4, 5); + Observable source1 = Observable.just(1, 2, 3); + Observable source2 = Observable.just(4, 5); Observable m = JoinObservable.when(JoinObservable.from(source1).and(source2).then(add)).toObservable(); m.subscribe(observer); diff --git a/rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorAverageTest.java b/rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorAverageTest.java index 938255dc87..2c2a0d756f 100644 --- a/rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorAverageTest.java +++ b/rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorAverageTest.java @@ -47,7 +47,7 @@ public class OperatorAverageTest { @Test public void testAverageOfAFewInts() throws Throwable { - Observable src = Observable.from(1, 2, 3, 4, 6); + Observable src = Observable.just(1, 2, 3, 4, 6); averageInteger(src).subscribe(w); verify(w, times(1)).onNext(anyInt()); @@ -68,7 +68,7 @@ public void testEmptyAverage() throws Throwable { @Test public void testAverageOfAFewLongs() throws Throwable { - Observable src = Observable.from(1L, 2L, 3L, 4L, 6L); + Observable src = Observable.just(1L, 2L, 3L, 4L, 6L); averageLong(src).subscribe(wl); verify(wl, times(1)).onNext(anyLong()); @@ -89,7 +89,7 @@ public void testEmptyAverageLongs() throws Throwable { @Test public void testAverageOfAFewFloats() throws Throwable { - Observable src = Observable.from(1.0f, 2.0f); + Observable src = Observable.just(1.0f, 2.0f); averageFloat(src).subscribe(wf); verify(wf, times(1)).onNext(anyFloat()); @@ -110,7 +110,7 @@ public void testEmptyAverageFloats() throws Throwable { @Test public void testAverageOfAFewDoubles() throws Throwable { - Observable src = Observable.from(1.0d, 2.0d); + Observable src = Observable.just(1.0d, 2.0d); averageDouble(src).subscribe(wd); verify(wd, times(1)).onNext(anyDouble()); @@ -143,7 +143,7 @@ void testValue(Observer o, N value) { @Test public void testIntegerAverageSelector() { - Observable source = Observable.from("a", "bb", "ccc", "dddd"); + Observable source = Observable.just("a", "bb", "ccc", "dddd"); Func1 length = new Func1() { @Override public Integer call(String t1) { @@ -161,7 +161,7 @@ public Integer call(String t1) { @Test public void testLongAverageSelector() { - Observable source = Observable.from("a", "bb", "ccc", "dddd"); + Observable source = Observable.just("a", "bb", "ccc", "dddd"); Func1 length = new Func1() { @Override public Long call(String t1) { @@ -179,7 +179,7 @@ public Long call(String t1) { @Test public void testFloatAverageSelector() { - Observable source = Observable.from("a", "bb", "ccc", "dddd"); + Observable source = Observable.just("a", "bb", "ccc", "dddd"); Func1 length = new Func1() { @Override public Float call(String t1) { @@ -197,7 +197,7 @@ public Float call(String t1) { @Test public void testDoubleAverageSelector() { - Observable source = Observable.from("a", "bb", "ccc", "dddd"); + Observable source = Observable.just("a", "bb", "ccc", "dddd"); Func1 length = new Func1() { @Override public Double call(String t1) { @@ -287,7 +287,7 @@ public Double call(String t1) { @Test public void testIntegerAverageSelectorThrows() { - Observable source = Observable.from("a"); + Observable source = Observable.just("a"); Func1 length = new Func1() { @Override public Integer call(String t1) { @@ -305,7 +305,7 @@ public Integer call(String t1) { @Test public void testLongAverageSelectorThrows() { - Observable source = Observable.from("a"); + Observable source = Observable.just("a"); Func1 length = new Func1() { @Override public Long call(String t1) { @@ -323,7 +323,7 @@ public Long call(String t1) { @Test public void testFloatAverageSelectorThrows() { - Observable source = Observable.from("a"); + Observable source = Observable.just("a"); Func1 length = new Func1() { @Override public Float call(String t1) { @@ -341,7 +341,7 @@ public Float call(String t1) { @Test public void testDoubleAverageSelectorThrows() { - Observable source = Observable.from("a"); + Observable source = Observable.just("a"); Func1 length = new Func1() { @Override public Double call(String t1) { diff --git a/rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorMinMaxTest.java b/rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorMinMaxTest.java index 3445b237fc..4959701821 100644 --- a/rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorMinMaxTest.java +++ b/rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorMinMaxTest.java @@ -35,7 +35,7 @@ public class OperatorMinMaxTest { @Test public void testMin() { - Observable observable = min(Observable.from(2, 3, 1, 4)); + Observable observable = min(Observable.just(2, 3, 1, 4)); @SuppressWarnings("unchecked") Observer observer = (Observer) mock(Observer.class); @@ -63,7 +63,7 @@ public void testMinWithEmpty() { @Test public void testMinWithComparator() { - Observable observable = min(Observable.from(2, 3, 1, 4), + Observable observable = min(Observable.just(2, 3, 1, 4), new Comparator() { @Override public int compare(Integer o1, Integer o2) { @@ -104,7 +104,7 @@ public int compare(Integer o1, Integer o2) { @Test public void testMinBy() { Observable> observable = minBy( - Observable.from("1", "2", "3", "4", "5", "6"), + Observable.just("1", "2", "3", "4", "5", "6"), new Func1() { @Override public Integer call(String t1) { @@ -145,7 +145,7 @@ public Integer call(String t1) { @Test public void testMinByWithComparator() { Observable> observable = minBy( - Observable.from("1", "2", "3", "4", "5", "6"), + Observable.just("1", "2", "3", "4", "5", "6"), new Func1() { @Override public Integer call(String t1) { @@ -195,7 +195,7 @@ public int compare(Integer o1, Integer o2) { @Test public void testMax() { - Observable observable = max(Observable.from(2, 3, 1, 4)); + Observable observable = max(Observable.just(2, 3, 1, 4)); @SuppressWarnings("unchecked") Observer observer = (Observer) mock(Observer.class); @@ -223,7 +223,7 @@ public void testMaxWithEmpty() { @Test public void testMaxWithComparator() { - Observable observable = max(Observable.from(2, 3, 1, 4), + Observable observable = max(Observable.just(2, 3, 1, 4), new Comparator() { @Override public int compare(Integer o1, Integer o2) { @@ -264,7 +264,7 @@ public int compare(Integer o1, Integer o2) { @Test public void testMaxBy() { Observable> observable = maxBy( - Observable.from("1", "2", "3", "4", "5", "6"), + Observable.just("1", "2", "3", "4", "5", "6"), new Func1() { @Override public Integer call(String t1) { @@ -305,7 +305,7 @@ public Integer call(String t1) { @Test public void testMaxByWithComparator() { Observable> observable = maxBy( - Observable.from("1", "2", "3", "4", "5", "6"), + Observable.just("1", "2", "3", "4", "5", "6"), new Func1() { @Override public Integer call(String t1) { diff --git a/rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorSumTest.java b/rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorSumTest.java index b3e4fc9e20..ace50c181b 100644 --- a/rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorSumTest.java +++ b/rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorSumTest.java @@ -39,7 +39,7 @@ public class OperatorSumTest { @Test public void testSumOfAFewInts() throws Throwable { - Observable src = Observable.from(1, 2, 3, 4, 5); + Observable src = Observable.just(1, 2, 3, 4, 5); sumIntegers(src).subscribe(w); verify(w, times(1)).onNext(anyInt()); @@ -61,7 +61,7 @@ public void testEmptySum() throws Throwable { @Test public void testSumOfAFewLongs() throws Throwable { - Observable src = Observable.from(1L, 2L, 3L, 4L, 5L); + Observable src = Observable.just(1L, 2L, 3L, 4L, 5L); sumLongs(src).subscribe(wl); verify(wl, times(1)).onNext(anyLong()); @@ -83,7 +83,7 @@ public void testEmptySumLongs() throws Throwable { @Test public void testSumOfAFewFloats() throws Throwable { - Observable src = Observable.from(1.0f); + Observable src = Observable.just(1.0f); sumFloats(src).subscribe(wf); verify(wf, times(1)).onNext(anyFloat()); @@ -105,7 +105,7 @@ public void testEmptySumFloats() throws Throwable { @Test public void testSumOfAFewDoubles() throws Throwable { - Observable src = Observable.from(0.0d, 1.0d, 0.5d); + Observable src = Observable.just(0.0d, 1.0d, 0.5d); sumDoubles(src).subscribe(wd); verify(wd, times(1)).onNext(anyDouble()); @@ -139,7 +139,7 @@ void testValue(Observer o, N value) { @Test public void testIntegerSumSelector() { - Observable source = Observable.from("a", "bb", "ccc", "dddd"); + Observable source = Observable.just("a", "bb", "ccc", "dddd"); Func1 length = new Func1() { @Override public Integer call(String t1) { @@ -157,7 +157,7 @@ public Integer call(String t1) { @Test public void testLongSumSelector() { - Observable source = Observable.from("a", "bb", "ccc", "dddd"); + Observable source = Observable.just("a", "bb", "ccc", "dddd"); Func1 length = new Func1() { @Override public Long call(String t1) { @@ -175,7 +175,7 @@ public Long call(String t1) { @Test public void testFloatSumSelector() { - Observable source = Observable.from("a", "bb", "ccc", "dddd"); + Observable source = Observable.just("a", "bb", "ccc", "dddd"); Func1 length = new Func1() { @Override public Float call(String t1) { @@ -193,7 +193,7 @@ public Float call(String t1) { @Test public void testDoubleSumSelector() { - Observable source = Observable.from("a", "bb", "ccc", "dddd"); + Observable source = Observable.just("a", "bb", "ccc", "dddd"); Func1 length = new Func1() { @Override public Double call(String t1) { @@ -283,7 +283,7 @@ public Double call(String t1) { @Test public void testIntegerSumSelectorThrows() { - Observable source = Observable.from("a"); + Observable source = Observable.just("a"); Func1 length = new Func1() { @Override public Integer call(String t1) { @@ -301,7 +301,7 @@ public Integer call(String t1) { @Test public void testLongSumSelectorThrows() { - Observable source = Observable.from("a"); + Observable source = Observable.just("a"); Func1 length = new Func1() { @Override public Long call(String t1) { @@ -319,7 +319,7 @@ public Long call(String t1) { @Test public void testFloatSumSelectorThrows() { - Observable source = Observable.from("a"); + Observable source = Observable.just("a"); Func1 length = new Func1() { @Override public Float call(String t1) { @@ -337,7 +337,7 @@ public Float call(String t1) { @Test public void testDoubleSumSelectorThrows() { - Observable source = Observable.from("a"); + Observable source = Observable.just("a"); Func1 length = new Func1() { @Override public Double call(String t1) {