From d71b76459b88b5a14d18bd60e77498cdecc5f6f0 Mon Sep 17 00:00:00 2001 From: Ben Christensen Date: Wed, 13 Aug 2014 22:22:48 -0700 Subject: [PATCH] from(T) -> just(T) See https://github.com/Netflix/RxJava/issues/1563 for discussion. --- rxjava-core/src/main/java/rx/Observable.java | 370 ++++++++++++++++-- .../operators/OperatorSequenceEqual.java | 4 +- .../src/test/java/rx/CombineLatestTests.java | 4 +- rxjava-core/src/test/java/rx/ConcatTests.java | 36 +- .../src/test/java/rx/CovarianceTest.java | 6 +- rxjava-core/src/test/java/rx/MergeTests.java | 20 +- .../src/test/java/rx/ObservableDoOnTest.java | 4 +- .../src/test/java/rx/ObservableTests.java | 76 ++-- .../test/java/rx/ObservableWindowTests.java | 2 +- rxjava-core/src/test/java/rx/ReduceTests.java | 8 +- .../src/test/java/rx/StartWithTests.java | 6 +- .../src/test/java/rx/SubscriberTest.java | 6 +- rxjava-core/src/test/java/rx/ZipTests.java | 4 +- .../java/rx/exceptions/ExceptionsTest.java | 4 +- .../java/rx/exceptions/OnNextValueTest.java | 4 +- .../BlockingOperatorToFutureTest.java | 8 +- .../BlockingOperatorToIteratorTest.java | 2 +- .../operators/OnSubscribeCacheTest.java | 2 +- .../OnSubscribeCombineLatestTest.java | 8 +- .../operators/OnSubscribeDeferTest.java | 4 +- .../operators/OnSubscribeDelayTest.java | 4 +- .../internal/operators/OperatorAllTest.java | 4 +- .../internal/operators/OperatorAnyTest.java | 14 +- .../operators/OperatorBufferTest.java | 6 +- .../internal/operators/OperatorCastTest.java | 4 +- .../operators/OperatorConcatTest.java | 4 +- .../operators/OperatorDefaultIfEmptyTest.java | 2 +- .../operators/OperatorDematerializeTest.java | 2 +- .../operators/OperatorDistinctTest.java | 8 +- .../OperatorDistinctUntilChangedTest.java | 8 +- .../operators/OperatorDoOnEachTest.java | 10 +- .../operators/OperatorFilterTest.java | 4 +- .../internal/operators/OperatorFirstTest.java | 26 +- .../operators/OperatorGroupByTest.java | 8 +- .../operators/OperatorGroupByUntilTest.java | 18 +- .../internal/operators/OperatorLastTest.java | 26 +- .../internal/operators/OperatorMapTest.java | 22 +- .../OperatorMergeMaxConcurrentTest.java | 6 +- .../internal/operators/OperatorMergeTest.java | 10 +- .../operators/OperatorObserveOnTest.java | 12 +- .../operators/OperatorOnErrorFlatMapTest.java | 8 +- ...ratorOnErrorResumeNextViaFunctionTest.java | 12 +- ...torOnErrorResumeNextViaObservableTest.java | 4 +- ...nExceptionResumeNextViaObservableTest.java | 10 +- .../operators/OperatorParallelMergeTest.java | 2 +- .../operators/OperatorParallelTest.java | 2 +- .../operators/OperatorReduceTest.java | 12 +- .../operators/OperatorRepeatTest.java | 12 +- .../operators/OperatorReplayTest.java | 2 +- .../internal/operators/OperatorScanTest.java | 6 +- .../operators/OperatorSequenceEqualTest.java | 34 +- .../operators/OperatorSingleTest.java | 24 +- .../operators/OperatorSkipLastTest.java | 4 +- .../internal/operators/OperatorSkipTest.java | 12 +- .../operators/OperatorSkipWhileTest.java | 10 +- .../operators/OperatorSubscribeOnTest.java | 2 +- .../operators/OperatorTakeLastTest.java | 10 +- .../operators/OperatorTakeLastTimedTest.java | 2 +- .../operators/OperatorTakeWhileTest.java | 4 +- .../operators/OperatorTimeoutTests.java | 6 +- .../OperatorTimeoutWithSelectorTest.java | 2 +- .../internal/operators/OperatorToMapTest.java | 12 +- .../operators/OperatorToMultimapTest.java | 16 +- .../OperatorToObservableSortedListTest.java | 6 +- .../operators/OperatorWindowTest.java | 6 +- .../operators/OperatorZipIterableTest.java | 2 +- .../internal/operators/OperatorZipTest.java | 20 +- .../observables/BlockingObservableTest.java | 46 +-- .../AbstractSchedulerConcurrencyTests.java | 2 +- .../rx/schedulers/AbstractSchedulerTests.java | 4 +- .../schedulers/CachedThreadSchedulerTest.java | 4 +- .../schedulers/ComputationSchedulerTests.java | 8 +- .../rx/schedulers/ImmediateSchedulerTest.java | 8 +- .../schedulers/TrampolineSchedulerTest.java | 4 +- .../java/rx/subjects/BehaviorSubjectTest.java | 2 +- .../java/rx/subjects/PublishSubjectTest.java | 2 +- .../java/rx/subjects/ReplaySubjectTest.java | 2 +- .../java/rx/util/AssertObservableTest.java | 6 +- 78 files changed, 698 insertions(+), 408 deletions(-) diff --git a/rxjava-core/src/main/java/rx/Observable.java b/rxjava-core/src/main/java/rx/Observable.java index ce2b764117..7a1777ece7 100644 --- a/rxjava-core/src/main/java/rx/Observable.java +++ b/rxjava-core/src/main/java/rx/Observable.java @@ -821,7 +821,7 @@ public final static Observable concat(ObservableMSDN: Observable.Concat */ public final static Observable concat(Observable t1, Observable t2) { - return concat(from(t1, t2)); + return concat(just(t1, t2)); } /** @@ -846,7 +846,7 @@ public final static Observable concat(Observable t1, Observa * @see MSDN: Observable.Concat */ public final static Observable concat(Observable t1, Observable t2, Observable t3) { - return concat(from(t1, t2, t3)); + return concat(just(t1, t2, t3)); } /** @@ -873,7 +873,7 @@ public final static Observable concat(Observable t1, Observa * @see MSDN: Observable.Concat */ public final static Observable concat(Observable t1, Observable t2, Observable t3, Observable t4) { - return concat(from(t1, t2, t3, t4)); + return concat(just(t1, t2, t3, t4)); } /** @@ -902,7 +902,7 @@ public final static Observable concat(Observable t1, Observa * @see MSDN: Observable.Concat */ public final static Observable concat(Observable t1, Observable t2, Observable t3, Observable t4, Observable t5) { - return concat(from(t1, t2, t3, t4, t5)); + return concat(just(t1, t2, t3, t4, t5)); } /** @@ -933,7 +933,7 @@ public final static Observable concat(Observable t1, Observa * @see MSDN: Observable.Concat */ public final static Observable concat(Observable t1, Observable t2, Observable t3, Observable t4, Observable t5, Observable t6) { - return concat(from(t1, t2, t3, t4, t5, t6)); + return concat(just(t1, t2, t3, t4, t5, t6)); } /** @@ -966,7 +966,7 @@ public final static Observable concat(Observable t1, Observa * @see MSDN: Observable.Concat */ public final static Observable concat(Observable t1, Observable t2, Observable t3, Observable t4, Observable t5, Observable t6, Observable t7) { - return concat(from(t1, t2, t3, t4, t5, t6, t7)); + return concat(just(t1, t2, t3, t4, t5, t6, t7)); } /** @@ -1001,7 +1001,7 @@ public final static Observable concat(Observable t1, Observa * @see MSDN: Observable.Concat */ public final static Observable concat(Observable t1, Observable t2, Observable t3, Observable t4, Observable t5, Observable t6, Observable t7, Observable t8) { - return concat(from(t1, t2, t3, t4, t5, t6, t7, t8)); + return concat(just(t1, t2, t3, t4, t5, t6, t7, t8)); } /** @@ -1038,7 +1038,7 @@ public final static Observable concat(Observable t1, Observa * @see MSDN: Observable.Concat */ public final static Observable concat(Observable t1, Observable t2, Observable t3, Observable t4, Observable t5, Observable t6, Observable t7, Observable t8, Observable t9) { - return concat(from(t1, t2, t3, t4, t5, t6, t7, t8, t9)); + return concat(just(t1, t2, t3, t4, t5, t6, t7, t8, t9)); } /** @@ -1246,6 +1246,7 @@ public final static Observable from(Future future, long time * @see RxJava wiki: from */ public final static Observable from(Future future, Scheduler scheduler) { + // TODO in a future revision the Scheduler will become important because we'll start polling instead of blocking on the Future return create(OnSubscribeToObservableFuture.toObservableFuture(future)).subscribeOn(scheduler); } @@ -1292,7 +1293,9 @@ public final static Observable from(Iterable iterable) { * Scheduler * @see RxJava wiki: from * @see MSDN: Observable.ToObservable + * @deprecated Use subscribeOn to Schedule the work */ + @Deprecated public final static Observable from(Iterable iterable, Scheduler scheduler) { return from(iterable).subscribeOn(scheduler); } @@ -1312,7 +1315,9 @@ public final static Observable from(Iterable iterable, Sched * the type of the item * @return an Observable that emits the item * @see RxJava wiki: from + * @deprecated Use just or item instead */ + @Deprecated public final static Observable from(T t1) { return just(t1); } @@ -1334,7 +1339,9 @@ public final static Observable from(T t1) { * the type of these items * @return an Observable that emits each item * @see RxJava wiki: from + * @deprecated Use items instead */ + @Deprecated // suppress unchecked because we are using varargs inside the method @SuppressWarnings("unchecked") public final static Observable from(T t1, T t2) { @@ -1360,7 +1367,9 @@ public final static Observable from(T t1, T t2) { * the type of these items * @return an Observable that emits each item * @see RxJava wiki: from + * @deprecated Use items 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) { @@ -1388,7 +1397,9 @@ public final static Observable from(T t1, T t2, T t3) { * the type of these items * @return an Observable that emits each item * @see RxJava wiki: from + * @deprecated Use items 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) { @@ -1418,7 +1429,9 @@ public final static Observable from(T t1, T t2, T t3, T t4) { * the type of these items * @return an Observable that emits each item * @see RxJava wiki: from + * @deprecated Use items 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) { @@ -1450,7 +1463,9 @@ public final static Observable from(T t1, T t2, T t3, T t4, T t5) { * the type of these items * @return an Observable that emits each item * @see RxJava wiki: from + * @deprecated Use items 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) { @@ -1484,7 +1499,9 @@ public final static Observable from(T t1, T t2, T t3, T t4, T t5, T t6) { * the type of these items * @return an Observable that emits each item * @see RxJava wiki: from + * @deprecated Use items 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) { @@ -1520,7 +1537,9 @@ public final static Observable from(T t1, T t2, T t3, T t4, T t5, T t6, T * the type of these items * @return an Observable that emits each item * @see RxJava wiki: from + * @deprecated Use items 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) { @@ -1558,7 +1577,9 @@ public final static Observable from(T t1, T t2, T t3, T t4, T t5, T t6, T * the type of these items * @return an Observable that emits each item * @see RxJava wiki: from + * @deprecated Use items 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) { @@ -1598,7 +1619,9 @@ public final static Observable from(T t1, T t2, T t3, T t4, T t5, T t6, T * the type of these items * @return an Observable that emits each item * @see RxJava wiki: from + * @deprecated Use items 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) { @@ -1622,8 +1645,8 @@ public final static Observable from(T t1, T t2, T t3, T t4, T t5, T t6, T * @see RxJava wiki: from * @see MSDN: Observable.ToObservable */ - public final static Observable from(T... t1) { - return from(Arrays.asList(t1)); + public final static Observable from(T[] array) { + return from(Arrays.asList(array)); } /** @@ -1644,7 +1667,9 @@ public final static Observable from(T... t1) { * @return an Observable that emits each item in the source Array * @see RxJava wiki: from * @see MSDN: Observable.ToObservable + * @deprecated Use subscribeOn to Schedule the work */ + @Deprecated public final static Observable from(T[] items, Scheduler scheduler) { return from(Arrays.asList(items), scheduler); } @@ -1721,30 +1746,295 @@ public final static Observable interval(long interval, TimeUnit unit, Sche public final static Observable just(final T value) { return ScalarSynchronousObservable.create(value); } + + /** + * 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 + */ + // suppress unchecked because we are using varargs inside the method + @SuppressWarnings("unchecked") + public final static Observable just(T t1, T t2) { + return from(Arrays.asList(t1, t2)); + } /** - * Returns an Observable that emits a single item and then completes, on a specified Scheduler. + * Converts three items into an Observable that emits those items. *

- * + * *

*
Scheduler:
- *
you specify which {@link Scheduler} this operator will use
+ *
{@code from} does not operate by default on a particular {@link Scheduler}.
*
* - * @param value - * the item to emit + * @param t1 + * first item + * @param t2 + * second item + * @param t3 + * third item * @param - * the type of that item - * @param scheduler - * the Scheduler to emit the single item on - * @return an Observable that emits {@code value} as a single item and then completes, on a specified - * Scheduler - * @see RxJava wiki: just + * the type of these items + * @return an Observable that emits each item + * @see RxJava wiki: from + */ + // suppress unchecked because we are using varargs inside the method + @SuppressWarnings("unchecked") + public final static Observable just(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 + */ + // suppress unchecked because we are using varargs inside the method + @SuppressWarnings("unchecked") + public final static Observable just(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 + */ + // suppress unchecked because we are using varargs inside the method + @SuppressWarnings("unchecked") + public final static Observable just(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 + */ + // suppress unchecked because we are using varargs inside the method + @SuppressWarnings("unchecked") + public final static Observable just(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 + */ + // suppress unchecked because we are using varargs inside the method + @SuppressWarnings("unchecked") + public final static Observable just(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 + */ + // suppress unchecked because we are using varargs inside the method + @SuppressWarnings("unchecked") + public final static Observable just(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 */ - public final static Observable just(T value, Scheduler scheduler) { - return just(value).subscribeOn(scheduler); + // suppress unchecked because we are using varargs inside the method + @SuppressWarnings("unchecked") + public final static Observable just(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 + */ + // suppress unchecked because we are using varargs inside the method + @SuppressWarnings("unchecked") + public final static Observable just(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)); + } + /** * Flattens an Iterable of Observables into one Observable, without any transformation. *

