Skip to content

Commit 8e993b0

Browse files
committed
4.x: Unit test lambdaification 8 of N
1 parent f768274 commit 8e993b0

46 files changed

Lines changed: 228 additions & 373 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/io/reactivex/rxjava4/core/Flowable.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9407,13 +9407,12 @@ public final Flowable<T> delaySubscription(long time, @NonNull TimeUnit unit, @N
94079407
* @see #distinct(Function)
94089408
* @see #distinct(Function, Supplier)
94099409
*/
9410-
@SuppressWarnings({ "rawtypes", "unchecked" })
94119410
@CheckReturnValue
94129411
@BackpressureSupport(BackpressureKind.FULL)
94139412
@SchedulerSupport(SchedulerSupport.NONE)
94149413
@NonNull
94159414
public final Flowable<T> distinct() {
9416-
return distinct((Function)Functions.identity(), Functions.<T>createHashSet());
9415+
return distinct(Functions.identity(), Functions.<T>createHashSet());
94179416
}
94189417

94199418
/**

src/main/java/io/reactivex/rxjava4/observers/BaseTestConsumer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,9 @@ public final U assertError(@NonNull Throwable error) {
240240
* @param errorClass the error {@code Class} to expect
241241
* @return this
242242
*/
243-
@SuppressWarnings({ "unchecked", "rawtypes" })
244243
@NonNull
245244
public final U assertError(@NonNull Class<? extends Throwable> errorClass) {
246-
return (U)assertError((Predicate)Functions.isInstanceOf(errorClass), true);
245+
return assertError(Functions.isInstanceOf(errorClass), true);
247246
}
248247

249248
/**

src/test/java/io/reactivex/rxjava4/completable/CompletableTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,7 +1761,7 @@ public void retry5Times() {
17611761

17621762
@Test(expected = TestException.class)
17631763
public void retryBiPredicate5Times() {
1764-
Completable c = error.completable.retry((BiPredicate<Integer, Throwable>) (n, _) -> n < 5);
1764+
Completable c = error.completable.retry((n, _) -> n < 5);
17651765

17661766
c.blockingAwait();
17671767
}
@@ -1795,7 +1795,7 @@ public void retryNegativeTimes() {
17951795

17961796
@Test(expected = TestException.class)
17971797
public void retryPredicateError() {
1798-
Completable c = error.completable.retry((Predicate<Throwable>) _ -> false);
1798+
Completable c = error.completable.retry(_ -> false);
17991799

18001800
c.blockingAwait();
18011801
}
@@ -1808,7 +1808,7 @@ public void retryPredicate5Times() {
18081808
if (calls.decrementAndGet() != 0) {
18091809
throw new TestException();
18101810
}
1811-
}).retry((Predicate<Throwable>) _ -> true);
1811+
}).retry(_ -> true);
18121812

18131813
c.blockingAwait();
18141814
}
@@ -2039,7 +2039,7 @@ public void timeoutTimerCancelled() throws InterruptedException {
20392039
@Test
20402040
public void toNormal() {
20412041
normal.completable
2042-
.to((CompletableConverter<Flowable<Object>>) Completable::toFlowable)
2042+
.to(Completable::toFlowable)
20432043
.test()
20442044
.assertComplete()
20452045
.assertNoValues();
@@ -2048,7 +2048,7 @@ public void toNormal() {
20482048
@Test
20492049
public void asNormal() {
20502050
normal.completable
2051-
.to((CompletableConverter<Flowable<Object>>) Completable::toFlowable)
2051+
.to(Completable::toFlowable)
20522052
.test()
20532053
.assertComplete()
20542054
.assertNoValues();
@@ -2614,7 +2614,7 @@ public void subscribeTwoActionsThrowFromOnError() {
26142614
@Test
26152615
public void propagateExceptionSubscribeOneAction() {
26162616
expectUncaughtTestException(() -> error.completable.toSingleDefault(1)
2617-
.subscribe((Consumer<Integer>) _ -> { }));
2617+
.subscribe(_ -> { }));
26182618
}
26192619

26202620
@Test
@@ -3171,7 +3171,7 @@ public void subscribeAction2ReportsUnsubscribedOnErrorAfter() {
31713171
@Test
31723172
public void propagateExceptionSubscribeOneActionThrowFromOnSuccess() {
31733173
expectUncaughtTestException(() -> normal.completable.toSingleDefault(1)
3174-
.subscribe((Consumer<Integer>) _ -> {
3174+
.subscribe(_ -> {
31753175
throw new TestException();
31763176
}));
31773177
}

src/test/java/io/reactivex/rxjava4/exceptions/CompositeExceptionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public void nullCollection() {
183183

184184
@Test
185185
public void nullElement() {
186-
CompositeException composite = new CompositeException(Collections.singletonList((Throwable) null));
186+
CompositeException composite = new CompositeException(Collections.singletonList(null));
187187
composite.getCause();
188188
composite.printStackTrace();
189189
}

src/test/java/io/reactivex/rxjava4/flowable/FlowableCollectTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public final class FlowableCollectTest extends RxJavaTest {
3434
public void collectToListFlowable() {
3535
Flowable<List<Integer>> f = Flowable.just(1, 2, 3)
3636
.collect((Supplier<List<Integer>>) () -> new ArrayList<>(),
37-
(BiConsumer<List<Integer>, Integer>) List::add)
37+
List::add)
3838
.toFlowable();
3939

4040
List<Integer> list = f.blockingLast();
@@ -153,7 +153,7 @@ public void collectIntoFlowable() {
153153
@Test
154154
public void collectToList() {
155155
Single<List<Integer>> o = Flowable.just(1, 2, 3)
156-
.collect(() -> new ArrayList<>(), (BiConsumer<List<Integer>, Integer>) List::add);
156+
.collect(() -> new ArrayList<>(), List::add);
157157

158158
List<Integer> list = o.blockingGet();
159159

src/test/java/io/reactivex/rxjava4/flowable/FlowableNullTests.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,25 +151,25 @@ public void generateStateConsumerInitialStateNull() {
151151

152152
@Test(expected = NullPointerException.class)
153153
public void generateStateFunctionInitialStateNull() {
154-
Flowable.generate(null, (BiFunction<Object, Emitter<Object>, Object>) (s, o) -> {
154+
Flowable.generate(null, (s, o) -> {
155155
o.onNext(1); return s;
156156
});
157157
}
158158

159159
@Test(expected = NullPointerException.class)
160160
public void generateStateConsumerNull() {
161-
Flowable.generate((Supplier<Integer>) () -> 1, (BiConsumer<Integer, Emitter<Object>>)null);
161+
Flowable.generate(() -> 1, (BiConsumer<Integer, Emitter<Object>>)null);
162162
}
163163

164164
@Test
165165
public void generateConsumerStateNullAllowed() {
166166
BiConsumer<Integer, Emitter<Integer>> generator = (_, o) -> o.onComplete();
167-
Flowable.generate((Supplier<Integer>) () -> null, generator).blockingSubscribe();
167+
Flowable.generate(() -> null, generator).blockingSubscribe();
168168
}
169169

170170
@Test
171171
public void generateFunctionStateNullAllowed() {
172-
Flowable.generate((Supplier<Object>) () -> null, (BiFunction<Object, Emitter<Object>, Object>) (s, o) -> {
172+
Flowable.generate(() -> null, (s, o) -> {
173173
o.onComplete(); return s;
174174
}).blockingSubscribe();
175175
}
@@ -248,7 +248,7 @@ public void zipIterableFunctionReturnsNull() {
248248

249249
@Test(expected = NullPointerException.class)
250250
public void zipIterable2Null() {
251-
Flowable.zip((Iterable<Publisher<Object>>)null, (Function<Object[], Object>) _ -> 1, true, 128);
251+
Flowable.zip(null, (Function<Object[], Object>) _ -> 1, true, 128);
252252
}
253253

254254
@Test(expected = NullPointerException.class)
@@ -259,7 +259,7 @@ public void zipIterable2IteratorNull() {
259259

260260
@Test(expected = NullPointerException.class)
261261
public void zipIterable2FunctionReturnsNull() {
262-
Flowable.zip(Arrays.asList(just1, just1), (Function<Object[], Object>) _ -> null, true, 128)
262+
Flowable.zip(Arrays.asList(just1, just1), _ -> null, true, 128)
263263
.blockingLast();
264264
}
265265

@@ -334,7 +334,7 @@ public void distinctFunctionReturnsNull() {
334334

335335
@Test
336336
public void distinctUntilChangedFunctionReturnsNull() {
337-
Flowable.range(1, 2).distinctUntilChanged((Function<Integer, Object>) _ -> null).test().assertResult(1);
337+
Flowable.range(1, 2).distinctUntilChanged(_ -> null).test().assertResult(1);
338338
}
339339

340340
@Test(expected = NullPointerException.class)
@@ -482,13 +482,13 @@ public void replaySelectorReturnsNull() {
482482

483483
@Test(expected = NullPointerException.class)
484484
public void replayBoundedSelectorReturnsNull() {
485-
just1.replay((Function<Flowable<Integer>, Publisher<Object>>) _ -> null, 1, 1, TimeUnit.SECONDS)
485+
just1.replay(_ -> null, 1, 1, TimeUnit.SECONDS)
486486
.blockingSubscribe();
487487
}
488488

489489
@Test(expected = NullPointerException.class)
490490
public void replayTimeBoundedSelectorReturnsNull() {
491-
just1.replay((Function<Flowable<Integer>, Publisher<Object>>) _ -> null, 1, TimeUnit.SECONDS, Schedulers.single())
491+
just1.replay(_ -> null, 1, TimeUnit.SECONDS, Schedulers.single())
492492
.blockingSubscribe();
493493
}
494494

@@ -556,7 +556,7 @@ public void timeoutSelectorOtherNull() {
556556

557557
@Test(expected = NullPointerException.class)
558558
public void timeoutFirstItemReturnsNull() {
559-
just1.timeout(Flowable.never(), (Function<Integer, Publisher<Object>>) _ -> null).blockingSubscribe();
559+
just1.timeout(Flowable.never(), _ -> null).blockingSubscribe();
560560
}
561561

562562
@Test(expected = NullPointerException.class)
@@ -622,7 +622,7 @@ public void withLatestFromOtherNull() {
622622

623623
@Test(expected = NullPointerException.class)
624624
public void withLatestFromCombinerReturnsNull() {
625-
just1.withLatestFrom(just1, (BiFunction<Integer, Integer, Object>) (_, _) -> null)
625+
just1.withLatestFrom(just1, (_, _) -> null)
626626
.blockingSubscribe();
627627
}
628628

@@ -633,7 +633,7 @@ public void zipWithIterableNull() {
633633

634634
@Test(expected = NullPointerException.class)
635635
public void zipWithIterableCombinerReturnsNull() {
636-
just1.zipWith(Arrays.asList(1), (BiFunction<Integer, Integer, Object>) (_, _) -> null)
636+
just1.zipWith(Arrays.asList(1), (_, _) -> null)
637637
.blockingSubscribe();
638638
}
639639

@@ -656,7 +656,7 @@ public void zipWithPublisherNull() {
656656

657657
@Test(expected = NullPointerException.class)
658658
public void zipWithCombinerReturnsNull() {
659-
just1.zipWith(just1, (BiFunction<Integer, Integer, Object>) (_, _) -> null).blockingSubscribe();
659+
just1.zipWith(just1, (_, _) -> null).blockingSubscribe();
660660
}
661661

662662
//*********************************************

src/test/java/io/reactivex/rxjava4/flowable/FlowableTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import static java.util.concurrent.Flow.*;
2727

2828
import io.reactivex.rxjava4.core.*;
29-
import io.reactivex.rxjava4.core.Observable;
3029
import io.reactivex.rxjava4.disposables.Disposable;
3130
import io.reactivex.rxjava4.exceptions.*;
3231
import io.reactivex.rxjava4.flowables.ConnectableFlowable;
@@ -849,7 +848,7 @@ public void takeWhileToList() {
849848
@Test
850849
public void compose() {
851850
TestSubscriberEx<String> ts = new TestSubscriberEx<>();
852-
Flowable.just(1, 2, 3).compose(t1 -> t1.map((Function<Integer, String>) String::valueOf))
851+
Flowable.just(1, 2, 3).compose(t1 -> t1.map(String::valueOf))
853852
.subscribe(ts);
854853
ts.assertTerminated();
855854
ts.assertNoErrors();
@@ -923,7 +922,7 @@ public void asExtend() {
923922

924923
@Test
925924
public void as() {
926-
Flowable.just(1).to((FlowableConverter<Integer, Observable<Integer>>) Flowable::toObservable)
925+
Flowable.just(1).to(Flowable::toObservable)
927926
.test()
928927
.assertResult(1);
929928
}

src/test/java/io/reactivex/rxjava4/internal/operators/completable/CompletableFromPublisherTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.junit.Test;
1717

1818
import io.reactivex.rxjava4.core.*;
19-
import io.reactivex.rxjava4.functions.Function;
2019
import io.reactivex.rxjava4.testsupport.TestHelper;
2120

2221
public class CompletableFromPublisherTest extends RxJavaTest {
@@ -49,6 +48,6 @@ public void dispose() {
4948
@Test
5049
public void doubleOnSubscribe() {
5150
TestHelper.checkDoubleOnSubscribeFlowableToCompletable(
52-
(Function<Flowable<Object>, Completable>) Completable::fromPublisher);
51+
Completable::fromPublisher);
5352
}
5453
}

src/test/java/io/reactivex/rxjava4/internal/operators/completable/CompletableMaterializeTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import io.reactivex.rxjava4.core.*;
1919
import io.reactivex.rxjava4.exceptions.TestException;
20-
import io.reactivex.rxjava4.functions.Function;
2120
import io.reactivex.rxjava4.subjects.CompletableSubject;
2221
import io.reactivex.rxjava4.testsupport.TestHelper;
2322

@@ -43,7 +42,7 @@ public void empty() {
4342
@Test
4443
public void doubleOnSubscribe() {
4544
TestHelper.checkDoubleOnSubscribeCompletableToSingle(
46-
(Function<Completable, SingleSource<Notification<Object>>>) Completable::materialize);
45+
Completable::materialize);
4746
}
4847

4948
@Test

src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableAllTest.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import static java.util.concurrent.Flow.*;
2626

2727
import io.reactivex.rxjava4.core.*;
28-
import io.reactivex.rxjava4.disposables.Disposable;
2928
import io.reactivex.rxjava4.exceptions.TestException;
3029
import io.reactivex.rxjava4.functions.*;
3130
import io.reactivex.rxjava4.internal.functions.Functions;
@@ -45,7 +44,7 @@ public void all() {
4544
obs.all(s -> s.length() == 3)
4645
.subscribe(observer);
4746

48-
verify(observer).onSubscribe((Disposable)any());
47+
verify(observer).onSubscribe(any());
4948
verify(observer).onSuccess(true);
5049
verifyNoMoreInteractions(observer);
5150
}
@@ -59,7 +58,7 @@ public void notAll() {
5958
obs.all(s -> s.length() == 3)
6059
.subscribe(observer);
6160

62-
verify(observer).onSubscribe((Disposable)any());
61+
verify(observer).onSubscribe(any());
6362
verify(observer).onSuccess(false);
6463
verifyNoMoreInteractions(observer);
6564
}
@@ -73,7 +72,7 @@ public void empty() {
7372
obs.all(s -> s.length() == 3)
7473
.subscribe(observer);
7574

76-
verify(observer).onSubscribe((Disposable)any());
75+
verify(observer).onSubscribe(any());
7776
verify(observer).onSuccess(true);
7877
verifyNoMoreInteractions(observer);
7978
}
@@ -88,7 +87,7 @@ public void error() {
8887
obs.all(s -> s.length() == 3)
8988
.subscribe(observer);
9089

91-
verify(observer).onSubscribe((Disposable)any());
90+
verify(observer).onSubscribe(any());
9291
verify(observer).onError(error);
9392
verifyNoMoreInteractions(observer);
9493
}
@@ -152,7 +151,7 @@ public void allFlowable() {
152151
.toFlowable()
153152
.subscribe(subscriber);
154153

155-
verify(subscriber).onSubscribe((Subscription)any());
154+
verify(subscriber).onSubscribe(any());
156155
verify(subscriber).onNext(true);
157156
verify(subscriber).onComplete();
158157
verifyNoMoreInteractions(subscriber);
@@ -168,7 +167,7 @@ public void notAllFlowable() {
168167
.toFlowable()
169168
.subscribe(subscriber);
170169

171-
verify(subscriber).onSubscribe((Subscription)any());
170+
verify(subscriber).onSubscribe(any());
172171
verify(subscriber).onNext(false);
173172
verify(subscriber).onComplete();
174173
verifyNoMoreInteractions(subscriber);
@@ -184,7 +183,7 @@ public void emptyFlowable() {
184183
.toFlowable()
185184
.subscribe(subscriber);
186185

187-
verify(subscriber).onSubscribe((Subscription)any());
186+
verify(subscriber).onSubscribe(any());
188187
verify(subscriber).onNext(true);
189188
verify(subscriber).onComplete();
190189
verifyNoMoreInteractions(subscriber);
@@ -201,7 +200,7 @@ public void errorFlowable() {
201200
.toFlowable()
202201
.subscribe(subscriber);
203202

204-
verify(subscriber).onSubscribe((Subscription)any());
203+
verify(subscriber).onSubscribe(any());
205204
verify(subscriber).onError(error);
206205
verifyNoMoreInteractions(subscriber);
207206
}

0 commit comments

Comments
 (0)