Skip to content

Commit f768274

Browse files
authored
4.x: Unit test lambdaification 8 of N (ReactiveX#8144)
1 parent 54cd5d4 commit f768274

23 files changed

Lines changed: 1098 additions & 2893 deletions

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -735,12 +735,7 @@ public void serializedSubjectOnErrorNull() {
735735

736736
@Test(expected = NullPointerException.class)
737737
public void combineLatestDelayErrorIterableFunctionReturnsNull() {
738-
Flowable.combineLatestDelayError(Arrays.asList(just1), new Function<Object[], Object>() {
739-
@Override
740-
public Object apply(Object[] v) {
741-
return null;
742-
}
743-
}, 128).blockingLast();
738+
Flowable.combineLatestDelayError(Arrays.asList(just1), _ -> null, 128).blockingLast();
744739
}
745740

746741
@Test(expected = NullPointerException.class)

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

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -951,30 +951,24 @@ public void toObservableError() {
951951
@Test
952952
public void zipIterableObject() {
953953
final List<Flowable<Integer>> flowables = Arrays.asList(Flowable.just(1, 2, 3), Flowable.just(1, 2, 3));
954-
Flowable.zip(flowables, new Function<Object[], Object>() {
955-
@Override
956-
public Object apply(Object[] o) throws Exception {
957-
int sum = 0;
958-
for (Object i : o) {
959-
sum += (Integer) i;
960-
}
961-
return sum;
954+
Flowable.zip(flowables, o -> {
955+
int sum = 0;
956+
for (Object i : o) {
957+
sum += (Integer) i;
962958
}
959+
return sum;
963960
}).test().assertResult(2, 4, 6);
964961
}
965962

966963
@Test
967964
public void combineLatestObject() {
968965
final List<Flowable<Integer>> flowables = Arrays.asList(Flowable.just(1, 2, 3), Flowable.just(1, 2, 3));
969-
Flowable.combineLatest(flowables, new Function<Object[], Object>() {
970-
@Override
971-
public Object apply(final Object[] o) throws Exception {
972-
int sum = 1;
973-
for (Object i : o) {
974-
sum *= (Integer) i;
975-
}
976-
return sum;
966+
Flowable.combineLatest(flowables, o -> {
967+
int sum = 1;
968+
for (Object i : o) {
969+
sum *= (Integer) i;
977970
}
971+
return sum;
978972
}).test().assertResult(3, 6, 9);
979973
}
980974
}

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,10 @@ public void nonBlockingObservable() {
7979

8080
Collection<Flowable<Object>> observables = Collections.emptyList();
8181

82-
Flowable<Object> result = Flowable.zip(observables, new Function<Object[], Object>() {
83-
@Override
84-
public Object apply(Object[] args) {
85-
System.out.println("received: " + args);
86-
assertEquals("No argument should have been passed", 0, args.length);
87-
return invoked;
88-
}
82+
Flowable<Object> result = Flowable.zip(observables, args -> {
83+
System.out.println("received: " + args);
84+
assertEquals("No argument should have been passed", 0, args.length);
85+
return invoked;
8986
});
9087

9188
assertSame(invoked, result.blockingLast());

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.util.concurrent.atomic.*;
2121

2222
import org.junit.*;
23-
import static java.util.concurrent.Flow.*;
2423

2524
import io.reactivex.rxjava4.core.*;
2625
import io.reactivex.rxjava4.disposables.SerialDisposable;

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

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -51,39 +51,35 @@ public void setUp() {
5151

5252
private Flowable<String> createFlowable(final String[] values,
5353
final long interval, final Throwable e) {
54-
return Flowable.unsafeCreate(new Publisher<String>() {
54+
return Flowable.unsafeCreate(subscriber -> {
55+
@SuppressWarnings("resource")
56+
final CompositeDisposable parentSubscription = new CompositeDisposable();
5557

56-
@Override
57-
public void subscribe(final Subscriber<? super String> subscriber) {
58-
@SuppressWarnings("resource")
59-
final CompositeDisposable parentSubscription = new CompositeDisposable();
60-
61-
subscriber.onSubscribe(new Subscription() /* NFI */ {
62-
@Override
63-
public void request(long n) {
58+
subscriber.onSubscribe(new Subscription() /* NFI */ {
59+
@Override
60+
public void request(long n) {
6461

65-
}
66-
67-
@Override
68-
public void cancel() {
69-
parentSubscription.dispose();
70-
}
71-
});
62+
}
7263

73-
long delay = interval;
74-
for (final String value : values) {
75-
parentSubscription.add(innerScheduler.schedule(() -> subscriber.onNext(value)
76-
, delay, TimeUnit.MILLISECONDS));
77-
delay += interval;
64+
@Override
65+
public void cancel() {
66+
parentSubscription.dispose();
7867
}
79-
parentSubscription.add(innerScheduler.schedule(() -> {
80-
if (e == null) {
81-
subscriber.onComplete();
82-
} else {
83-
subscriber.onError(e);
84-
}
85-
}, delay, TimeUnit.MILLISECONDS));
68+
});
69+
70+
long delay = interval;
71+
for (final String value : values) {
72+
parentSubscription.add(innerScheduler.schedule(() -> subscriber.onNext(value)
73+
, delay, TimeUnit.MILLISECONDS));
74+
delay += interval;
8675
}
76+
parentSubscription.add(innerScheduler.schedule(() -> {
77+
if (e == null) {
78+
subscriber.onComplete();
79+
} else {
80+
subscriber.onError(e);
81+
}
82+
}, delay, TimeUnit.MILLISECONDS));
8783
});
8884
}
8985

0 commit comments

Comments
 (0)