@@ -2265,7 +2555,7 @@ public final static Observable mergeDelayError(ObservableMSDN: Observable.Merge */ public final static Observable mergeDelayError(Observable t1, Observable t2) { - return mergeDelayError(from(t1, t2)); + return mergeDelayError(just(t1, t2)); } /** @@ -2298,7 +2588,7 @@ public final static Observable mergeDelayError(Observable t1 * @see MSDN: Observable.Merge */ public final static Observable mergeDelayError(Observable t1, Observable t2, Observable t3) { - return mergeDelayError(from(t1, t2, t3)); + return mergeDelayError(just(t1, t2, t3)); } /** @@ -2333,7 +2623,7 @@ public final static Observable mergeDelayError(Observable t1 * @see MSDN: Observable.Merge */ public final static Observable mergeDelayError(Observable t1, Observable t2, Observable t3, Observable t4) { - return mergeDelayError(from(t1, t2, t3, t4)); + return mergeDelayError(just(t1, t2, t3, t4)); } /** @@ -2370,7 +2660,7 @@ public final static Observable mergeDelayError(Observable t1 * @see MSDN: Observable.Merge */ public final static Observable mergeDelayError(Observable t1, Observable t2, Observable t3, Observable t4, Observable t5) { - return mergeDelayError(from(t1, t2, t3, t4, t5)); + return mergeDelayError(just(t1, t2, t3, t4, t5)); } /** @@ -2409,7 +2699,7 @@ public final static Observable mergeDelayError(Observable t1 * @see MSDN: Observable.Merge */ public final static Observable mergeDelayError(Observable t1, Observable t2, Observable t3, Observable t4, Observable t5, Observable t6) { - return mergeDelayError(from(t1, t2, t3, t4, t5, t6)); + return mergeDelayError(just(t1, t2, t3, t4, t5, t6)); } /** @@ -2451,7 +2741,7 @@ public final static Observable mergeDelayError(Observable t1 * @see MSDN: Observable.Merge */ public final static Observable mergeDelayError(Observable t1, Observable t2, Observable t3, Observable t4, Observable t5, Observable t6, Observable t7) { - return mergeDelayError(from(t1, t2, t3, t4, t5, t6, t7)); + return mergeDelayError(just(t1, t2, t3, t4, t5, t6, t7)); } /** @@ -2495,7 +2785,7 @@ public final static Observable mergeDelayError(Observable t1 */ // suppress because the types are checked by the method signature before using a vararg public final static Observable mergeDelayError(Observable t1, Observable t2, Observable t3, Observable t4, Observable t5, Observable t6, Observable t7, Observable t8) { - return mergeDelayError(from(t1, t2, t3, t4, t5, t6, t7, t8)); + return mergeDelayError(just(t1, t2, t3, t4, t5, t6, t7, t8)); } /** @@ -2540,7 +2830,7 @@ public final static Observable mergeDelayError(Observable t1 * @see MSDN: Observable.Merge */ public final static Observable mergeDelayError(Observable t1, Observable t2, Observable t3, Observable t4, Observable t5, Observable t6, Observable t7, Observable t8, Observable t9) { - return mergeDelayError(from(t1, t2, t3, t4, t5, t6, t7, t8, t9)); + return mergeDelayError(just(t1, t2, t3, t4, t5, t6, t7, t8, t9)); } /** @@ -7694,7 +7984,7 @@ public final Observable startWith(Iterable values, Scheduler scheduler) { * @see MSDN: Observable.StartWith */ public final Observable startWith(T t1) { - return concat(Observable. from(t1), this); + return concat(just(t1), this); } /** @@ -7717,7 +8007,7 @@ public final Observable startWith(T t1) { * @see MSDN: Observable.StartWith */ public final Observable startWith(T t1, T t2) { - return concat(Observable. from(t1, t2), this); + return concat(just(t1, t2), this); } /** @@ -7742,7 +8032,7 @@ public final Observable startWith(T t1, T t2) { * @see MSDN: Observable.StartWith */ public final Observable startWith(T t1, T t2, T t3) { - return concat(Observable. from(t1, t2, t3), this); + return concat(just(t1, t2, t3), this); } /** @@ -7769,7 +8059,7 @@ public final Observable startWith(T t1, T t2, T t3) { * @see MSDN: Observable.StartWith */ public final Observable startWith(T t1, T t2, T t3, T t4) { - return concat(Observable. from(t1, t2, t3, t4), this); + return concat(just(t1, t2, t3, t4), this); } /** @@ -7798,7 +8088,7 @@ public final Observable startWith(T t1, T t2, T t3, T t4) { * @see MSDN: Observable.StartWith */ public final Observable startWith(T t1, T t2, T t3, T t4, T t5) { - return concat(Observable. from(t1, t2, t3, t4, t5), this); + return concat(just(t1, t2, t3, t4, t5), this); } /** @@ -7829,7 +8119,7 @@ public final Observable startWith(T t1, T t2, T t3, T t4, T t5) { * @see MSDN: Observable.StartWith */ public final Observable startWith(T t1, T t2, T t3, T t4, T t5, T t6) { - return concat(Observable. from(t1, t2, t3, t4, t5, t6), this); + return concat(just(t1, t2, t3, t4, t5, t6), this); } /** @@ -7862,7 +8152,7 @@ public final Observable startWith(T t1, T t2, T t3, T t4, T t5, T t6) { * @see MSDN: Observable.StartWith */ public final Observable startWith(T t1, T t2, T t3, T t4, T t5, T t6, T t7) { - return concat(Observable. from(t1, t2, t3, t4, t5, t6, t7), this); + return concat(just(t1, t2, t3, t4, t5, t6, t7), this); } /** @@ -7897,7 +8187,7 @@ public final Observable startWith(T t1, T t2, T t3, T t4, T t5, T t6, T t7) { * @see MSDN: Observable.StartWith */ public final Observable startWith(T t1, T t2, T t3, T t4, T t5, T t6, T t7, T t8) { - return concat(Observable. from(t1, t2, t3, t4, t5, t6, t7, t8), this); + return concat(just(t1, t2, t3, t4, t5, t6, t7, t8), this); } /** @@ -7934,7 +8224,7 @@ public final Observable startWith(T t1, T t2, T t3, T t4, T t5, T t6, T t7, T * @see MSDN: Observable.StartWith */ public final Observable startWith(T t1, T t2, T t3, T t4, T t5, T t6, T t7, T t8, T t9) { - return concat(Observable. from(t1, t2, t3, t4, t5, t6, t7, t8, t9), this); + return concat(just(t1, t2, t3, t4, t5, t6, t7, t8, t9), this); } /** diff --git a/rxjava-core/src/main/java/rx/internal/operators/OperatorSequenceEqual.java b/rxjava-core/src/main/java/rx/internal/operators/OperatorSequenceEqual.java index 8165d4c2b8..24d32b2cac 100644 --- a/rxjava-core/src/main/java/rx/internal/operators/OperatorSequenceEqual.java +++ b/rxjava-core/src/main/java/rx/internal/operators/OperatorSequenceEqual.java @@ -16,7 +16,7 @@ package rx.internal.operators; import static rx.Observable.concat; -import static rx.Observable.from; +import static rx.Observable.just; import static rx.Observable.zip; import rx.Observable; import rx.functions.Func1; @@ -43,7 +43,7 @@ public Object call(T t1) { return t1; } - }), from(LOCAL_ONCOMPLETED)); + }), just(LOCAL_ONCOMPLETED)); } /** diff --git a/rxjava-core/src/test/java/rx/CombineLatestTests.java b/rxjava-core/src/test/java/rx/CombineLatestTests.java index e8340cc141..19c7301a04 100644 --- a/rxjava-core/src/test/java/rx/CombineLatestTests.java +++ b/rxjava-core/src/test/java/rx/CombineLatestTests.java @@ -33,8 +33,8 @@ public class CombineLatestTests { */ @Test public void testCovarianceOfCombineLatest() { - Observable horrors = Observable.from(new HorrorMovie()); - Observable ratings = Observable.from(new CoolRating()); + Observable horrors = Observable.just(new HorrorMovie()); + Observable ratings = Observable.just(new CoolRating()); Observable. combineLatest(horrors, ratings, combine).toBlocking().forEach(action); Observable. combineLatest(horrors, ratings, combine).toBlocking().forEach(action); diff --git a/rxjava-core/src/test/java/rx/ConcatTests.java b/rxjava-core/src/test/java/rx/ConcatTests.java index ca1737e9e3..8e15164d86 100644 --- a/rxjava-core/src/test/java/rx/ConcatTests.java +++ b/rxjava-core/src/test/java/rx/ConcatTests.java @@ -31,8 +31,8 @@ public class ConcatTests { @Test public void testConcatSimple() { - Observable o1 = Observable.from("one", "two"); - Observable o2 = Observable.from("three", "four"); + Observable o1 = Observable.just("one", "two"); + Observable o2 = Observable.just("three", "four"); List values = Observable.concat(o1, o2).toList().toBlocking().single(); @@ -44,11 +44,11 @@ public void testConcatSimple() { @Test public void testConcatWithObservableOfObservable() { - Observable o1 = Observable.from("one", "two"); - Observable o2 = Observable.from("three", "four"); - Observable o3 = Observable.from("five", "six"); + Observable o1 = Observable.just("one", "two"); + Observable o2 = Observable.just("three", "four"); + Observable o3 = Observable.just("five", "six"); - Observable> os = Observable.from(o1, o2, o3); + Observable> os = Observable.just(o1, o2, o3); List values = Observable.concat(os).toList().toBlocking().single(); @@ -62,9 +62,9 @@ public void testConcatWithObservableOfObservable() { @Test public void testConcatWithIterableOfObservable() { - Observable o1 = Observable.from("one", "two"); - Observable o2 = Observable.from("three", "four"); - Observable o3 = Observable.from("five", "six"); + Observable o1 = Observable.just("one", "two"); + Observable o2 = Observable.just("three", "four"); + Observable o3 = Observable.just("five", "six"); @SuppressWarnings("unchecked") Iterable> is = Arrays.asList(o1, o2, o3); @@ -86,10 +86,10 @@ public void testConcatCovariance() { Media media = new Media(); HorrorMovie horrorMovie2 = new HorrorMovie(); - Observable o1 = Observable. from(horrorMovie1, movie); - Observable o2 = Observable.from(media, horrorMovie2); + Observable o1 = Observable. just(horrorMovie1, movie); + Observable o2 = Observable.just(media, horrorMovie2); - Observable> os = Observable.from(o1, o2); + Observable> os = Observable.just(o1, o2); List values = Observable.concat(os).toList().toBlocking().single(); @@ -108,10 +108,10 @@ public void testConcatCovariance2() { Media media2 = new Media(); HorrorMovie horrorMovie2 = new HorrorMovie(); - Observable o1 = Observable.from(horrorMovie1, movie, media1); - Observable o2 = Observable.from(media2, horrorMovie2); + Observable o1 = Observable.just(horrorMovie1, movie, media1); + Observable o2 = Observable.just(media2, horrorMovie2); - Observable> os = Observable.from(o1, o2); + Observable> os = Observable.just(o1, o2); List values = Observable.concat(os).toList().toBlocking().single(); @@ -130,8 +130,8 @@ public void testConcatCovariance3() { Media media = new Media(); HorrorMovie horrorMovie2 = new HorrorMovie(); - Observable o1 = Observable.from(horrorMovie1, movie); - Observable o2 = Observable.from(media, horrorMovie2); + Observable o1 = Observable.just(horrorMovie1, movie); + Observable o2 = Observable.just(media, horrorMovie2); List values = Observable.concat(o1, o2).toList().toBlocking().single(); @@ -160,7 +160,7 @@ public void call(Subscriber o) { } }); - Observable o2 = Observable.from(media, horrorMovie2); + Observable o2 = Observable.just(media, horrorMovie2); List values = Observable.concat(o1, o2).toList().toBlocking().single(); diff --git a/rxjava-core/src/test/java/rx/CovarianceTest.java b/rxjava-core/src/test/java/rx/CovarianceTest.java index adf3a8c9b8..0318192a94 100644 --- a/rxjava-core/src/test/java/rx/CovarianceTest.java +++ b/rxjava-core/src/test/java/rx/CovarianceTest.java @@ -33,7 +33,7 @@ public class CovarianceTest { */ @Test public void testCovarianceOfFrom() { - Observable. from(new HorrorMovie()); + Observable. just(new HorrorMovie()); Observable. from(new ArrayList()); // Observable.from(new Movie()); // may not compile } @@ -49,11 +49,11 @@ public Integer call(Media t1, Media t2) { }; // this one would work without the covariance generics - Observable o = Observable.from(new Movie(), new TVSeason(), new Album()); + Observable o = Observable.just(new Movie(), new TVSeason(), new Album()); o.toSortedList(SORT_FUNCTION); // this one would NOT work without the covariance generics - Observable o2 = Observable.from(new Movie(), new ActionMovie(), new HorrorMovie()); + Observable o2 = Observable.just(new Movie(), new ActionMovie(), new HorrorMovie()); o2.toSortedList(SORT_FUNCTION); } diff --git a/rxjava-core/src/test/java/rx/MergeTests.java b/rxjava-core/src/test/java/rx/MergeTests.java index aca0cec086..f1501478f6 100644 --- a/rxjava-core/src/test/java/rx/MergeTests.java +++ b/rxjava-core/src/test/java/rx/MergeTests.java @@ -34,17 +34,17 @@ public class MergeTests { */ @Test public void testCovarianceOfMerge() { - Observable horrors = Observable.from(new HorrorMovie()); + Observable horrors = Observable.just(new HorrorMovie()); Observable> metaHorrors = Observable.just(horrors); Observable. merge(metaHorrors); } @Test public void testMergeCovariance() { - Observable o1 = Observable. from(new HorrorMovie(), new Movie()); - Observable o2 = Observable.from(new Media(), new HorrorMovie()); + Observable o1 = Observable. just(new HorrorMovie(), new Movie()); + Observable o2 = Observable.just(new Media(), new HorrorMovie()); - Observable> os = Observable.from(o1, o2); + Observable> os = Observable.just(o1, o2); List values = Observable.merge(os).toList().toBlocking().single(); @@ -53,10 +53,10 @@ public void testMergeCovariance() { @Test public void testMergeCovariance2() { - Observable o1 = Observable.from(new HorrorMovie(), new Movie(), new Media()); - Observable o2 = Observable.from(new Media(), new HorrorMovie()); + Observable o1 = Observable.just(new HorrorMovie(), new Movie(), new Media()); + Observable o2 = Observable.just(new Media(), new HorrorMovie()); - Observable> os = Observable.from(o1, o2); + Observable> os = Observable.just(o1, o2); List values = Observable.merge(os).toList().toBlocking().single(); @@ -65,8 +65,8 @@ public void testMergeCovariance2() { @Test public void testMergeCovariance3() { - Observable o1 = Observable.from(new HorrorMovie(), new Movie()); - Observable o2 = Observable.from(new Media(), new HorrorMovie()); + Observable o1 = Observable.just(new HorrorMovie(), new Movie()); + Observable o2 = Observable.just(new Media(), new HorrorMovie()); List values = Observable.merge(o1, o2).toList().toBlocking().single(); @@ -90,7 +90,7 @@ public void call(Subscriber o) { } }); - Observable o2 = Observable.from(new Media(), new HorrorMovie()); + Observable o2 = Observable.just(new Media(), new HorrorMovie()); List values = Observable.merge(o1, o2).toList().toBlocking().single(); diff --git a/rxjava-core/src/test/java/rx/ObservableDoOnTest.java b/rxjava-core/src/test/java/rx/ObservableDoOnTest.java index 7a39870bdf..0f22e6ecbd 100644 --- a/rxjava-core/src/test/java/rx/ObservableDoOnTest.java +++ b/rxjava-core/src/test/java/rx/ObservableDoOnTest.java @@ -33,7 +33,7 @@ public class ObservableDoOnTest { @Test public void testDoOnEach() { final AtomicReference r = new AtomicReference(); - String output = Observable.from("one").doOnNext(new Action1() { + String output = Observable.just("one").doOnNext(new Action1() { @Override public void call(String v) { @@ -69,7 +69,7 @@ public void call(Throwable v) { @Test public void testDoOnCompleted() { final AtomicBoolean r = new AtomicBoolean(); - String output = Observable.from("one").doOnCompleted(new Action0() { + String output = Observable.just("one").doOnCompleted(new Action0() { @Override public void call() { diff --git a/rxjava-core/src/test/java/rx/ObservableTests.java b/rxjava-core/src/test/java/rx/ObservableTests.java index cdee0440a1..3721b2add6 100644 --- a/rxjava-core/src/test/java/rx/ObservableTests.java +++ b/rxjava-core/src/test/java/rx/ObservableTests.java @@ -96,7 +96,7 @@ public void fromIterable() { @Test public void fromArityArgs3() { - Observable items = Observable.from("one", "two", "three"); + Observable items = Observable.just("one", "two", "three"); assertEquals(new Integer(3), items.count().toBlocking().single()); assertEquals("two", items.skip(1).take(1).toBlocking().single()); @@ -105,7 +105,7 @@ public void fromArityArgs3() { @Test public void fromArityArgs1() { - Observable items = Observable.from("one"); + Observable items = Observable.just("one"); assertEquals(new Integer(1), items.count().toBlocking().single()); assertEquals("one", items.takeLast(1).toBlocking().single()); @@ -138,7 +138,7 @@ public void call(Subscriber Observer) { @Test public void testCountAFewItems() { - Observable observable = Observable.from("a", "b", "c", "d"); + Observable observable = Observable.just("a", "b", "c", "d"); observable.count().subscribe(w); // we should be called only once verify(w, times(1)).onNext(anyInt()); @@ -173,7 +173,7 @@ public void call(Subscriber obsv) { } public void testTakeFirstWithPredicateOfSome() { - Observable observable = Observable.from(1, 3, 5, 4, 6, 3); + Observable observable = Observable.just(1, 3, 5, 4, 6, 3); observable.takeFirst(IS_EVEN).subscribe(w); verify(w, times(1)).onNext(anyInt()); verify(w).onNext(4); @@ -183,7 +183,7 @@ public void testTakeFirstWithPredicateOfSome() { @Test public void testTakeFirstWithPredicateOfNoneMatchingThePredicate() { - Observable observable = Observable.from(1, 3, 5, 7, 9, 7, 5, 3, 1); + Observable observable = Observable.just(1, 3, 5, 7, 9, 7, 5, 3, 1); observable.takeFirst(IS_EVEN).subscribe(w); verify(w, never()).onNext(anyInt()); verify(w, times(1)).onCompleted(); @@ -192,7 +192,7 @@ public void testTakeFirstWithPredicateOfNoneMatchingThePredicate() { @Test public void testTakeFirstOfSome() { - Observable observable = Observable.from(1, 2, 3); + Observable observable = Observable.just(1, 2, 3); observable.take(1).subscribe(w); verify(w, times(1)).onNext(anyInt()); verify(w).onNext(1); @@ -220,7 +220,7 @@ public void testFirstOfNone() { @Test public void testFirstWithPredicateOfNoneMatchingThePredicate() { - Observable observable = Observable.from(1, 3, 5, 7, 9, 7, 5, 3, 1); + Observable observable = Observable.just(1, 3, 5, 7, 9, 7, 5, 3, 1); observable.first(IS_EVEN).subscribe(w); verify(w, never()).onNext(anyInt()); verify(w, never()).onCompleted(); @@ -229,7 +229,7 @@ public void testFirstWithPredicateOfNoneMatchingThePredicate() { @Test public void testReduce() { - Observable observable = Observable.from(1, 2, 3, 4); + Observable observable = Observable.just(1, 2, 3, 4); observable.reduce(new Func2() { @Override @@ -289,7 +289,7 @@ public Integer call(Integer t1, Integer t2) { @Test public void testReduceWithInitialValue() { - Observable observable = Observable.from(1, 2, 3, 4); + Observable observable = Observable.just(1, 2, 3, 4); observable.reduce(50, new Func2() { @Override @@ -820,7 +820,7 @@ public void call(String t1) { public void testTakeWithErrorInObserver() { final AtomicInteger count = new AtomicInteger(); final AtomicReference error = new AtomicReference(); - Observable.from("1", "2", "three", "4").take(3).subscribe(new Subscriber() { + Observable.just("1", "2", "three", "4").take(3).subscribe(new Subscriber() { @Override public void onCompleted() { @@ -852,7 +852,7 @@ public void onNext(String v) { @Test public void testOfType() { - Observable observable = Observable.from(1, "abc", false, 2L).ofType(String.class); + Observable observable = Observable.just(1, "abc", false, 2L).ofType(String.class); @SuppressWarnings("unchecked") Observer observer = mock(Observer.class); @@ -874,7 +874,7 @@ public void testOfTypeWithPolymorphism() { l2.add(2); @SuppressWarnings("rawtypes") - Observable observable = Observable. from(l1, l2, "123").ofType(List.class); + Observable observable = Observable. just(l1, l2, "123").ofType(List.class); @SuppressWarnings("unchecked") Observer observer = mock(Observer.class); @@ -889,7 +889,7 @@ public void testOfTypeWithPolymorphism() { @Test public void testContains() { - Observable observable = Observable.from("a", "b", null).contains("b"); + Observable observable = Observable.just("a", "b", null).contains("b"); @SuppressWarnings("unchecked") Observer observer = mock(Observer.class); @@ -903,7 +903,7 @@ public void testContains() { @Test public void testContainsWithInexistence() { - Observable observable = Observable.from("a", "b", null).contains("c"); + Observable observable = Observable.just("a", "b", null).contains("c"); @SuppressWarnings("unchecked") Observer observer = mock(Observer.class); @@ -917,7 +917,7 @@ public void testContainsWithInexistence() { @Test public void testContainsWithNull() { - Observable observable = Observable.from("a", "b", null).contains(null); + Observable observable = Observable.just("a", "b", null).contains(null); @SuppressWarnings("unchecked") Observer observer = mock(Observer.class); @@ -945,7 +945,7 @@ public void testContainsWithEmptyObservable() { @Test public void testIgnoreElements() { - Observable observable = Observable.from(1, 2, 3).ignoreElements(); + Observable observable = Observable.just(1, 2, 3).ignoreElements(); @SuppressWarnings("unchecked") Observer observer = mock(Observer.class); @@ -956,27 +956,27 @@ public void testIgnoreElements() { } @Test - public void testFromWithScheduler() { - TestScheduler scheduler = new TestScheduler(); - Observable observable = Observable.from(Arrays.asList(1, 2), scheduler); - - @SuppressWarnings("unchecked") - Observer observer = mock(Observer.class); - observable.subscribe(observer); - - scheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS); - - InOrder inOrder = inOrder(observer); - inOrder.verify(observer, times(1)).onNext(1); - inOrder.verify(observer, times(1)).onNext(2); - inOrder.verify(observer, times(1)).onCompleted(); - inOrder.verifyNoMoreInteractions(); - } + public void testJustWithScheduler() { + TestScheduler scheduler = new TestScheduler(); + Observable observable = Observable.from(Arrays.asList(1, 2), scheduler); + + @SuppressWarnings("unchecked") + Observer observer = mock(Observer.class); + observable.subscribe(observer); + + scheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS); + + InOrder inOrder = inOrder(observer); + inOrder.verify(observer, times(1)).onNext(1); + inOrder.verify(observer, times(1)).onNext(2); + inOrder.verify(observer, times(1)).onCompleted(); + inOrder.verifyNoMoreInteractions(); + } @Test public void testStartWithWithScheduler() { TestScheduler scheduler = new TestScheduler(); - Observable observable = Observable.from(3, 4).startWith(Arrays.asList(1, 2), scheduler); + Observable observable = Observable.just(3, 4).startWith(Arrays.asList(1, 2), scheduler); @SuppressWarnings("unchecked") Observer observer = mock(Observer.class); @@ -1015,7 +1015,7 @@ public void testRangeWithScheduler() { @Test public void testCollectToList() { - List list = Observable.from(1, 2, 3).collect(new ArrayList(), new Action2, Integer>() { + List list = Observable.just(1, 2, 3).collect(new ArrayList(), new Action2, Integer>() { @Override public void call(List list, Integer v) { @@ -1031,7 +1031,7 @@ public void call(List list, Integer v) { @Test public void testCollectToString() { - String value = Observable.from(1, 2, 3).collect(new StringBuilder(), new Action2() { + String value = Observable.just(1, 2, 3).collect(new StringBuilder(), new Action2() { @Override public void call(StringBuilder sb, Integer v) { @@ -1068,7 +1068,7 @@ public void testAmbWith() { @Test(expected = OnErrorNotImplementedException.class) public void testSubscribeWithoutOnError() { - Observable o = Observable.from("a", "b").flatMap(new Func1>() { + Observable o = Observable.just("a", "b").flatMap(new Func1>() { @Override public Observable call(String s) { return Observable.error(new Exception("test")); @@ -1083,7 +1083,7 @@ public void testTakeWhileToList() { final AtomicInteger count = new AtomicInteger(); for(final int n: nums) { Observable - .from(Boolean.TRUE, Boolean.FALSE) + .just(Boolean.TRUE, Boolean.FALSE) .takeWhile(new Func1() { @Override public Boolean call(Boolean value) { @@ -1105,7 +1105,7 @@ public void call(List booleans) { @Test public void testCompose() { TestSubscriber ts = new TestSubscriber(); - Observable.from(1, 2, 3).compose(new Transformer() { + Observable.just(1, 2, 3).compose(new Transformer() { @Override public Observable call(Observable t1) { diff --git a/rxjava-core/src/test/java/rx/ObservableWindowTests.java b/rxjava-core/src/test/java/rx/ObservableWindowTests.java index 4b9ac9187d..3833b934a9 100644 --- a/rxjava-core/src/test/java/rx/ObservableWindowTests.java +++ b/rxjava-core/src/test/java/rx/ObservableWindowTests.java @@ -32,7 +32,7 @@ public class ObservableWindowTests { public void testWindow() { final ArrayList> lists = new ArrayList>(); - Observable.concat(Observable.from(1, 2, 3, 4, 5, 6).window(3).map(new Func1, Observable>>() { + Observable.concat(Observable.just(1, 2, 3, 4, 5, 6).window(3).map(new Func1, Observable>>() { @Override public Observable> call(Observable xs) { return xs.toList(); diff --git a/rxjava-core/src/test/java/rx/ReduceTests.java b/rxjava-core/src/test/java/rx/ReduceTests.java index 8fd3b7cefa..908d39003b 100644 --- a/rxjava-core/src/test/java/rx/ReduceTests.java +++ b/rxjava-core/src/test/java/rx/ReduceTests.java @@ -27,7 +27,7 @@ public class ReduceTests { @Test public void reduceInts() { - Observable o = Observable.from(1, 2, 3); + Observable o = Observable.just(1, 2, 3); int value = o.reduce(new Func2() { @Override @@ -42,7 +42,7 @@ public Integer call(Integer t1, Integer t2) { @SuppressWarnings("unused") @Test public void reduceWithObjects() { - Observable horrorMovies = Observable. from(new HorrorMovie()); + Observable horrorMovies = Observable. just(new HorrorMovie()); Func2 chooseSecondMovie = new Func2() { @@ -64,7 +64,7 @@ public Movie call(Movie t1, Movie t2) { @SuppressWarnings("unused") @Test public void reduceWithCovariantObjects() { - Observable horrorMovies = Observable. from(new HorrorMovie()); + Observable horrorMovies = Observable. just(new HorrorMovie()); Func2 chooseSecondMovie = new Func2() { @@ -84,7 +84,7 @@ public Movie call(Movie t1, Movie t2) { @Test public void reduceCovariance() { // must type it to - Observable horrorMovies = Observable. from(new HorrorMovie()); + Observable horrorMovies = Observable. just(new HorrorMovie()); libraryFunctionActingOnMovieObservables(horrorMovies); } diff --git a/rxjava-core/src/test/java/rx/StartWithTests.java b/rxjava-core/src/test/java/rx/StartWithTests.java index f35cc14236..4153ea325b 100644 --- a/rxjava-core/src/test/java/rx/StartWithTests.java +++ b/rxjava-core/src/test/java/rx/StartWithTests.java @@ -26,7 +26,7 @@ public class StartWithTests { @Test public void startWith1() { - List values = Observable.from("one", "two").startWith("zero").toList().toBlocking().single(); + List values = Observable.just("one", "two").startWith("zero").toList().toBlocking().single(); assertEquals("zero", values.get(0)); assertEquals("two", values.get(2)); @@ -37,7 +37,7 @@ public void startWithIterable() { List li = new ArrayList(); li.add("alpha"); li.add("beta"); - List values = Observable.from("one", "two").startWith(li).toList().toBlocking().single(); + List values = Observable.just("one", "two").startWith(li).toList().toBlocking().single(); assertEquals("alpha", values.get(0)); assertEquals("beta", values.get(1)); @@ -50,7 +50,7 @@ public void startWithObservable() { List li = new ArrayList(); li.add("alpha"); li.add("beta"); - List values = Observable.from("one", "two").startWith(Observable.from(li)).toList().toBlocking().single(); + List values = Observable.just("one", "two").startWith(Observable.from(li)).toList().toBlocking().single(); assertEquals("alpha", values.get(0)); assertEquals("beta", values.get(1)); diff --git a/rxjava-core/src/test/java/rx/SubscriberTest.java b/rxjava-core/src/test/java/rx/SubscriberTest.java index 3eae33abe0..f779c19c70 100644 --- a/rxjava-core/src/test/java/rx/SubscriberTest.java +++ b/rxjava-core/src/test/java/rx/SubscriberTest.java @@ -320,7 +320,7 @@ public void request(long n) { @Test public void testOnStartCalledOnceViaSubscribe() { final AtomicInteger c = new AtomicInteger(); - Observable.from(1, 2, 3, 4).take(2).subscribe(new Subscriber() { + Observable.just(1, 2, 3, 4).take(2).subscribe(new Subscriber() { @Override public void onStart() { @@ -352,7 +352,7 @@ public void onNext(Integer t) { @Test public void testOnStartCalledOnceViaUnsafeSubscribe() { final AtomicInteger c = new AtomicInteger(); - Observable.from(1, 2, 3, 4).take(2).unsafeSubscribe(new Subscriber() { + Observable.just(1, 2, 3, 4).take(2).unsafeSubscribe(new Subscriber() { @Override public void onStart() { @@ -384,7 +384,7 @@ public void onNext(Integer t) { @Test public void testOnStartCalledOnceViaLift() { final AtomicInteger c = new AtomicInteger(); - Observable.from(1, 2, 3, 4).lift(new Operator() { + Observable.just(1, 2, 3, 4).lift(new Operator() { @Override public Subscriber call(final Subscriber child) { diff --git a/rxjava-core/src/test/java/rx/ZipTests.java b/rxjava-core/src/test/java/rx/ZipTests.java index 28bf13b9f4..5d35ea94bf 100644 --- a/rxjava-core/src/test/java/rx/ZipTests.java +++ b/rxjava-core/src/test/java/rx/ZipTests.java @@ -86,8 +86,8 @@ public void call(Map v) { */ @Test public void testCovarianceOfZip() { - Observable horrors = Observable.from(new HorrorMovie()); - Observable ratings = Observable.from(new CoolRating()); + Observable horrors = Observable.just(new HorrorMovie()); + Observable ratings = Observable.just(new CoolRating()); Observable. zip(horrors, ratings, combine).toBlocking().forEach(action); Observable. zip(horrors, ratings, combine).toBlocking().forEach(action); diff --git a/rxjava-core/src/test/java/rx/exceptions/ExceptionsTest.java b/rxjava-core/src/test/java/rx/exceptions/ExceptionsTest.java index 75ce52c27e..1ce62cade3 100644 --- a/rxjava-core/src/test/java/rx/exceptions/ExceptionsTest.java +++ b/rxjava-core/src/test/java/rx/exceptions/ExceptionsTest.java @@ -29,7 +29,7 @@ public class ExceptionsTest { @Test(expected = OnErrorNotImplementedException.class) public void testOnErrorNotImplementedIsThrown() { - Observable.from(1, 2, 3).subscribe(new Action1() { + Observable.just(1, 2, 3).subscribe(new Action1() { @Override public void call(Integer t1) { @@ -117,7 +117,7 @@ public void onNext(Integer args) { @Test(expected = ThreadDeath.class) public void testThreadDeathIsThrown() { - Observable.from(1).subscribe(new Observer() { + Observable.just(1).subscribe(new Observer() { @Override public void onCompleted() { diff --git a/rxjava-core/src/test/java/rx/exceptions/OnNextValueTest.java b/rxjava-core/src/test/java/rx/exceptions/OnNextValueTest.java index 37f947445c..b30932256b 100755 --- a/rxjava-core/src/test/java/rx/exceptions/OnNextValueTest.java +++ b/rxjava-core/src/test/java/rx/exceptions/OnNextValueTest.java @@ -80,7 +80,7 @@ public static String stackTraceAsString(Throwable e) { public void addOnNextValueExceptionAdded() throws Exception { Observer observer = new BadToStringObserver(); - Observable.from(new BadToString(false)) + Observable.just(new BadToString(false)) .map(new Func1() { @Override public BadToString call(BadToString badToString) { @@ -94,7 +94,7 @@ public BadToString call(BadToString badToString) { public void addOnNextValueExceptionNotAddedWithBadString() throws Exception { Observer observer = new BadToStringObserver(); - Observable.from(new BadToString(true)) + Observable.just(new BadToString(true)) .map(new Func1() { @Override public BadToString call(BadToString badToString) { diff --git a/rxjava-core/src/test/java/rx/internal/operators/BlockingOperatorToFutureTest.java b/rxjava-core/src/test/java/rx/internal/operators/BlockingOperatorToFutureTest.java index 0d4540dd7d..96edb2ced8 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/BlockingOperatorToFutureTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/BlockingOperatorToFutureTest.java @@ -38,14 +38,14 @@ public class BlockingOperatorToFutureTest { @Test public void testToFuture() throws InterruptedException, ExecutionException { - Observable obs = Observable.from("one"); + Observable obs = Observable.just("one"); Future f = toFuture(obs); assertEquals("one", f.get()); } @Test public void testToFutureList() throws InterruptedException, ExecutionException { - Observable obs = Observable.from("one", "two", "three"); + Observable obs = Observable.just("one", "two", "three"); Future> f = toFuture(obs.toList()); assertEquals("one", f.get().get(0)); assertEquals("two", f.get().get(1)); @@ -54,7 +54,7 @@ public void testToFutureList() throws InterruptedException, ExecutionException { @Test(expected = IllegalArgumentException.class) public void testExceptionWithMoreThanOneElement() throws Throwable { - Observable obs = Observable.from("one", "two"); + Observable obs = Observable.just("one", "two"); Future f = toFuture(obs); try { // we expect an exception since there are more than 1 element @@ -127,7 +127,7 @@ public void testGetWithEmptyObservable() throws Throwable { @Test public void testGetWithASingleNullItem() throws Exception { - Observable obs = Observable.from((String)null); + Observable obs = Observable.just((String)null); Future f = obs.toBlocking().toFuture(); assertEquals(null, f.get()); } diff --git a/rxjava-core/src/test/java/rx/internal/operators/BlockingOperatorToIteratorTest.java b/rxjava-core/src/test/java/rx/internal/operators/BlockingOperatorToIteratorTest.java index 2ae711b482..db92042f1a 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/BlockingOperatorToIteratorTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/BlockingOperatorToIteratorTest.java @@ -31,7 +31,7 @@ public class BlockingOperatorToIteratorTest { @Test public void testToIterator() { - Observable obs = Observable.from("one", "two", "three"); + Observable obs = Observable.just("one", "two", "three"); Iterator it = toIterator(obs); diff --git a/rxjava-core/src/test/java/rx/internal/operators/OnSubscribeCacheTest.java b/rxjava-core/src/test/java/rx/internal/operators/OnSubscribeCacheTest.java index e6a053ee91..e45496bd32 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OnSubscribeCacheTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OnSubscribeCacheTest.java @@ -96,7 +96,7 @@ public void call(String v) { } private void testWithCustomSubjectAndRepeat(Subject subject, Integer... expected) { - Observable source0 = Observable.from(1, 2, 3) + Observable source0 = Observable.just(1, 2, 3) .subscribeOn(Schedulers.io()) .flatMap(new Func1>() { @Override diff --git a/rxjava-core/src/test/java/rx/internal/operators/OnSubscribeCombineLatestTest.java b/rxjava-core/src/test/java/rx/internal/operators/OnSubscribeCombineLatestTest.java index dbb883adb9..eef3b40108 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OnSubscribeCombineLatestTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OnSubscribeCombineLatestTest.java @@ -198,7 +198,7 @@ public void testCombineLatest2Types() { /* define a Observer to receive aggregated events */ Observer observer = mock(Observer.class); - Observable w = Observable.combineLatest(Observable.from("one", "two"), Observable.from(2, 3, 4), combineLatestFunction); + Observable w = Observable.combineLatest(Observable.just("one", "two"), Observable.just(2, 3, 4), combineLatestFunction); w.subscribe(observer); verify(observer, never()).onError(any(Throwable.class)); @@ -217,7 +217,7 @@ public void testCombineLatest3TypesA() { /* define a Observer to receive aggregated events */ Observer observer = mock(Observer.class); - Observable w = Observable.combineLatest(Observable.from("one", "two"), Observable.from(2), Observable.from(new int[] { 4, 5, 6 }), combineLatestFunction); + Observable w = Observable.combineLatest(Observable.just("one", "two"), Observable.just(2), Observable.just(new int[] { 4, 5, 6 }), combineLatestFunction); w.subscribe(observer); verify(observer, never()).onError(any(Throwable.class)); @@ -234,7 +234,7 @@ public void testCombineLatest3TypesB() { /* define a Observer to receive aggregated events */ Observer observer = mock(Observer.class); - Observable w = Observable.combineLatest(Observable.from("one"), Observable.from(2), Observable.from(new int[] { 4, 5, 6 }, new int[] { 7, 8 }), combineLatestFunction); + Observable w = Observable.combineLatest(Observable.just("one"), Observable.just(2), Observable.just(new int[] { 4, 5, 6 }, new int[] { 7, 8 }), combineLatestFunction); w.subscribe(observer); verify(observer, never()).onError(any(Throwable.class)); @@ -510,7 +510,7 @@ public List call(Object... args) { List> sources = new ArrayList>(); List values = new ArrayList(); for (int j = 0; j < i; j++) { - sources.add(Observable.just(j, Schedulers.io())); + sources.add(Observable.just(j).subscribeOn(Schedulers.io())); values.add(j); } diff --git a/rxjava-core/src/test/java/rx/internal/operators/OnSubscribeDeferTest.java b/rxjava-core/src/test/java/rx/internal/operators/OnSubscribeDeferTest.java index e43a50398b..dfff5d9381 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OnSubscribeDeferTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OnSubscribeDeferTest.java @@ -38,8 +38,8 @@ public void testDefer() throws Throwable { Func0> factory = mock(Func0.class); - Observable firstObservable = Observable.from("one", "two"); - Observable secondObservable = Observable.from("three", "four"); + Observable firstObservable = Observable.just("one", "two"); + Observable secondObservable = Observable.just("three", "four"); when(factory.call()).thenReturn(firstObservable, secondObservable); Observable deferred = Observable.defer(factory); diff --git a/rxjava-core/src/test/java/rx/internal/operators/OnSubscribeDelayTest.java b/rxjava-core/src/test/java/rx/internal/operators/OnSubscribeDelayTest.java index 6094c936a2..3f28de6d51 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OnSubscribeDelayTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OnSubscribeDelayTest.java @@ -201,7 +201,7 @@ public void testDelayWithMultipleSubscriptions() { @Test public void testDelaySubscription() { - Observable result = Observable.from(1, 2, 3).delaySubscription(100, TimeUnit.MILLISECONDS, scheduler); + Observable result = Observable.just(1, 2, 3).delaySubscription(100, TimeUnit.MILLISECONDS, scheduler); @SuppressWarnings("unchecked") Observer o = mock(Observer.class); @@ -224,7 +224,7 @@ public void testDelaySubscription() { @Test public void testDelaySubscriptionCancelBeforeTime() { - Observable result = Observable.from(1, 2, 3).delaySubscription(100, TimeUnit.MILLISECONDS, scheduler); + Observable result = Observable.just(1, 2, 3).delaySubscription(100, TimeUnit.MILLISECONDS, scheduler); @SuppressWarnings("unchecked") Observer o = mock(Observer.class); diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorAllTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorAllTest.java index 067879629c..e5f4f32a7d 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorAllTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorAllTest.java @@ -33,7 +33,7 @@ public class OperatorAllTest { @Test @SuppressWarnings("unchecked") public void testAll() { - Observable obs = Observable.from("one", "two", "six"); + Observable obs = Observable.just("one", "two", "six"); Observer observer = mock(Observer.class); obs.all(new Func1() { @@ -51,7 +51,7 @@ public Boolean call(String s) { @Test @SuppressWarnings("unchecked") public void testNotAll() { - Observable obs = Observable.from("one", "two", "three", "six"); + Observable obs = Observable.just("one", "two", "three", "six"); Observer observer = mock(Observer.class); obs.all(new Func1() { diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorAnyTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorAnyTest.java index 9be6a804fc..700d6370f9 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorAnyTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorAnyTest.java @@ -34,7 +34,7 @@ public class OperatorAnyTest { @Test public void testAnyWithTwoItems() { - Observable w = Observable.from(1, 2); + Observable w = Observable.just(1, 2); Observable observable = w.exists(Functions.alwaysTrue()); @SuppressWarnings("unchecked") @@ -48,7 +48,7 @@ public void testAnyWithTwoItems() { @Test public void testIsEmptyWithTwoItems() { - Observable w = Observable.from(1, 2); + Observable w = Observable.just(1, 2); Observable observable = w.isEmpty(); @SuppressWarnings("unchecked") @@ -62,7 +62,7 @@ public void testIsEmptyWithTwoItems() { @Test public void testAnyWithOneItem() { - Observable w = Observable.from(1); + Observable w = Observable.just(1); Observable observable = w.exists(Functions.alwaysTrue()); @SuppressWarnings("unchecked") @@ -76,7 +76,7 @@ public void testAnyWithOneItem() { @Test public void testIsEmptyWithOneItem() { - Observable w = Observable.from(1); + Observable w = Observable.just(1); Observable observable = w.isEmpty(); @SuppressWarnings("unchecked") @@ -118,7 +118,7 @@ public void testIsEmptyWithEmpty() { @Test public void testAnyWithPredicate1() { - Observable w = Observable.from(1, 2, 3); + Observable w = Observable.just(1, 2, 3); Observable observable = w.exists( new Func1() { @@ -139,7 +139,7 @@ public Boolean call(Integer t1) { @Test public void testExists1() { - Observable w = Observable.from(1, 2, 3); + Observable w = Observable.just(1, 2, 3); Observable observable = w.exists( new Func1() { @@ -160,7 +160,7 @@ public Boolean call(Integer t1) { @Test public void testAnyWithPredicate2() { - Observable w = Observable.from(1, 2, 3); + Observable w = Observable.just(1, 2, 3); Observable observable = w.exists( new Func1() { diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorBufferTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorBufferTest.java index cfa38d425e..85af16ab1d 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorBufferTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorBufferTest.java @@ -315,7 +315,7 @@ public void call(Subscriber observer) { public void testLongTimeAction() throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); LongTimeAction action = new LongTimeAction(latch); - Observable.from(1).buffer(10, TimeUnit.MILLISECONDS, 10) + Observable.just(1).buffer(10, TimeUnit.MILLISECONDS, 10) .subscribe(action); latch.await(); assertFalse(action.fail); @@ -526,7 +526,7 @@ public void bufferWithBOBoundaryThrows() { } @Test(timeout = 2000) public void bufferWithSizeTake1() { - Observable source = Observable.from(1).repeat(); + Observable source = Observable.just(1).repeat(); Observable> result = source.buffer(2).take(1); @@ -542,7 +542,7 @@ public void bufferWithSizeTake1() { @Test(timeout = 2000) public void bufferWithSizeSkipTake1() { - Observable source = Observable.from(1).repeat(); + Observable source = Observable.just(1).repeat(); Observable> result = source.buffer(2, 3).take(1); diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorCastTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorCastTest.java index 873e655c4c..1f18b592c2 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorCastTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorCastTest.java @@ -29,7 +29,7 @@ public class OperatorCastTest { @Test public void testCast() { - Observable source = Observable.from(1, 2); + Observable source = Observable.just(1, 2); Observable observable = source.cast(Integer.class); @SuppressWarnings("unchecked") @@ -44,7 +44,7 @@ public void testCast() { @Test public void testCastWithWrongType() { - Observable source = Observable.from(1, 2); + Observable source = Observable.just(1, 2); Observable observable = source.cast(Boolean.class); @SuppressWarnings("unchecked") diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorConcatTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorConcatTest.java index 8760635a59..168d4bff74 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorConcatTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorConcatTest.java @@ -600,7 +600,7 @@ public void call(Subscriber> s) { if (s.isUnsubscribed()) { return; } - s.onNext(Observable.from(i)); + s.onNext(Observable.just(i)); } s.onCompleted(); } @@ -632,7 +632,7 @@ public void call(Subscriber> s) { if (s.isUnsubscribed()) { return; } - s.onNext(Observable.from(i)); + s.onNext(Observable.just(i)); } s.onCompleted(); } diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorDefaultIfEmptyTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorDefaultIfEmptyTest.java index 47fa356ae1..a180f933e2 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorDefaultIfEmptyTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorDefaultIfEmptyTest.java @@ -31,7 +31,7 @@ public class OperatorDefaultIfEmptyTest { @Test public void testDefaultIfEmpty() { - Observable source = Observable.from(1, 2, 3); + Observable source = Observable.just(1, 2, 3); Observable observable = source.defaultIfEmpty(10); @SuppressWarnings("unchecked") diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorDematerializeTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorDematerializeTest.java index 041190d158..7b805d63c0 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorDematerializeTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorDematerializeTest.java @@ -35,7 +35,7 @@ public class OperatorDematerializeTest { @Test @SuppressWarnings("unchecked") public void testDematerialize1() { - Observable> notifications = Observable.from(1, 2).materialize(); + Observable> notifications = Observable.just(1, 2).materialize(); Observable dematerialize = notifications.dematerialize(); Observer observer = mock(Observer.class); diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorDistinctTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorDistinctTest.java index e7c98ac294..b0f128d29f 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorDistinctTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorDistinctTest.java @@ -78,7 +78,7 @@ public void testDistinctOfNoneWithKeySelector() { @Test public void testDistinctOfNormalSource() { - Observable src = Observable.from("a", "b", "c", "c", "c", "b", "b", "a", "e"); + Observable src = Observable.just("a", "b", "c", "c", "c", "b", "b", "a", "e"); src.distinct().subscribe(w); InOrder inOrder = inOrder(w); @@ -93,7 +93,7 @@ public void testDistinctOfNormalSource() { @Test public void testDistinctOfNormalSourceWithKeySelector() { - Observable src = Observable.from("a", "B", "c", "C", "c", "B", "b", "a", "E"); + Observable src = Observable.just("a", "B", "c", "C", "c", "B", "b", "a", "E"); src.distinct(TO_UPPER_WITH_EXCEPTION).subscribe(w); InOrder inOrder = inOrder(w); @@ -108,7 +108,7 @@ public void testDistinctOfNormalSourceWithKeySelector() { @Test public void testDistinctOfSourceWithNulls() { - Observable src = Observable.from(null, "a", "a", null, null, "b", null); + Observable src = Observable.just(null, "a", "a", null, null, "b", null); src.distinct().subscribe(w); InOrder inOrder = inOrder(w); @@ -122,7 +122,7 @@ public void testDistinctOfSourceWithNulls() { @Test public void testDistinctOfSourceWithExceptionsFromKeySelector() { - Observable src = Observable.from("a", "b", null, "c"); + Observable src = Observable.just("a", "b", null, "c"); src.distinct(TO_UPPER_WITH_EXCEPTION).subscribe(w); InOrder inOrder = inOrder(w); diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorDistinctUntilChangedTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorDistinctUntilChangedTest.java index 40f6567453..fc81a6a906 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorDistinctUntilChangedTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorDistinctUntilChangedTest.java @@ -78,7 +78,7 @@ public void testDistinctUntilChangedOfNoneWithKeySelector() { @Test public void testDistinctUntilChangedOfNormalSource() { - Observable src = Observable.from("a", "b", "c", "c", "c", "b", "b", "a", "e"); + Observable src = Observable.just("a", "b", "c", "c", "c", "b", "b", "a", "e"); src.distinctUntilChanged().subscribe(w); InOrder inOrder = inOrder(w); @@ -95,7 +95,7 @@ public void testDistinctUntilChangedOfNormalSource() { @Test public void testDistinctUntilChangedOfNormalSourceWithKeySelector() { - Observable src = Observable.from("a", "b", "c", "C", "c", "B", "b", "a", "e"); + Observable src = Observable.just("a", "b", "c", "C", "c", "B", "b", "a", "e"); src.distinctUntilChanged(TO_UPPER_WITH_EXCEPTION).subscribe(w); InOrder inOrder = inOrder(w); @@ -112,7 +112,7 @@ public void testDistinctUntilChangedOfNormalSourceWithKeySelector() { @Test public void testDistinctUntilChangedOfSourceWithNulls() { - Observable src = Observable.from(null, "a", "a", null, null, "b", null, null); + Observable src = Observable.just(null, "a", "a", null, null, "b", null, null); src.distinctUntilChanged().subscribe(w); InOrder inOrder = inOrder(w); @@ -128,7 +128,7 @@ public void testDistinctUntilChangedOfSourceWithNulls() { @Test public void testDistinctUntilChangedOfSourceWithExceptionsFromKeySelector() { - Observable src = Observable.from("a", "b", null, "c"); + Observable src = Observable.just("a", "b", null, "c"); src.distinctUntilChanged(TO_UPPER_WITH_EXCEPTION).subscribe(w); InOrder inOrder = inOrder(w); diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorDoOnEachTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorDoOnEachTest.java index 9a5a533bae..7de9f78e25 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorDoOnEachTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorDoOnEachTest.java @@ -48,7 +48,7 @@ public void before() { @Test public void testDoOnEach() { - Observable base = Observable.from("a", "b", "c"); + Observable base = Observable.just("a", "b", "c"); Observable doOnEach = base.doOnEach(sideEffectObserver); doOnEach.subscribe(subscribedObserver); @@ -70,7 +70,7 @@ public void testDoOnEach() { @Test public void testDoOnEachWithError() { - Observable base = Observable.from("one", "fail", "two", "three", "fail"); + Observable base = Observable.just("one", "fail", "two", "three", "fail"); Observable errs = base.map(new Func1() { @Override public String call(String s) { @@ -99,7 +99,7 @@ public String call(String s) { @Test public void testDoOnEachWithErrorInCallback() { - Observable base = Observable.from("one", "two", "fail", "three"); + Observable base = Observable.just("one", "two", "fail", "three"); Observable doOnEach = base.doOnNext(new Action1() { @Override public void call(String s) { @@ -125,7 +125,7 @@ public void testIssue1451Case1() { final AtomicInteger count = new AtomicInteger(); for (final int n : nums) { Observable - .from(Boolean.TRUE, Boolean.FALSE) + .just(Boolean.TRUE, Boolean.FALSE) .takeWhile(new Func1() { @Override public Boolean call(Boolean value) { @@ -151,7 +151,7 @@ public void testIssue1451Case2() { final AtomicInteger count = new AtomicInteger(); for (final int n : nums) { Observable - .from(Boolean.TRUE, Boolean.FALSE, Boolean.FALSE) + .just(Boolean.TRUE, Boolean.FALSE, Boolean.FALSE) .takeWhile(new Func1() { @Override public Boolean call(Boolean value) { diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorFilterTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorFilterTest.java index 86319393cb..529a286e20 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorFilterTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorFilterTest.java @@ -36,7 +36,7 @@ public class OperatorFilterTest { @Test public void testFilter() { - Observable w = Observable.from("one", "two", "three"); + Observable w = Observable.just("one", "two", "three"); Observable observable = w.filter(new Func1() { @Override @@ -60,7 +60,7 @@ public Boolean call(String t1) { */ @Test(timeout = 500) public void testWithBackpressure() throws InterruptedException { - Observable w = Observable.from("one", "two", "three"); + Observable w = Observable.just("one", "two", "three"); Observable o = w.filter(new Func1() { @Override diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorFirstTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorFirstTest.java index 6e9a09b095..cf50224aab 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorFirstTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorFirstTest.java @@ -66,7 +66,7 @@ public void testFirstOrElseOfNone() { @Test public void testFirstOrElseOfSome() { - Observable src = Observable.from("a", "b", "c"); + Observable src = Observable.just("a", "b", "c"); src.firstOrDefault("default").subscribe(w); verify(w, times(1)).onNext(anyString()); @@ -77,7 +77,7 @@ public void testFirstOrElseOfSome() { @Test public void testFirstOrElseWithPredicateOfNoneMatchingThePredicate() { - Observable src = Observable.from("a", "b", "c"); + Observable src = Observable.just("a", "b", "c"); src.firstOrDefault("default", IS_D).subscribe(w); verify(w, times(1)).onNext(anyString()); @@ -88,7 +88,7 @@ public void testFirstOrElseWithPredicateOfNoneMatchingThePredicate() { @Test public void testFirstOrElseWithPredicateOfSome() { - Observable src = Observable.from("a", "b", "c", "d", "e", "f"); + Observable src = Observable.just("a", "b", "c", "d", "e", "f"); src.firstOrDefault("default", IS_D).subscribe(w); verify(w, times(1)).onNext(anyString()); @@ -99,7 +99,7 @@ public void testFirstOrElseWithPredicateOfSome() { @Test public void testFirst() { - Observable observable = Observable.from(1, 2, 3).first(); + Observable observable = Observable.just(1, 2, 3).first(); @SuppressWarnings("unchecked") Observer observer = (Observer) mock(Observer.class); @@ -113,7 +113,7 @@ public void testFirst() { @Test public void testFirstWithOneElement() { - Observable observable = Observable.from(1).first(); + Observable observable = Observable.just(1).first(); @SuppressWarnings("unchecked") Observer observer = (Observer) mock(Observer.class); @@ -141,7 +141,7 @@ public void testFirstWithEmpty() { @Test public void testFirstWithPredicate() { - Observable observable = Observable.from(1, 2, 3, 4, 5, 6) + Observable observable = Observable.just(1, 2, 3, 4, 5, 6) .first(new Func1() { @Override @@ -162,7 +162,7 @@ public Boolean call(Integer t1) { @Test public void testFirstWithPredicateAndOneElement() { - Observable observable = Observable.from(1, 2).first( + Observable observable = Observable.just(1, 2).first( new Func1() { @Override @@ -183,7 +183,7 @@ public Boolean call(Integer t1) { @Test public void testFirstWithPredicateAndEmpty() { - Observable observable = Observable.from(1).first( + Observable observable = Observable.just(1).first( new Func1() { @Override @@ -203,7 +203,7 @@ public Boolean call(Integer t1) { @Test public void testFirstOrDefault() { - Observable observable = Observable.from(1, 2, 3) + Observable observable = Observable.just(1, 2, 3) .firstOrDefault(4); @SuppressWarnings("unchecked") @@ -218,7 +218,7 @@ public void testFirstOrDefault() { @Test public void testFirstOrDefaultWithOneElement() { - Observable observable = Observable.from(1).firstOrDefault(2); + Observable observable = Observable.just(1).firstOrDefault(2); @SuppressWarnings("unchecked") Observer observer = (Observer) mock(Observer.class); @@ -247,7 +247,7 @@ public void testFirstOrDefaultWithEmpty() { @Test public void testFirstOrDefaultWithPredicate() { - Observable observable = Observable.from(1, 2, 3, 4, 5, 6) + Observable observable = Observable.just(1, 2, 3, 4, 5, 6) .firstOrDefault(8, new Func1() { @Override @@ -268,7 +268,7 @@ public Boolean call(Integer t1) { @Test public void testFirstOrDefaultWithPredicateAndOneElement() { - Observable observable = Observable.from(1, 2).firstOrDefault( + Observable observable = Observable.just(1, 2).firstOrDefault( 4, new Func1() { @Override @@ -289,7 +289,7 @@ public Boolean call(Integer t1) { @Test public void testFirstOrDefaultWithPredicateAndEmpty() { - Observable observable = Observable.from(1).firstOrDefault(2, + Observable observable = Observable.just(1).firstOrDefault(2, new Func1() { @Override diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorGroupByTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorGroupByTest.java index 421937554d..9c6599cffd 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorGroupByTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorGroupByTest.java @@ -62,7 +62,7 @@ public Integer call(String s) { @Test public void testGroupBy() { - Observable source = Observable.from("one", "two", "three", "four", "five", "six"); + Observable source = Observable.just("one", "two", "three", "four", "five", "six"); Observable> grouped = source.lift(new OperatorGroupBy(length)); Map> map = toMap(grouped); @@ -75,7 +75,7 @@ public void testGroupBy() { @Test public void testGroupByWithElementSelector() { - Observable source = Observable.from("one", "two", "three", "four", "five", "six"); + Observable source = Observable.just("one", "two", "three", "four", "five", "six"); Observable> grouped = source.lift(new OperatorGroupBy(length, length)); Map> map = toMap(grouped); @@ -88,7 +88,7 @@ public void testGroupByWithElementSelector() { @Test public void testGroupByWithElementSelector2() { - Observable source = Observable.from("one", "two", "three", "four", "five", "six"); + Observable source = Observable.just("one", "two", "three", "four", "five", "six"); Observable> grouped = source.groupBy(length, length); Map> map = toMap(grouped); @@ -111,7 +111,7 @@ public void testEmpty() { @Test public void testError() { - Observable sourceStrings = Observable.from("one", "two", "three", "four", "five", "six"); + Observable sourceStrings = Observable.just("one", "two", "three", "four", "five", "six"); Observable errorSource = Observable.error(new RuntimeException("forced failure")); Observable source = Observable.concat(sourceStrings, errorSource); diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorGroupByUntilTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorGroupByUntilTest.java index 5f17330e1d..1196c04463 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorGroupByUntilTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorGroupByUntilTest.java @@ -151,7 +151,7 @@ public String call(String t1) { @Test public void behaveAsGroupBy() { - Observable source = Observable.from(0, 1, 2, 3, 4, 5, 6); + Observable source = Observable.just(0, 1, 2, 3, 4, 5, 6); Func1, Observable> duration = just(Observable.never()); @@ -183,7 +183,7 @@ public void call(Integer t2) { @Test public void keySelectorThrows() { - Observable source = Observable.from(0, 1, 2, 3, 4, 5, 6); + Observable source = Observable.just(0, 1, 2, 3, 4, 5, 6); Func1, Observable> duration = just(Observable.never()); @@ -201,7 +201,7 @@ public void keySelectorThrows() { @Test public void valueSelectorThrows() { - Observable source = Observable.from(0, 1, 2, 3, 4, 5, 6); + Observable source = Observable.just(0, 1, 2, 3, 4, 5, 6); Func1, Observable> duration = just(Observable.never()); @@ -219,7 +219,7 @@ identity, fail(0), @Test public void durationSelectorThrows() { - Observable source = Observable.from(0, 1, 2, 3, 4, 5, 6); + Observable source = Observable.just(0, 1, 2, 3, 4, 5, 6); Func1, Observable> duration = fail2((Observable) null); @@ -237,7 +237,7 @@ public void durationSelectorThrows() { @Test public void durationThrows() { - Observable source = Observable.from(0, 1, 2, 3, 4, 5, 6); + Observable source = Observable.just(0, 1, 2, 3, 4, 5, 6); Func1, Integer> getkey = new Func1, Integer>() { @@ -269,7 +269,7 @@ public Integer call(GroupedObservable t1) { @Test public void innerEscapeCompleted() { - Observable source = Observable.from(0); + Observable source = Observable.just(0); final AtomicReference> inner = new AtomicReference>(); @@ -293,7 +293,7 @@ public void call(GroupedObservable t1) { @Test public void innerEscapeCompletedTwice() { - Observable source = Observable.from(0); + Observable source = Observable.just(0); final AtomicReference> inner = new AtomicReference>(); @@ -322,7 +322,7 @@ public void call(GroupedObservable t1) { @Test public void innerEscapeError() { - Observable source = Observable.concat(Observable.from(0), Observable. error( + Observable source = Observable.concat(Observable.just(0), Observable. error( new TestException("Forced failure"))); final AtomicReference> inner = new AtomicReference>(); @@ -356,7 +356,7 @@ public void onCompleted() { @Test public void innerEscapeErrorTwice() { - Observable source = Observable.concat(Observable.from(0), Observable. error( + Observable source = Observable.concat(Observable.just(0), Observable. error( new TestException("Forced failure"))); final AtomicReference> inner = new AtomicReference>(); diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorLastTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorLastTest.java index 924083790e..4e4ad834ae 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorLastTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorLastTest.java @@ -34,7 +34,7 @@ public class OperatorLastTest { @Test public void testLastWithElements() { - Observable last = Observable.from(1, 2, 3).last(); + Observable last = Observable.just(1, 2, 3).last(); assertEquals(3, last.toBlocking().single().intValue()); } @@ -46,19 +46,19 @@ public void testLastWithNoElements() { @Test public void testLastMultiSubscribe() { - Observable last = Observable.from(1, 2, 3).last(); + Observable last = Observable.just(1, 2, 3).last(); assertEquals(3, last.toBlocking().single().intValue()); assertEquals(3, last.toBlocking().single().intValue()); } @Test public void testLastViaObservable() { - Observable.from(1, 2, 3).last(); + Observable.just(1, 2, 3).last(); } @Test public void testLast() { - Observable observable = Observable.from(1, 2, 3).last(); + Observable observable = Observable.just(1, 2, 3).last(); @SuppressWarnings("unchecked") Observer observer = (Observer) mock(Observer.class); @@ -72,7 +72,7 @@ public void testLast() { @Test public void testLastWithOneElement() { - Observable observable = Observable.from(1).last(); + Observable observable = Observable.just(1).last(); @SuppressWarnings("unchecked") Observer observer = (Observer) mock(Observer.class); @@ -100,7 +100,7 @@ public void testLastWithEmpty() { @Test public void testLastWithPredicate() { - Observable observable = Observable.from(1, 2, 3, 4, 5, 6) + Observable observable = Observable.just(1, 2, 3, 4, 5, 6) .last(new Func1() { @Override @@ -121,7 +121,7 @@ public Boolean call(Integer t1) { @Test public void testLastWithPredicateAndOneElement() { - Observable observable = Observable.from(1, 2).last( + Observable observable = Observable.just(1, 2).last( new Func1() { @Override @@ -142,7 +142,7 @@ public Boolean call(Integer t1) { @Test public void testLastWithPredicateAndEmpty() { - Observable observable = Observable.from(1).last( + Observable observable = Observable.just(1).last( new Func1() { @Override @@ -162,7 +162,7 @@ public Boolean call(Integer t1) { @Test public void testLastOrDefault() { - Observable observable = Observable.from(1, 2, 3) + Observable observable = Observable.just(1, 2, 3) .lastOrDefault(4); @SuppressWarnings("unchecked") @@ -177,7 +177,7 @@ public void testLastOrDefault() { @Test public void testLastOrDefaultWithOneElement() { - Observable observable = Observable.from(1).lastOrDefault(2); + Observable observable = Observable.just(1).lastOrDefault(2); @SuppressWarnings("unchecked") Observer observer = (Observer) mock(Observer.class); @@ -206,7 +206,7 @@ public void testLastOrDefaultWithEmpty() { @Test public void testLastOrDefaultWithPredicate() { - Observable observable = Observable.from(1, 2, 3, 4, 5, 6) + Observable observable = Observable.just(1, 2, 3, 4, 5, 6) .lastOrDefault(8, new Func1() { @Override @@ -227,7 +227,7 @@ public Boolean call(Integer t1) { @Test public void testLastOrDefaultWithPredicateAndOneElement() { - Observable observable = Observable.from(1, 2).lastOrDefault(4, + Observable observable = Observable.just(1, 2).lastOrDefault(4, new Func1() { @Override @@ -248,7 +248,7 @@ public Boolean call(Integer t1) { @Test public void testLastOrDefaultWithPredicateAndEmpty() { - Observable observable = Observable.from(1).lastOrDefault(2, + Observable observable = Observable.just(1).lastOrDefault(2, new Func1() { @Override diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorMapTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorMapTest.java index 5731330fd8..bf7a83ad7b 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorMapTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorMapTest.java @@ -62,7 +62,7 @@ public void before() { public void testMap() { Map m1 = getMap("One"); Map m2 = getMap("Two"); - Observable> observable = Observable.from(m1, m2); + Observable> observable = Observable.just(m1, m2); Observable m = observable.lift(new OperatorMap, String>(new Func1, String>() { @@ -83,7 +83,7 @@ public String call(Map map) { @Test public void testMapMany() { /* simulate a top-level async call which returns IDs */ - Observable ids = Observable.from(1, 2); + Observable ids = Observable.just(1, 2); /* now simulate the behavior to take those IDs and perform nested async calls based on them */ Observable m = ids.flatMap(new Func1>() { @@ -95,11 +95,11 @@ public Observable call(Integer id) { if (id == 1) { Map m1 = getMap("One"); Map m2 = getMap("Two"); - subObservable = Observable.from(m1, m2); + subObservable = Observable.just(m1, m2); } else { Map m3 = getMap("Three"); Map m4 = getMap("Four"); - subObservable = Observable.from(m3, m4); + subObservable = Observable.just(m3, m4); } /* simulate kicking off the async call and performing a select on it to transform the data */ @@ -126,13 +126,13 @@ public String call(Map map) { public void testMapMany2() { Map m1 = getMap("One"); Map m2 = getMap("Two"); - Observable> observable1 = Observable.from(m1, m2); + Observable> observable1 = Observable.just(m1, m2); Map m3 = getMap("Three"); Map m4 = getMap("Four"); - Observable> observable2 = Observable.from(m3, m4); + Observable> observable2 = Observable.just(m3, m4); - Observable>> observable = Observable.from(observable1, observable2); + Observable>> observable = Observable.just(observable1, observable2); Observable m = observable.flatMap(new Func1>, Observable>() { @@ -161,7 +161,7 @@ public String call(Map map) { @Test public void testMapWithError() { - Observable w = Observable.from("one", "fail", "two", "three", "fail"); + Observable w = Observable.just("one", "fail", "two", "three", "fail"); Observable m = w.lift(new OperatorMap(new Func1() { @Override public String call(String s) { @@ -189,7 +189,7 @@ public void call(Throwable t1) { @Test(expected = IllegalArgumentException.class) public void testMapWithIssue417() { - Observable.from(1).observeOn(Schedulers.computation()) + Observable.just(1).observeOn(Schedulers.computation()) .map(new Func1() { public Integer call(Integer arg0) { throw new IllegalArgumentException("any error"); @@ -202,7 +202,7 @@ public void testMapWithErrorInFuncAndThreadPoolScheduler() throws InterruptedExc // The error will throw in one of threads in the thread pool. // If map does not handle it, the error will disappear. // so map needs to handle the error by itself. - Observable m = Observable.from("one") + Observable m = Observable.just("one") .observeOn(Schedulers.computation()) .map(new Func1() { public String call(String arg0) { @@ -278,7 +278,7 @@ public void call(Subscriber observer) { @Override public Observable call(Object object) { - return Observable.from(object); + return Observable.just(object); } }; diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorMergeMaxConcurrentTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorMergeMaxConcurrentTest.java index e4f8d3a348..be9a04cb7a 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorMergeMaxConcurrentTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorMergeMaxConcurrentTest.java @@ -48,9 +48,9 @@ public void before() { public void testWhenMaxConcurrentIsOne() { for (int i = 0; i < 100; i++) { List> os = new ArrayList>(); - os.add(Observable.from("one", "two", "three", "four", "five").subscribeOn(Schedulers.newThread())); - os.add(Observable.from("one", "two", "three", "four", "five").subscribeOn(Schedulers.newThread())); - os.add(Observable.from("one", "two", "three", "four", "five").subscribeOn(Schedulers.newThread())); + os.add(Observable.just("one", "two", "three", "four", "five").subscribeOn(Schedulers.newThread())); + os.add(Observable.just("one", "two", "three", "four", "five").subscribeOn(Schedulers.newThread())); + os.add(Observable.just("one", "two", "three", "four", "five").subscribeOn(Schedulers.newThread())); List expected = Arrays.asList("one", "two", "three", "four", "five", "one", "two", "three", "four", "five", "one", "two", "three", "four", "five"); Iterator iter = Observable.merge(os, 1).toBlocking().toIterable().iterator(); diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorMergeTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorMergeTest.java index e1b18645f6..69275609cb 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorMergeTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorMergeTest.java @@ -146,7 +146,7 @@ public void call() { public void run() { while (!unsubscribed.get()) { - observer.onNext(Observable.from(1L, 2L)); + observer.onNext(Observable.just(1L, 2L)); } System.out.println("Done looping after unsubscribe: " + unsubscribed.get()); observer.onCompleted(); @@ -751,7 +751,7 @@ public void testBackpressureBothUpstreamAndDownstreamWithRegularObservables() th @Override public Observable call(Integer t1) { - return Observable.from(1, 2, 3); + return Observable.just(1, 2, 3); } }); @@ -792,7 +792,7 @@ public void onNext(Integer t) { public void mergeWithNullValues() { System.out.println("mergeWithNullValues"); TestSubscriber ts = new TestSubscriber(); - Observable.merge(Observable.from(null, "one"), Observable.from("two", null)).subscribe(ts); + Observable.merge(Observable.just(null, "one"), Observable.just("two", null)).subscribe(ts); ts.assertTerminalEvent(); ts.assertNoErrors(); ts.assertReceivedOnNext(Arrays.asList(null, "one", "two", null)); @@ -812,7 +812,7 @@ public void call(Subscriber s) { } }); - Observable.merge(Observable.from(null, "one"), bad).subscribe(ts); + Observable.merge(Observable.just(null, "one"), bad).subscribe(ts); ts.assertNoErrors(); ts.assertReceivedOnNext(Arrays.asList(null, "one", "two")); } @@ -820,7 +820,7 @@ public void call(Subscriber s) { @Test public void mergingNullObservable() { TestSubscriber ts = new TestSubscriber(); - Observable.merge(Observable.from("one"), null).subscribe(ts); + Observable.merge(Observable.just("one"), null).subscribe(ts); ts.assertNoErrors(); ts.assertReceivedOnNext(Arrays.asList("one")); } diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorObserveOnTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorObserveOnTest.java index 4f9938f968..c0313ba392 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorObserveOnTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorObserveOnTest.java @@ -62,7 +62,7 @@ public class OperatorObserveOnTest { @SuppressWarnings("unchecked") public void testObserveOn() { Observer observer = mock(Observer.class); - Observable.from(1, 2, 3).observeOn(Schedulers.immediate()).subscribe(observer); + Observable.just(1, 2, 3).observeOn(Schedulers.immediate()).subscribe(observer); verify(observer, times(1)).onNext(1); verify(observer, times(1)).onNext(2); @@ -73,7 +73,7 @@ public void testObserveOn() { @Test @SuppressWarnings("unchecked") public void testOrdering() throws InterruptedException { - Observable obs = Observable.from("one", null, "two", "three", "four"); + Observable obs = Observable.just("one", null, "two", "three", "four"); Observer observer = mock(Observer.class); @@ -103,7 +103,7 @@ public void testOrdering() throws InterruptedException { @SuppressWarnings("unchecked") public void testThreadName() throws InterruptedException { System.out.println("Main Thread: " + Thread.currentThread().getName()); - Observable obs = Observable.from("one", null, "two", "three", "four"); + Observable obs = Observable.just("one", null, "two", "three", "four"); Observer observer = mock(Observer.class); final String parentThreadName = Thread.currentThread().getName(); @@ -155,7 +155,7 @@ public void call() { public void observeOnTheSameSchedulerTwice() { Scheduler scheduler = Schedulers.immediate(); - Observable o = Observable.from(1, 2, 3); + Observable o = Observable.just(1, 2, 3); Observable o2 = o.observeOn(scheduler); @SuppressWarnings("unchecked") @@ -189,7 +189,7 @@ public void observeSameOnMultipleSchedulers() { TestScheduler scheduler1 = new TestScheduler(); TestScheduler scheduler2 = new TestScheduler(); - Observable o = Observable.from(1, 2, 3); + Observable o = Observable.just(1, 2, 3); Observable o1 = o.observeOn(scheduler1); Observable o2 = o.observeOn(scheduler2); @@ -395,7 +395,7 @@ public void testDelayedErrorDeliveryWhenSafeSubscriberUnsubscribes() { public void testAfterUnsubscribeCalledThenObserverOnNextNeverCalled() { final TestScheduler testScheduler = new TestScheduler(); final Observer observer = mock(Observer.class); - final Subscription subscription = Observable.from(1, 2, 3) + final Subscription subscription = Observable.just(1, 2, 3) .observeOn(testScheduler) .subscribe(observer); subscription.unsubscribe(); diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorOnErrorFlatMapTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorOnErrorFlatMapTest.java index f317c737d9..6acf5c49ee 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorOnErrorFlatMapTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorOnErrorFlatMapTest.java @@ -31,7 +31,7 @@ public class OperatorOnErrorFlatMapTest { @Test public void ignoreErrorsAndContinueEmitting() { TestSubscriber ts = new TestSubscriber(); - Observable.from(1, 2, 3, 4, 5, 6).map(new Func1() { + Observable.just(1, 2, 3, 4, 5, 6).map(new Func1() { @Override public String call(Integer v) { @@ -60,7 +60,7 @@ public Observable call(OnErrorThrowable t) { @Test public void spliceAndContinueEmitting() { TestSubscriber ts = new TestSubscriber(); - Observable.from(1, 2, 3, 4, 5, 6).map(new Func1() { + Observable.just(1, 2, 3, 4, 5, 6).map(new Func1() { @Override public String call(Integer v) { @@ -74,7 +74,7 @@ public String call(Integer v) { @Override public Observable call(OnErrorThrowable t) { - return Observable.from("Error=" + t.getValue()); + return Observable.just("Error=" + t.getValue()); } }).subscribe(ts); @@ -89,7 +89,7 @@ public Observable call(OnErrorThrowable t) { @Test public void testOnErrorFlatMapAfterFlatMap() { TestSubscriber ts = new TestSubscriber(); - Observable.from(1, 2, 3).flatMap(new Func1>() { + Observable.just(1, 2, 3).flatMap(new Func1>() { @Override public Observable call(Integer i) { diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorOnErrorResumeNextViaFunctionTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorOnErrorResumeNextViaFunctionTest.java index 0d0c835490..d25af29886 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorOnErrorResumeNextViaFunctionTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorOnErrorResumeNextViaFunctionTest.java @@ -55,7 +55,7 @@ public void call(Subscriber observer) { @Override public Observable call(Throwable t1) { receivedException.set(t1); - return Observable.from("twoResume", "threeResume"); + return Observable.just("twoResume", "threeResume"); } }; @@ -85,7 +85,7 @@ public void testResumeNextWithAsyncExecution() { @Override public Observable call(Throwable t1) { receivedException.set(t1); - return Observable.from("twoResume", "threeResume"); + return Observable.just("twoResume", "threeResume"); } }; @@ -153,7 +153,7 @@ public Observable call(Throwable t1) { @Test public void testOnErrorResumeReceivesErrorFromPreviousNonProtectedOperator() { TestSubscriber ts = new TestSubscriber(); - Observable.from(1).lift(new Operator() { + Observable.just(1).lift(new Operator() { @Override public Subscriber call(Subscriber t1) { @@ -165,7 +165,7 @@ public Subscriber call(Subscriber t1) { @Override public Observable call(Throwable t1) { if (t1.getMessage().equals("failed")) { - return Observable.from("success"); + return Observable.just("success"); } else { return Observable.error(t1); } @@ -185,7 +185,7 @@ public Observable call(Throwable t1) { @Test public void testOnErrorResumeReceivesErrorFromPreviousNonProtectedOperatorOnNext() { TestSubscriber ts = new TestSubscriber(); - Observable.from(1).lift(new Operator() { + Observable.just(1).lift(new Operator() { @Override public Subscriber call(Subscriber t1) { @@ -214,7 +214,7 @@ public void onNext(Integer t) { @Override public Observable call(Throwable t1) { if (t1.getMessage().equals("failed")) { - return Observable.from("success"); + return Observable.just("success"); } else { return Observable.error(t1); } diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorOnErrorResumeNextViaObservableTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorOnErrorResumeNextViaObservableTest.java index 53af3074b6..38a3a74ea5 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorOnErrorResumeNextViaObservableTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorOnErrorResumeNextViaObservableTest.java @@ -38,7 +38,7 @@ public void testResumeNext() { // Trigger failure on second element TestObservable f = new TestObservable(s, "one", "fail", "two", "three"); Observable w = Observable.create(f); - Observable resume = Observable.from("twoResume", "threeResume"); + Observable resume = Observable.just("twoResume", "threeResume"); Observable observable = w.onErrorResumeNext(resume); @SuppressWarnings("unchecked") @@ -64,7 +64,7 @@ public void testResumeNext() { public void testMapResumeAsyncNext() { Subscription sr = mock(Subscription.class); // Trigger multiple failures - Observable w = Observable.from("one", "fail", "two", "three", "fail"); + Observable w = Observable.just("one", "fail", "two", "three", "fail"); // Resume Observable is async TestObservable f = new TestObservable(sr, "twoResume", "threeResume"); Observable resume = Observable.create(f); diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorOnExceptionResumeNextViaObservableTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorOnExceptionResumeNextViaObservableTest.java index 26d8e781d9..70c6f625f6 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorOnExceptionResumeNextViaObservableTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorOnExceptionResumeNextViaObservableTest.java @@ -38,7 +38,7 @@ public void testResumeNextWithException() { // Trigger failure on second element TestObservable f = new TestObservable("one", "EXCEPTION", "two", "three"); Observable w = Observable.create(f); - Observable resume = Observable.from("twoResume", "threeResume"); + Observable resume = Observable.just("twoResume", "threeResume"); Observable observable = w.onExceptionResumeNext(resume); @SuppressWarnings("unchecked") @@ -66,7 +66,7 @@ public void testResumeNextWithRuntimeException() { // Trigger failure on second element TestObservable f = new TestObservable("one", "RUNTIMEEXCEPTION", "two", "three"); Observable w = Observable.create(f); - Observable resume = Observable.from("twoResume", "threeResume"); + Observable resume = Observable.just("twoResume", "threeResume"); Observable observable = w.onExceptionResumeNext(resume); @SuppressWarnings("unchecked") @@ -94,7 +94,7 @@ public void testThrowablePassesThru() { // Trigger failure on second element TestObservable f = new TestObservable("one", "THROWABLE", "two", "three"); Observable w = Observable.create(f); - Observable resume = Observable.from("twoResume", "threeResume"); + Observable resume = Observable.just("twoResume", "threeResume"); Observable observable = w.onExceptionResumeNext(resume); @SuppressWarnings("unchecked") @@ -122,7 +122,7 @@ public void testErrorPassesThru() { // Trigger failure on second element TestObservable f = new TestObservable("one", "ERROR", "two", "three"); Observable w = Observable.create(f); - Observable resume = Observable.from("twoResume", "threeResume"); + Observable resume = Observable.just("twoResume", "threeResume"); Observable observable = w.onExceptionResumeNext(resume); @SuppressWarnings("unchecked") @@ -148,7 +148,7 @@ public void testErrorPassesThru() { @Test public void testMapResumeAsyncNext() { // Trigger multiple failures - Observable w = Observable.from("one", "fail", "two", "three", "fail"); + Observable w = Observable.just("one", "fail", "two", "three", "fail"); // Resume Observable is async TestObservable f = new TestObservable("twoResume", "threeResume"); Observable resume = Observable.create(f); diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorParallelMergeTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorParallelMergeTest.java index 0131b0f324..19be47724e 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorParallelMergeTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorParallelMergeTest.java @@ -39,7 +39,7 @@ public void testParallelMerge() { PublishSubject p3 = PublishSubject. create(); PublishSubject p4 = PublishSubject. create(); - Observable> fourStreams = Observable.> from(p1, p2, p3, p4); + Observable> fourStreams = Observable.> just(p1, p2, p3, p4); Observable> twoStreams = Observable.parallelMerge(fourStreams, 2); Observable> threeStreams = Observable.parallelMerge(fourStreams, 3); diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorParallelTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorParallelTest.java index 66168297f5..d6a6e1ac79 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorParallelTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorParallelTest.java @@ -93,7 +93,7 @@ public Observable call(Observable o) { @Override public Observable call(Integer t) { - return Observable.from(String.valueOf(t)).delay(100, TimeUnit.MILLISECONDS); + return Observable.just(String.valueOf(t)).delay(100, TimeUnit.MILLISECONDS); } }); diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorReduceTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorReduceTest.java index fa8e9648f2..da9a476966 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorReduceTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorReduceTest.java @@ -53,7 +53,7 @@ public Integer call(Integer t1, Integer t2) { @Test public void testAggregateAsIntSum() { - Observable result = Observable.from(1, 2, 3, 4, 5).reduce(0, sum).map(Functions. identity()); + Observable result = Observable.just(1, 2, 3, 4, 5).reduce(0, sum).map(Functions. identity()); result.subscribe(observer); @@ -64,7 +64,7 @@ public void testAggregateAsIntSum() { @Test public void testAggregateAsIntSumSourceThrows() { - Observable result = Observable.concat(Observable.from(1, 2, 3, 4, 5), + Observable result = Observable.concat(Observable.just(1, 2, 3, 4, 5), Observable. error(new TestException())) .reduce(0, sum).map(Functions. identity()); @@ -84,7 +84,7 @@ public Integer call(Integer t1, Integer t2) { } }; - Observable result = Observable.from(1, 2, 3, 4, 5) + Observable result = Observable.just(1, 2, 3, 4, 5) .reduce(0, sumErr).map(Functions. identity()); result.subscribe(observer); @@ -105,7 +105,7 @@ public Integer call(Integer t1) { } }; - Observable result = Observable.from(1, 2, 3, 4, 5) + Observable result = Observable.just(1, 2, 3, 4, 5) .reduce(0, sum).map(error); result.subscribe(observer); @@ -117,7 +117,7 @@ public Integer call(Integer t1) { @Test public void testBackpressureWithNoInitialValue() throws InterruptedException { - Observable source = Observable.from(1, 2, 3, 4, 5, 6); + Observable source = Observable.just(1, 2, 3, 4, 5, 6); Observable reduced = source.reduce(sum); Integer r = reduced.toBlocking().first(); @@ -126,7 +126,7 @@ public void testBackpressureWithNoInitialValue() throws InterruptedException { @Test public void testBackpressureWithInitialValue() throws InterruptedException { - Observable source = Observable.from(1, 2, 3, 4, 5, 6); + Observable source = Observable.just(1, 2, 3, 4, 5, 6); Observable reduced = source.reduce(0, sum); Integer r = reduced.toBlocking().first(); diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorRepeatTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorRepeatTest.java index 4ccc07ac73..b317c85672 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorRepeatTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorRepeatTest.java @@ -55,14 +55,14 @@ public void call(final Subscriber o) { @Test(timeout = 2000) public void testRepeatTake() { - Observable xs = Observable.from(1, 2); + Observable xs = Observable.just(1, 2); Object[] ys = xs.repeat(Schedulers.newThread()).take(4).toList().toBlocking().last().toArray(); assertArrayEquals(new Object[] { 1, 2, 1, 2 }, ys); } @Test(timeout = 20000) public void testNoStackOverFlow() { - Observable.from(1).repeat(Schedulers.newThread()).take(100000).toBlocking().last(); + Observable.just(1).repeat(Schedulers.newThread()).take(100000).toBlocking().last(); } @Test @@ -103,7 +103,7 @@ public void testRepeatAndTake() { @SuppressWarnings("unchecked") Observer o = mock(Observer.class); - Observable.from(1).repeat().take(10).subscribe(o); + Observable.just(1).repeat().take(10).subscribe(o); verify(o, times(10)).onNext(1); verify(o).onCompleted(); @@ -115,7 +115,7 @@ public void testRepeatLimited() { @SuppressWarnings("unchecked") Observer o = mock(Observer.class); - Observable.from(1).repeat(10).subscribe(o); + Observable.just(1).repeat(10).subscribe(o); verify(o, times(10)).onNext(1); verify(o).onCompleted(); @@ -140,7 +140,7 @@ public void testRepeatZero() { @SuppressWarnings("unchecked") Observer o = mock(Observer.class); - Observable.from(1).repeat(0).subscribe(o); + Observable.just(1).repeat(0).subscribe(o); verify(o).onCompleted(); verify(o, never()).onNext(any()); @@ -152,7 +152,7 @@ public void testRepeatOne() { @SuppressWarnings("unchecked") Observer o = mock(Observer.class); - Observable.from(1).repeat(1).subscribe(o); + Observable.just(1).repeat(1).subscribe(o); verify(o).onCompleted(); verify(o, times(1)).onNext(any()); diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorReplayTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorReplayTest.java index 7fbdd0ea0b..7820aae380 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorReplayTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorReplayTest.java @@ -422,7 +422,7 @@ public void testWindowedReplayError() { @Test public void testSynchronousDisconnect() { final AtomicInteger effectCounter = new AtomicInteger(); - Observable source = Observable.from(1, 2, 3, 4) + Observable source = Observable.just(1, 2, 3, 4) .doOnNext(new Action1() { @Override public void call(Integer v) { diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorScanTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorScanTest.java index cd8cd98e4e..dcd5606794 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorScanTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorScanTest.java @@ -43,7 +43,7 @@ public void testScanIntegersWithInitialValue() { @SuppressWarnings("unchecked") Observer observer = mock(Observer.class); - Observable observable = Observable.from(1, 2, 3); + Observable observable = Observable.just(1, 2, 3); Observable m = observable.scan("", new Func2() { @@ -70,7 +70,7 @@ public void testScanIntegersWithoutInitialValue() { @SuppressWarnings("unchecked") Observer observer = mock(Observer.class); - Observable observable = Observable.from(1, 2, 3); + Observable observable = Observable.just(1, 2, 3); Observable m = observable.scan(new Func2() { @@ -97,7 +97,7 @@ public void testScanIntegersWithoutInitialValueAndOnlyOneValue() { @SuppressWarnings("unchecked") Observer observer = mock(Observer.class); - Observable observable = Observable.from(1); + Observable observable = Observable.just(1); Observable m = observable.scan(new Func2() { diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorSequenceEqualTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorSequenceEqualTest.java index 4d58c54038..e0fa617bb8 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorSequenceEqualTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorSequenceEqualTest.java @@ -33,41 +33,41 @@ public class OperatorSequenceEqualTest { @Test public void test1() { Observable observable = Observable.sequenceEqual( - Observable.from("one", "two", "three"), - Observable.from("one", "two", "three")); + Observable.just("one", "two", "three"), + Observable.just("one", "two", "three")); verifyResult(observable, true); } @Test public void test2() { Observable observable = Observable.sequenceEqual( - Observable.from("one", "two", "three"), - Observable.from("one", "two", "three", "four")); + Observable.just("one", "two", "three"), + Observable.just("one", "two", "three", "four")); verifyResult(observable, false); } @Test public void test3() { Observable observable = Observable.sequenceEqual( - Observable.from("one", "two", "three", "four"), - Observable.from("one", "two", "three")); + Observable.just("one", "two", "three", "four"), + Observable.just("one", "two", "three")); verifyResult(observable, false); } @Test public void testWithError1() { Observable observable = Observable.sequenceEqual( - Observable.concat(Observable.from("one"), + Observable.concat(Observable.just("one"), Observable. error(new TestException())), - Observable.from("one", "two", "three")); + Observable.just("one", "two", "three")); verifyError(observable); } @Test public void testWithError2() { Observable observable = Observable.sequenceEqual( - Observable.from("one", "two", "three"), - Observable.concat(Observable.from("one"), + Observable.just("one", "two", "three"), + Observable.concat(Observable.just("one"), Observable. error(new TestException()))); verifyError(observable); } @@ -75,9 +75,9 @@ public void testWithError2() { @Test public void testWithError3() { Observable observable = Observable.sequenceEqual( - Observable.concat(Observable.from("one"), + Observable.concat(Observable.just("one"), Observable. error(new TestException())), - Observable.concat(Observable.from("one"), + Observable.concat(Observable.just("one"), Observable. error(new TestException()))); verifyError(observable); } @@ -86,14 +86,14 @@ Observable. error(new TestException())), public void testWithEmpty1() { Observable observable = Observable.sequenceEqual( Observable. empty(), - Observable.from("one", "two", "three")); + Observable.just("one", "two", "three")); verifyResult(observable, false); } @Test public void testWithEmpty2() { Observable observable = Observable.sequenceEqual( - Observable.from("one", "two", "three"), + Observable.just("one", "two", "three"), Observable. empty()); verifyResult(observable, false); } @@ -108,21 +108,21 @@ public void testWithEmpty3() { @Test public void testWithNull1() { Observable observable = Observable.sequenceEqual( - Observable.from((String) null), Observable.from("one")); + Observable.just((String) null), Observable.just("one")); verifyResult(observable, false); } @Test public void testWithNull2() { Observable observable = Observable.sequenceEqual( - Observable.from((String) null), Observable.from((String) null)); + Observable.just((String) null), Observable.just((String) null)); verifyResult(observable, true); } @Test public void testWithEqualityError() { Observable observable = Observable.sequenceEqual( - Observable.from("one"), Observable.from("one"), + Observable.just("one"), Observable.just("one"), new Func2() { @Override public Boolean call(String t1, String t2) { diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorSingleTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorSingleTest.java index 6910390a51..aee9accdea 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorSingleTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorSingleTest.java @@ -34,7 +34,7 @@ public class OperatorSingleTest { @Test public void testSingle() { - Observable observable = Observable.from(1).single(); + Observable observable = Observable.just(1).single(); @SuppressWarnings("unchecked") Observer observer = (Observer) mock(Observer.class); @@ -48,7 +48,7 @@ public void testSingle() { @Test public void testSingleWithTooManyElements() { - Observable observable = Observable.from(1, 2).single(); + Observable observable = Observable.just(1, 2).single(); @SuppressWarnings("unchecked") Observer observer = (Observer) mock(Observer.class); @@ -76,7 +76,7 @@ public void testSingleWithEmpty() { @Test public void testSingleWithPredicate() { - Observable observable = Observable.from(1, 2).single( + Observable observable = Observable.just(1, 2).single( new Func1() { @Override @@ -97,7 +97,7 @@ public Boolean call(Integer t1) { @Test public void testSingleWithPredicateAndTooManyElements() { - Observable observable = Observable.from(1, 2, 3, 4).single( + Observable observable = Observable.just(1, 2, 3, 4).single( new Func1() { @Override @@ -118,7 +118,7 @@ public Boolean call(Integer t1) { @Test public void testSingleWithPredicateAndEmpty() { - Observable observable = Observable.from(1).single( + Observable observable = Observable.just(1).single( new Func1() { @Override @@ -138,7 +138,7 @@ public Boolean call(Integer t1) { @Test public void testSingleOrDefault() { - Observable observable = Observable.from(1).singleOrDefault(2); + Observable observable = Observable.just(1).singleOrDefault(2); @SuppressWarnings("unchecked") Observer observer = (Observer) mock(Observer.class); @@ -152,7 +152,7 @@ public void testSingleOrDefault() { @Test public void testSingleOrDefaultWithTooManyElements() { - Observable observable = Observable.from(1, 2).singleOrDefault( + Observable observable = Observable.just(1, 2).singleOrDefault( 3); @SuppressWarnings("unchecked") @@ -182,7 +182,7 @@ public void testSingleOrDefaultWithEmpty() { @Test public void testSingleOrDefaultWithPredicate() { - Observable observable = Observable.from(1, 2).singleOrDefault( + Observable observable = Observable.just(1, 2).singleOrDefault( 4, new Func1() { @Override @@ -203,7 +203,7 @@ public Boolean call(Integer t1) { @Test public void testSingleOrDefaultWithPredicateAndTooManyElements() { - Observable observable = Observable.from(1, 2, 3, 4) + Observable observable = Observable.just(1, 2, 3, 4) .singleOrDefault(6, new Func1() { @Override @@ -224,7 +224,7 @@ public Boolean call(Integer t1) { @Test public void testSingleOrDefaultWithPredicateAndEmpty() { - Observable observable = Observable.from(1).singleOrDefault(2, + Observable observable = Observable.just(1).singleOrDefault(2, new Func1() { @Override @@ -245,7 +245,7 @@ public Boolean call(Integer t1) { @Test public void testSingleWithBackpressure() { - Observable observable = Observable.from(1, 2).single(); + Observable observable = Observable.just(1, 2).single(); Subscriber subscriber = spy(new Subscriber() { @@ -279,7 +279,7 @@ public void onNext(Integer integer) { @Test(timeout = 30000) public void testIssue1527() throws InterruptedException { //https://github.com/Netflix/RxJava/pull/1527 - Observable source = Observable.from(1, 2, 3, 4, 5, 6); + Observable source = Observable.just(1, 2, 3, 4, 5, 6); Observable reduced = source.reduce(new Func2() { @Override public Integer call(Integer i1, Integer i2) { diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorSkipLastTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorSkipLastTest.java index 5d44c93e9b..fb9de98ab9 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorSkipLastTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorSkipLastTest.java @@ -77,7 +77,7 @@ public void testSkipLast2() { @Test public void testSkipLastWithZeroCount() { - Observable w = Observable.from("one", "two"); + Observable w = Observable.just("one", "two"); Observable observable = w.skipLast(0); @SuppressWarnings("unchecked") @@ -116,7 +116,7 @@ public void testSkipLastWithBackpressure() { @Test(expected = IndexOutOfBoundsException.class) public void testSkipLastWithNegativeCount() { - Observable.from("one").skipLast(-1); + Observable.just("one").skipLast(-1); } } diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorSkipTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorSkipTest.java index 1740156098..9f4b75d5a7 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorSkipTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorSkipTest.java @@ -32,7 +32,7 @@ public class OperatorSkipTest { @Test public void testSkipNegativeElements() { - Observable skip = Observable.from("one", "two", "three").lift(new OperatorSkip(-99)); + Observable skip = Observable.just("one", "two", "three").lift(new OperatorSkip(-99)); @SuppressWarnings("unchecked") Observer observer = mock(Observer.class); @@ -47,7 +47,7 @@ public void testSkipNegativeElements() { @Test public void testSkipZeroElements() { - Observable skip = Observable.from("one", "two", "three").lift(new OperatorSkip(0)); + Observable skip = Observable.just("one", "two", "three").lift(new OperatorSkip(0)); @SuppressWarnings("unchecked") Observer observer = mock(Observer.class); @@ -62,7 +62,7 @@ public void testSkipZeroElements() { @Test public void testSkipOneElement() { - Observable skip = Observable.from("one", "two", "three").lift(new OperatorSkip(1)); + Observable skip = Observable.just("one", "two", "three").lift(new OperatorSkip(1)); @SuppressWarnings("unchecked") Observer observer = mock(Observer.class); @@ -77,7 +77,7 @@ public void testSkipOneElement() { @Test public void testSkipTwoElements() { - Observable skip = Observable.from("one", "two", "three").lift(new OperatorSkip(2)); + Observable skip = Observable.just("one", "two", "three").lift(new OperatorSkip(2)); @SuppressWarnings("unchecked") Observer observer = mock(Observer.class); @@ -106,7 +106,7 @@ public void testSkipEmptyStream() { @Test public void testSkipMultipleObservers() { - Observable skip = Observable.from("one", "two", "three").lift(new OperatorSkip(2)); + Observable skip = Observable.just("one", "two", "three").lift(new OperatorSkip(2)); @SuppressWarnings("unchecked") Observer observer1 = mock(Observer.class); @@ -130,7 +130,7 @@ public void testSkipError() { Exception e = new Exception(); - Observable ok = Observable.from("one"); + Observable ok = Observable.just("one"); Observable error = Observable.error(e); Observable skip = Observable.concat(ok, error).lift(new OperatorSkip(100)); diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorSkipWhileTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorSkipWhileTest.java index b531618bc9..ee66d48ba3 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorSkipWhileTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorSkipWhileTest.java @@ -54,7 +54,7 @@ public Boolean call(Integer value, Integer index) { @Test public void testSkipWithIndex() { - Observable src = Observable.from(1, 2, 3, 4, 5); + Observable src = Observable.just(1, 2, 3, 4, 5); src.skipWhileWithIndex(INDEX_LESS_THAN_THREE).subscribe(w); InOrder inOrder = inOrder(w); @@ -75,7 +75,7 @@ public void testSkipEmpty() { @Test public void testSkipEverything() { - Observable src = Observable.from(1, 2, 3, 4, 3, 2, 1); + Observable src = Observable.just(1, 2, 3, 4, 3, 2, 1); src.skipWhile(LESS_THAN_FIVE).subscribe(w); verify(w, never()).onNext(anyInt()); verify(w, never()).onError(any(Throwable.class)); @@ -84,7 +84,7 @@ public void testSkipEverything() { @Test public void testSkipNothing() { - Observable src = Observable.from(5, 3, 1); + Observable src = Observable.just(5, 3, 1); src.skipWhile(LESS_THAN_FIVE).subscribe(w); InOrder inOrder = inOrder(w); @@ -97,7 +97,7 @@ public void testSkipNothing() { @Test public void testSkipSome() { - Observable src = Observable.from(1, 2, 3, 4, 5, 3, 1, 5); + Observable src = Observable.just(1, 2, 3, 4, 5, 3, 1, 5); src.skipWhile(LESS_THAN_FIVE).subscribe(w); InOrder inOrder = inOrder(w); @@ -111,7 +111,7 @@ public void testSkipSome() { @Test public void testSkipError() { - Observable src = Observable.from(1, 2, 42, 5, 3, 1); + Observable src = Observable.just(1, 2, 42, 5, 3, 1); src.skipWhile(LESS_THAN_FIVE).subscribe(w); InOrder inOrder = inOrder(w); diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorSubscribeOnTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorSubscribeOnTest.java index 11ca3d0e91..f767ceebf6 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorSubscribeOnTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorSubscribeOnTest.java @@ -223,7 +223,7 @@ public void onNext(Integer t) { @Test public void testSetProducerSynchronousRequest() { TestSubscriber ts = new TestSubscriber(); - Observable.from(1, 2, 3).lift(new Operator() { + Observable.just(1, 2, 3).lift(new Operator() { @Override public Subscriber call(final Subscriber child) { diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorTakeLastTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorTakeLastTest.java index 13b626bf6e..c411fda40b 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorTakeLastTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorTakeLastTest.java @@ -54,7 +54,7 @@ public void testTakeLastEmpty() { @Test public void testTakeLast1() { - Observable w = Observable.from("one", "two", "three"); + Observable w = Observable.just("one", "two", "three"); Observable take = w.takeLast(2); @SuppressWarnings("unchecked") @@ -70,7 +70,7 @@ public void testTakeLast1() { @Test public void testTakeLast2() { - Observable w = Observable.from("one"); + Observable w = Observable.just("one"); Observable take = w.takeLast(10); @SuppressWarnings("unchecked") @@ -83,7 +83,7 @@ public void testTakeLast2() { @Test public void testTakeLastWithZeroCount() { - Observable w = Observable.from("one"); + Observable w = Observable.just("one"); Observable take = w.takeLast(0); @SuppressWarnings("unchecked") @@ -96,7 +96,7 @@ public void testTakeLastWithZeroCount() { @Test public void testTakeLastWithNull() { - Observable w = Observable.from("one", null, "three"); + Observable w = Observable.just("one", null, "three"); Observable take = w.takeLast(2); @SuppressWarnings("unchecked") @@ -111,7 +111,7 @@ public void testTakeLastWithNull() { @Test(expected = IndexOutOfBoundsException.class) public void testTakeLastWithNegativeCount() { - Observable.from("one").takeLast(-1); + Observable.just("one").takeLast(-1); } @Test diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorTakeLastTimedTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorTakeLastTimedTest.java index 76412ca7cf..800a2cd673 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorTakeLastTimedTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorTakeLastTimedTest.java @@ -37,7 +37,7 @@ public class OperatorTakeLastTimedTest { @Test(expected = IndexOutOfBoundsException.class) public void testTakeLastTimedWithNegativeCount() { - Observable.from("one").takeLast(-1, 1, TimeUnit.SECONDS); + Observable.just("one").takeLast(-1, 1, TimeUnit.SECONDS); } @Test diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorTakeWhileTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorTakeWhileTest.java index eb5a0e0b5c..ac5b8d8d6a 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorTakeWhileTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorTakeWhileTest.java @@ -38,7 +38,7 @@ public class OperatorTakeWhileTest { @Test public void testTakeWhile1() { - Observable w = Observable.from(1, 2, 3); + Observable w = Observable.just(1, 2, 3); Observable take = w.takeWhile(new Func1() { @Override public Boolean call(Integer input) { @@ -88,7 +88,7 @@ public Boolean call(Integer input) { @Test public void testTakeWhile2() { - Observable w = Observable.from("one", "two", "three"); + Observable w = Observable.just("one", "two", "three"); Observable take = w.takeWhileWithIndex(new Func2() { @Override public Boolean call(String input, Integer index) { diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorTimeoutTests.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorTimeoutTests.java index 251207fc91..900a7c3ec2 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorTimeoutTests.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorTimeoutTests.java @@ -135,7 +135,7 @@ public void shouldErrorIfUnderlyingErrors() { @Test public void shouldSwitchToOtherIfOnNextNotWithinTimeout() { - Observable other = Observable.from("a", "b", "c"); + Observable other = Observable.just("a", "b", "c"); Observable source = underlyingSubject.timeout(TIMEOUT, TIME_UNIT, other, testScheduler); @SuppressWarnings("unchecked") @@ -158,7 +158,7 @@ public void shouldSwitchToOtherIfOnNextNotWithinTimeout() { @Test public void shouldSwitchToOtherIfOnErrorNotWithinTimeout() { - Observable other = Observable.from("a", "b", "c"); + Observable other = Observable.just("a", "b", "c"); Observable source = underlyingSubject.timeout(TIMEOUT, TIME_UNIT, other, testScheduler); @SuppressWarnings("unchecked") @@ -181,7 +181,7 @@ public void shouldSwitchToOtherIfOnErrorNotWithinTimeout() { @Test public void shouldSwitchToOtherIfOnCompletedNotWithinTimeout() { - Observable other = Observable.from("a", "b", "c"); + Observable other = Observable.just("a", "b", "c"); Observable source = underlyingSubject.timeout(TIMEOUT, TIME_UNIT, other, testScheduler); @SuppressWarnings("unchecked") diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorTimeoutWithSelectorTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorTimeoutWithSelectorTest.java index 4373dfc7b4..4d2799c12b 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorTimeoutWithSelectorTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorTimeoutWithSelectorTest.java @@ -400,7 +400,7 @@ public Void answer(InvocationOnMock invocation) throws Throwable { @Override public void run() { PublishSubject source = PublishSubject.create(); - source.timeout(timeoutFunc, Observable.from(3)).subscribe(ts); + source.timeout(timeoutFunc, Observable.just(3)).subscribe(ts); source.onNext(1); // start timeout try { if(!enteredTimeoutOne.await(30, TimeUnit.SECONDS)) { diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorToMapTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorToMapTest.java index d58ae8edcf..dec6d80b31 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorToMapTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorToMapTest.java @@ -59,7 +59,7 @@ public String call(String t1) { @Test public void testToMap() { - Observable source = Observable.from("a", "bb", "ccc", "dddd"); + Observable source = Observable.just("a", "bb", "ccc", "dddd"); Observable> mapped = source.toMap(lengthFunc); @@ -78,7 +78,7 @@ public void testToMap() { @Test public void testToMapWithValueSelector() { - Observable source = Observable.from("a", "bb", "ccc", "dddd"); + Observable source = Observable.just("a", "bb", "ccc", "dddd"); Observable> mapped = source.toMap(lengthFunc, duplicate); @@ -97,7 +97,7 @@ public void testToMapWithValueSelector() { @Test public void testToMapWithError() { - Observable source = Observable.from("a", "bb", "ccc", "dddd"); + Observable source = Observable.just("a", "bb", "ccc", "dddd"); Func1 lengthFuncErr = new Func1() { @Override @@ -126,7 +126,7 @@ public Integer call(String t1) { @Test public void testToMapWithErrorInValueSelector() { - Observable source = Observable.from("a", "bb", "ccc", "dddd"); + Observable source = Observable.just("a", "bb", "ccc", "dddd"); Func1 duplicateErr = new Func1() { @Override @@ -156,7 +156,7 @@ public String call(String t1) { @Test public void testToMapWithFactory() { - Observable source = Observable.from("a", "bb", "ccc", "dddd"); + Observable source = Observable.just("a", "bb", "ccc", "dddd"); Func0> mapFactory = new Func0>() { @Override @@ -195,7 +195,7 @@ public Integer call(String t1) { @Test public void testToMapWithErrorThrowingFactory() { - Observable source = Observable.from("a", "bb", "ccc", "dddd"); + Observable source = Observable.just("a", "bb", "ccc", "dddd"); Func0> mapFactory = new Func0>() { @Override diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorToMultimapTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorToMultimapTest.java index 662b5452ea..fa040a3644 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorToMultimapTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorToMultimapTest.java @@ -66,7 +66,7 @@ public String call(String t1) { @Test public void testToMultimap() { - Observable source = Observable.from("a", "b", "cc", "dd"); + Observable source = Observable.just("a", "b", "cc", "dd"); Observable>> mapped = source.toMultimap(lengthFunc); @@ -83,7 +83,7 @@ public void testToMultimap() { @Test public void testToMultimapWithValueSelector() { - Observable source = Observable.from("a", "b", "cc", "dd"); + Observable source = Observable.just("a", "b", "cc", "dd"); Observable>> mapped = source.toMultimap(lengthFunc, duplicate); @@ -100,7 +100,7 @@ public void testToMultimapWithValueSelector() { @Test public void testToMultimapWithMapFactory() { - Observable source = Observable.from("a", "b", "cc", "dd", "eee", "fff"); + Observable source = Observable.just("a", "b", "cc", "dd", "eee", "fff"); Func0>> mapFactory = new Func0>>() { @Override @@ -134,7 +134,7 @@ protected boolean removeEldestEntry(Map.Entry> eldes @Test public void testToMultimapWithCollectionFactory() { - Observable source = Observable.from("cc", "dd", "eee", "eee"); + Observable source = Observable.just("cc", "dd", "eee", "eee"); Func1> collectionFactory = new Func1>() { @@ -165,7 +165,7 @@ public Collection call(Integer t1) { @Test public void testToMultimapWithError() { - Observable source = Observable.from("a", "b", "cc", "dd"); + Observable source = Observable.just("a", "b", "cc", "dd"); Func1 lengthFuncErr = new Func1() { @Override @@ -192,7 +192,7 @@ public Integer call(String t1) { @Test public void testToMultimapWithErrorInValueSelector() { - Observable source = Observable.from("a", "b", "cc", "dd"); + Observable source = Observable.just("a", "b", "cc", "dd"); Func1 duplicateErr = new Func1() { @Override @@ -219,7 +219,7 @@ public String call(String t1) { @Test public void testToMultimapWithMapThrowingFactory() { - Observable source = Observable.from("a", "b", "cc", "dd", "eee", "fff"); + Observable source = Observable.just("a", "b", "cc", "dd", "eee", "fff"); Func0>> mapFactory = new Func0>>() { @Override @@ -243,7 +243,7 @@ public Map> call() { @Test public void testToMultimapWithThrowingCollectionFactory() { - Observable source = Observable.from("cc", "cc", "eee", "eee"); + Observable source = Observable.just("cc", "cc", "eee", "eee"); Func1> collectionFactory = new Func1>() { diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorToObservableSortedListTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorToObservableSortedListTest.java index aa8e470c8e..d304e9443e 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorToObservableSortedListTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorToObservableSortedListTest.java @@ -36,7 +36,7 @@ public class OperatorToObservableSortedListTest { @Test public void testSortedList() { - Observable w = Observable.from(1, 3, 2, 5, 4); + Observable w = Observable.just(1, 3, 2, 5, 4); Observable> observable = w.lift(new OperatorToObservableSortedList()); @SuppressWarnings("unchecked") @@ -49,7 +49,7 @@ public void testSortedList() { @Test public void testSortedListWithCustomFunction() { - Observable w = Observable.from(1, 3, 2, 5, 4); + Observable w = Observable.just(1, 3, 2, 5, 4); Observable> observable = w.lift(new OperatorToObservableSortedList(new Func2() { @Override @@ -69,7 +69,7 @@ public Integer call(Integer t1, Integer t2) { @Test public void testWithFollowingFirst() { - Observable o = Observable.from(1, 3, 2, 5, 4); + Observable o = Observable.just(1, 3, 2, 5, 4); assertEquals(Arrays.asList(1, 2, 3, 4, 5), o.toSortedList().toBlocking().first()); } } diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorWindowTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorWindowTest.java index 61f9d06771..4d6151fdf0 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorWindowTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorWindowTest.java @@ -74,7 +74,7 @@ public void call(List xs) { @Test public void testNonOverlappingWindows() { - Observable subject = Observable.from("one", "two", "three", "four", "five"); + Observable subject = Observable.just("one", "two", "three", "four", "five"); Observable> windowed = subject.window(3); List> windows = toLists(windowed); @@ -86,7 +86,7 @@ public void testNonOverlappingWindows() { @Test public void testSkipAndCountGaplessWindows() { - Observable subject = Observable.from("one", "two", "three", "four", "five"); + Observable subject = Observable.just("one", "two", "three", "four", "five"); Observable> windowed = subject.window(3, 3); List> windows = toLists(windowed); @@ -114,7 +114,7 @@ public void testOverlappingWindows() { @Test public void testSkipAndCountWindowsWithGaps() { - Observable subject = Observable.from("one", "two", "three", "four", "five"); + Observable subject = Observable.just("one", "two", "three", "four", "five"); Observable> windowed = subject.window(2, 3); List> windows = toLists(windowed); diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorZipIterableTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorZipIterableTest.java index f2fdd321de..ca5d6e84ce 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorZipIterableTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorZipIterableTest.java @@ -369,7 +369,7 @@ public String call(Integer t1) { } @Test public void testTake2() { - Observable o = Observable.from(1, 2, 3, 4, 5); + Observable o = Observable.just(1, 2, 3, 4, 5); Iterable it = Arrays.asList("a", "b", "c", "d", "e"); SquareStr squareStr = new SquareStr(); diff --git a/rxjava-core/src/test/java/rx/internal/operators/OperatorZipTest.java b/rxjava-core/src/test/java/rx/internal/operators/OperatorZipTest.java index 01cf19ce90..f9eff7adef 100644 --- a/rxjava-core/src/test/java/rx/internal/operators/OperatorZipTest.java +++ b/rxjava-core/src/test/java/rx/internal/operators/OperatorZipTest.java @@ -95,7 +95,7 @@ public void testCollectionSizeDifferentThanFunction() { Observer observer = mock(Observer.class); @SuppressWarnings("rawtypes") - Collection ws = java.util.Collections.singleton(Observable.from("one", "two")); + Collection ws = java.util.Collections.singleton(Observable.just("one", "two")); Observable w = Observable.zip(ws, zipr); w.subscribe(observer); @@ -446,7 +446,7 @@ public void testStart2Types() { /* define a Observer to receive aggregated events */ Observer observer = mock(Observer.class); - Observable w = Observable.zip(Observable.from("one", "two"), Observable.from(2, 3, 4), zipr); + Observable w = Observable.zip(Observable.just("one", "two"), Observable.just(2, 3, 4), zipr); w.subscribe(observer); verify(observer, never()).onError(any(Throwable.class)); @@ -465,7 +465,7 @@ public void testStart3Types() { /* define a Observer to receive aggregated events */ Observer observer = mock(Observer.class); - Observable w = Observable.zip(Observable.from("one", "two"), Observable.from(2), Observable.from(new int[] { 4, 5, 6 }), zipr); + Observable w = Observable.zip(Observable.just("one", "two"), Observable.just(2), Observable.just(new int[] { 4, 5, 6 }), zipr); w.subscribe(observer); verify(observer, never()).onError(any(Throwable.class)); @@ -481,7 +481,7 @@ public void testOnNextExceptionInvokesOnError() { @SuppressWarnings("unchecked") Observer observer = mock(Observer.class); - Observable w = Observable.zip(Observable.from(10, 20, 30), Observable.from(0, 1, 2), zipr); + Observable w = Observable.zip(Observable.just(10, 20, 30), Observable.just(0, 1, 2), zipr); w.subscribe(observer); verify(observer, times(1)).onError(any(Throwable.class)); @@ -770,8 +770,8 @@ public void testStartWithOnCompletedTwice() { @SuppressWarnings("unchecked") final Observer observer = mock(Observer.class); - Observable.zip(Observable.from(1), - Observable.from(1), new Func2() { + Observable.zip(Observable.just(1), + Observable.just(1), new Func2() { @Override public Integer call(Integer a, Integer b) { return a + b; @@ -899,8 +899,8 @@ public void onNext(String s) { @Test public void testEmitNull() { - Observable oi = Observable.from(1, null, 3); - Observable os = Observable.from("a", "b", null); + Observable oi = Observable.just(1, null, 3); + Observable os = Observable.just("a", "b", null); Observable o = Observable.zip(oi, os, new Func2() { @Override @@ -928,8 +928,8 @@ public void call(String s) { @Test public void testEmitMaterializedNotifications() { - Observable> oi = Observable.from(1, 2, 3).materialize(); - Observable> os = Observable.from("a", "b", "c").materialize(); + Observable> oi = Observable.just(1, 2, 3).materialize(); + Observable> os = Observable.just("a", "b", "c").materialize(); Observable o = Observable.zip(oi, os, new Func2, Notification, String>() { @Override diff --git a/rxjava-core/src/test/java/rx/observables/BlockingObservableTest.java b/rxjava-core/src/test/java/rx/observables/BlockingObservableTest.java index 75c047b099..5abc7a8bfc 100644 --- a/rxjava-core/src/test/java/rx/observables/BlockingObservableTest.java +++ b/rxjava-core/src/test/java/rx/observables/BlockingObservableTest.java @@ -52,7 +52,7 @@ public void before() { @Test public void testLast() { - BlockingObservable obs = BlockingObservable.from(Observable.from("one", "two", "three")); + BlockingObservable obs = BlockingObservable.from(Observable.just("one", "two", "three")); assertEquals("three", obs.last()); } @@ -65,7 +65,7 @@ public void testLastEmptyObservable() { @Test public void testLastOrDefault() { - BlockingObservable observable = BlockingObservable.from(Observable.from(1, 0, -1)); + BlockingObservable observable = BlockingObservable.from(Observable.just(1, 0, -1)); int last = observable.lastOrDefault(-100, new Func1() { @Override public Boolean call(Integer args) { @@ -77,7 +77,7 @@ public Boolean call(Integer args) { @Test public void testLastOrDefault1() { - BlockingObservable observable = BlockingObservable.from(Observable.from("one", "two", "three")); + BlockingObservable observable = BlockingObservable.from(Observable.just("one", "two", "three")); assertEquals("three", observable.lastOrDefault("default")); } @@ -89,7 +89,7 @@ public void testLastOrDefault2() { @Test public void testLastOrDefaultWithPredicate() { - BlockingObservable observable = BlockingObservable.from(Observable.from(1, 0, -1)); + BlockingObservable observable = BlockingObservable.from(Observable.just(1, 0, -1)); int last = observable.lastOrDefault(0, new Func1() { @Override public Boolean call(Integer args) { @@ -102,7 +102,7 @@ public Boolean call(Integer args) { @Test public void testLastOrDefaultWrongPredicate() { - BlockingObservable observable = BlockingObservable.from(Observable.from(-1, -2, -3)); + BlockingObservable observable = BlockingObservable.from(Observable.just(-1, -2, -3)); int last = observable.lastOrDefault(0, new Func1() { @Override public Boolean call(Integer args) { @@ -114,7 +114,7 @@ public Boolean call(Integer args) { @Test public void testLastWithPredicate() { - BlockingObservable obs = BlockingObservable.from(Observable.from("one", "two", "three")); + BlockingObservable obs = BlockingObservable.from(Observable.just("one", "two", "three")); assertEquals("two", obs.last(new Func1() { @Override @@ -125,7 +125,7 @@ public Boolean call(String s) { } public void testSingle() { - BlockingObservable observable = BlockingObservable.from(Observable.from("one")); + BlockingObservable observable = BlockingObservable.from(Observable.just("one")); assertEquals("one", observable.single()); } @@ -137,7 +137,7 @@ public void testSingleDefault() { @Test(expected = IllegalArgumentException.class) public void testSingleDefaultPredicateMatchesMoreThanOne() { - BlockingObservable.from(Observable.from("one", "two")).singleOrDefault("default", new Func1() { + BlockingObservable.from(Observable.just("one", "two")).singleOrDefault("default", new Func1() { @Override public Boolean call(String args) { return args.length() == 3; @@ -147,7 +147,7 @@ public Boolean call(String args) { @Test public void testSingleDefaultPredicateMatchesNothing() { - BlockingObservable observable = BlockingObservable.from(Observable.from("one", "two")); + BlockingObservable observable = BlockingObservable.from(Observable.just("one", "two")); String result = observable.singleOrDefault("default", new Func1() { @Override public Boolean call(String args) { @@ -159,13 +159,13 @@ public Boolean call(String args) { @Test(expected = IllegalArgumentException.class) public void testSingleDefaultWithMoreThanOne() { - BlockingObservable observable = BlockingObservable.from(Observable.from("one", "two", "three")); + BlockingObservable observable = BlockingObservable.from(Observable.just("one", "two", "three")); observable.singleOrDefault("default"); } @Test public void testSingleWithPredicateDefault() { - BlockingObservable observable = BlockingObservable.from(Observable.from("one", "two", "four")); + BlockingObservable observable = BlockingObservable.from(Observable.just("one", "two", "four")); assertEquals("four", observable.single(new Func1() { @Override public Boolean call(String s) { @@ -176,13 +176,13 @@ public Boolean call(String s) { @Test(expected = IllegalArgumentException.class) public void testSingleWrong() { - BlockingObservable observable = BlockingObservable.from(Observable.from(1, 2)); + BlockingObservable observable = BlockingObservable.from(Observable.just(1, 2)); observable.single(); } @Test(expected = NoSuchElementException.class) public void testSingleWrongPredicate() { - BlockingObservable observable = BlockingObservable.from(Observable.from(-1)); + BlockingObservable observable = BlockingObservable.from(Observable.just(-1)); observable.single(new Func1() { @Override public Boolean call(Integer args) { @@ -193,7 +193,7 @@ public Boolean call(Integer args) { @Test public void testToIterable() { - BlockingObservable obs = BlockingObservable.from(Observable.from("one", "two", "three")); + BlockingObservable obs = BlockingObservable.from(Observable.just("one", "two", "three")); Iterator it = obs.toIterable().iterator(); @@ -212,7 +212,7 @@ public void testToIterable() { @Test(expected = NoSuchElementException.class) public void testToIterableNextOnly() { - BlockingObservable obs = BlockingObservable.from(Observable.from(1, 2, 3)); + BlockingObservable obs = BlockingObservable.from(Observable.just(1, 2, 3)); Iterator it = obs.toIterable().iterator(); @@ -225,7 +225,7 @@ public void testToIterableNextOnly() { @Test(expected = NoSuchElementException.class) public void testToIterableNextOnlyTwice() { - BlockingObservable obs = BlockingObservable.from(Observable.from(1, 2, 3)); + BlockingObservable obs = BlockingObservable.from(Observable.just(1, 2, 3)); Iterator it = obs.toIterable().iterator(); @@ -246,7 +246,7 @@ public void testToIterableNextOnlyTwice() { @Test public void testToIterableManyTimes() { - BlockingObservable obs = BlockingObservable.from(Observable.from(1, 2, 3)); + BlockingObservable obs = BlockingObservable.from(Observable.just(1, 2, 3)); Iterable iter = obs.toIterable(); @@ -317,7 +317,7 @@ public void call(String t1) { @Test public void testFirst() { - BlockingObservable observable = BlockingObservable.from(Observable.from("one", "two", "three")); + BlockingObservable observable = BlockingObservable.from(Observable.just("one", "two", "three")); assertEquals("one", observable.first()); } @@ -328,7 +328,7 @@ public void testFirstWithEmpty() { @Test public void testFirstWithPredicate() { - BlockingObservable observable = BlockingObservable.from(Observable.from("one", "two", "three")); + BlockingObservable observable = BlockingObservable.from(Observable.just("one", "two", "three")); String first = observable.first(new Func1() { @Override public Boolean call(String args) { @@ -340,7 +340,7 @@ public Boolean call(String args) { @Test(expected = NoSuchElementException.class) public void testFirstWithPredicateAndEmpty() { - BlockingObservable observable = BlockingObservable.from(Observable.from("one", "two", "three")); + BlockingObservable observable = BlockingObservable.from(Observable.just("one", "two", "three")); observable.first(new Func1() { @Override public Boolean call(String args) { @@ -351,7 +351,7 @@ public Boolean call(String args) { @Test public void testFirstOrDefault() { - BlockingObservable observable = BlockingObservable.from(Observable.from("one", "two", "three")); + BlockingObservable observable = BlockingObservable.from(Observable.just("one", "two", "three")); assertEquals("one", observable.firstOrDefault("default")); } @@ -363,7 +363,7 @@ public void testFirstOrDefaultWithEmpty() { @Test public void testFirstOrDefaultWithPredicate() { - BlockingObservable observable = BlockingObservable.from(Observable.from("one", "two", "three")); + BlockingObservable observable = BlockingObservable.from(Observable.just("one", "two", "three")); String first = observable.firstOrDefault("default", new Func1() { @Override public Boolean call(String args) { @@ -375,7 +375,7 @@ public Boolean call(String args) { @Test public void testFirstOrDefaultWithPredicateAndEmpty() { - BlockingObservable observable = BlockingObservable.from(Observable.from("one", "two", "three")); + BlockingObservable observable = BlockingObservable.from(Observable.just("one", "two", "three")); String first = observable.firstOrDefault("default", new Func1() { @Override public Boolean call(String args) { diff --git a/rxjava-core/src/test/java/rx/schedulers/AbstractSchedulerConcurrencyTests.java b/rxjava-core/src/test/java/rx/schedulers/AbstractSchedulerConcurrencyTests.java index fd81a2d5fb..6367f4c0f8 100644 --- a/rxjava-core/src/test/java/rx/schedulers/AbstractSchedulerConcurrencyTests.java +++ b/rxjava-core/src/test/java/rx/schedulers/AbstractSchedulerConcurrencyTests.java @@ -346,7 +346,7 @@ public final void testSubscribeWithScheduler() throws InterruptedException { final AtomicInteger count = new AtomicInteger(); - Observable o1 = Observable. from(1, 2, 3, 4, 5); + Observable o1 = Observable. just(1, 2, 3, 4, 5); o1.subscribe(new Action1() { diff --git a/rxjava-core/src/test/java/rx/schedulers/AbstractSchedulerTests.java b/rxjava-core/src/test/java/rx/schedulers/AbstractSchedulerTests.java index 093ad8d999..94acb530a3 100644 --- a/rxjava-core/src/test/java/rx/schedulers/AbstractSchedulerTests.java +++ b/rxjava-core/src/test/java/rx/schedulers/AbstractSchedulerTests.java @@ -385,7 +385,7 @@ public void run() { public final void testObserveOn() throws InterruptedException { final Scheduler scheduler = getScheduler(); - Observable o = Observable.from("one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"); + Observable o = Observable.just("one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"); ConcurrentObserverValidator observer = new ConcurrentObserverValidator(); @@ -405,7 +405,7 @@ public final void testObserveOn() throws InterruptedException { public final void testSubscribeOnNestedConcurrency() throws InterruptedException { final Scheduler scheduler = getScheduler(); - Observable o = Observable.from("one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten") + Observable o = Observable.just("one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten") .mergeMap(new Func1>() { @Override diff --git a/rxjava-core/src/test/java/rx/schedulers/CachedThreadSchedulerTest.java b/rxjava-core/src/test/java/rx/schedulers/CachedThreadSchedulerTest.java index f9f8ca161c..738e2a757d 100644 --- a/rxjava-core/src/test/java/rx/schedulers/CachedThreadSchedulerTest.java +++ b/rxjava-core/src/test/java/rx/schedulers/CachedThreadSchedulerTest.java @@ -37,8 +37,8 @@ protected Scheduler getScheduler() { @Test public final void testIOScheduler() { - Observable o1 = Observable.from(1, 2, 3, 4, 5); - Observable o2 = Observable.from(6, 7, 8, 9, 10); + Observable o1 = Observable.just(1, 2, 3, 4, 5); + Observable o2 = Observable.just(6, 7, 8, 9, 10); Observable o = Observable.merge(o1, o2).map(new Func1() { @Override diff --git a/rxjava-core/src/test/java/rx/schedulers/ComputationSchedulerTests.java b/rxjava-core/src/test/java/rx/schedulers/ComputationSchedulerTests.java index c4090bd1aa..f7544636bd 100644 --- a/rxjava-core/src/test/java/rx/schedulers/ComputationSchedulerTests.java +++ b/rxjava-core/src/test/java/rx/schedulers/ComputationSchedulerTests.java @@ -91,8 +91,8 @@ public void call() { @Test public final void testComputationThreadPool1() { - Observable o1 = Observable. from(1, 2, 3, 4, 5); - Observable o2 = Observable. from(6, 7, 8, 9, 10); + Observable o1 = Observable. just(1, 2, 3, 4, 5); + Observable o2 = Observable. just(6, 7, 8, 9, 10); Observable o = Observable. merge(o1, o2).map(new Func1() { @Override @@ -117,8 +117,8 @@ public final void testMergeWithExecutorScheduler() { final String currentThreadName = Thread.currentThread().getName(); - Observable o1 = Observable. from(1, 2, 3, 4, 5); - Observable o2 = Observable. from(6, 7, 8, 9, 10); + Observable o1 = Observable. just(1, 2, 3, 4, 5); + Observable o2 = Observable. just(6, 7, 8, 9, 10); Observable o = Observable. merge(o1, o2).subscribeOn(Schedulers.computation()).map(new Func1() { @Override diff --git a/rxjava-core/src/test/java/rx/schedulers/ImmediateSchedulerTest.java b/rxjava-core/src/test/java/rx/schedulers/ImmediateSchedulerTest.java index ee52a0b5fd..c68e4843b5 100644 --- a/rxjava-core/src/test/java/rx/schedulers/ImmediateSchedulerTest.java +++ b/rxjava-core/src/test/java/rx/schedulers/ImmediateSchedulerTest.java @@ -57,8 +57,8 @@ public final void testMergeWithoutScheduler() { final String currentThreadName = Thread.currentThread().getName(); - Observable o1 = Observable. from(1, 2, 3, 4, 5); - Observable o2 = Observable. from(6, 7, 8, 9, 10); + Observable o1 = Observable. just(1, 2, 3, 4, 5); + Observable o2 = Observable. just(6, 7, 8, 9, 10); Observable o = Observable. merge(o1, o2).map(new Func1() { @Override @@ -82,8 +82,8 @@ public final void testMergeWithImmediateScheduler1() { final String currentThreadName = Thread.currentThread().getName(); - Observable o1 = Observable. from(1, 2, 3, 4, 5); - Observable o2 = Observable. from(6, 7, 8, 9, 10); + Observable o1 = Observable. just(1, 2, 3, 4, 5); + Observable o2 = Observable. just(6, 7, 8, 9, 10); Observable o = Observable. merge(o1, o2).subscribeOn(Schedulers.immediate()).map(new Func1() { @Override diff --git a/rxjava-core/src/test/java/rx/schedulers/TrampolineSchedulerTest.java b/rxjava-core/src/test/java/rx/schedulers/TrampolineSchedulerTest.java index b8c2a88647..253d3a5382 100644 --- a/rxjava-core/src/test/java/rx/schedulers/TrampolineSchedulerTest.java +++ b/rxjava-core/src/test/java/rx/schedulers/TrampolineSchedulerTest.java @@ -42,8 +42,8 @@ public final void testMergeWithCurrentThreadScheduler1() { final String currentThreadName = Thread.currentThread().getName(); - Observable o1 = Observable. from(1, 2, 3, 4, 5); - Observable o2 = Observable. from(6, 7, 8, 9, 10); + Observable o1 = Observable. just(1, 2, 3, 4, 5); + Observable o2 = Observable. just(6, 7, 8, 9, 10); Observable o = Observable. merge(o1, o2).subscribeOn(Schedulers.trampoline()).map(new Func1() { @Override diff --git a/rxjava-core/src/test/java/rx/subjects/BehaviorSubjectTest.java b/rxjava-core/src/test/java/rx/subjects/BehaviorSubjectTest.java index 58197c5f97..dc78ebf42a 100644 --- a/rxjava-core/src/test/java/rx/subjects/BehaviorSubjectTest.java +++ b/rxjava-core/src/test/java/rx/subjects/BehaviorSubjectTest.java @@ -262,7 +262,7 @@ public void testUnsubscriptionCase() { @Override public Observable call(String t1) { - return Observable.from(t1 + ", " + t1); + return Observable.just(t1 + ", " + t1); } }) .subscribe(new Observer() { diff --git a/rxjava-core/src/test/java/rx/subjects/PublishSubjectTest.java b/rxjava-core/src/test/java/rx/subjects/PublishSubjectTest.java index 7c636b09b6..20ec300700 100644 --- a/rxjava-core/src/test/java/rx/subjects/PublishSubjectTest.java +++ b/rxjava-core/src/test/java/rx/subjects/PublishSubjectTest.java @@ -320,7 +320,7 @@ public void testUnsubscriptionCase() { @Override public Observable call(String t1) { - return Observable.from(t1 + ", " + t1); + return Observable.just(t1 + ", " + t1); } }) .subscribe(new Observer() { diff --git a/rxjava-core/src/test/java/rx/subjects/ReplaySubjectTest.java b/rxjava-core/src/test/java/rx/subjects/ReplaySubjectTest.java index 44e3dcfa67..7c4ae2f8f9 100644 --- a/rxjava-core/src/test/java/rx/subjects/ReplaySubjectTest.java +++ b/rxjava-core/src/test/java/rx/subjects/ReplaySubjectTest.java @@ -381,7 +381,7 @@ public void testUnsubscriptionCase() { @Override public Observable call(String t1) { - return Observable.from(t1 + ", " + t1); + return Observable.just(t1 + ", " + t1); } }) .subscribe(new Observer() { diff --git a/rxjava-core/src/test/java/rx/util/AssertObservableTest.java b/rxjava-core/src/test/java/rx/util/AssertObservableTest.java index 8be0f5dadd..1e45f160bf 100644 --- a/rxjava-core/src/test/java/rx/util/AssertObservableTest.java +++ b/rxjava-core/src/test/java/rx/util/AssertObservableTest.java @@ -23,7 +23,7 @@ public class AssertObservableTest { @Test public void testPassNotNull() { - AssertObservable.assertObservableEqualsBlocking("foo", Observable.from(1, 2), Observable.from(1, 2)); + AssertObservable.assertObservableEqualsBlocking("foo", Observable.just(1, 2), Observable.just(1, 2)); } @Test @@ -33,11 +33,11 @@ public void testPassNull() { @Test(expected = AssertionError.class) public void testFailNotNull() { - AssertObservable.assertObservableEqualsBlocking("foo", Observable.from(1, 2), Observable.from(1)); + AssertObservable.assertObservableEqualsBlocking("foo", Observable.just(1, 2), Observable.just(1)); } @Test(expected = AssertionError.class) public void testFailNull() { - AssertObservable.assertObservableEqualsBlocking("foo", Observable.from(1, 2), null); + AssertObservable.assertObservableEqualsBlocking("foo", Observable.just(1, 2), null); } }