Skip to content

Commit 1dc078f

Browse files
committed
Fix rebase issues (bring back down to java 7)
1 parent f273fa7 commit 1dc078f

File tree

2 files changed

+120
-25
lines changed

2 files changed

+120
-25
lines changed

autodispose/src/test/java/com/uber/autodispose/LambdaObserverTest.java

Lines changed: 112 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616

1717
package com.uber.autodispose;
1818

19+
import com.uber.autodispose.observers.AutoDisposingObserver;
1920
import io.reactivex.Maybe;
2021
import io.reactivex.Observable;
2122
import io.reactivex.Observer;
2223
import io.reactivex.disposables.Disposable;
2324
import io.reactivex.disposables.Disposables;
2425
import io.reactivex.exceptions.CompositeException;
26+
import io.reactivex.functions.Action;
27+
import io.reactivex.functions.Consumer;
2528
import java.util.ArrayList;
2629
import java.util.Arrays;
2730
import java.util.List;
@@ -33,8 +36,7 @@
3336
import static org.junit.Assert.assertFalse;
3437
import static org.junit.Assert.assertTrue;
3538

36-
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
37-
public class LambdaObserverTest {
39+
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") public class LambdaObserverTest {
3840

3941
@Rule public RxErrorsRule errors = new RxErrorsRule();
4042

@@ -44,14 +46,29 @@ public class LambdaObserverTest {
4446
final List<Object> received = new ArrayList<>();
4547

4648
AutoDisposingObserver<Object> o =
47-
new AutoDisposingObserver<>(lifecycle, received::add, received::add,
48-
() -> received.add(100), s -> {
49-
throw new TestException();
49+
new AutoDisposingObserverImpl<>(lifecycle, new Consumer<Object>() {
50+
@Override public void accept(Object o) throws Exception {
51+
received.add(o);
52+
}
53+
}, new Consumer<Object>() {
54+
@Override public void accept(Object o) throws Exception {
55+
received.add(o);
56+
}
57+
}, new Action() {
58+
59+
@Override public void run() throws Exception {
60+
received.add(100);
61+
}
62+
}, new Consumer<Disposable>() {
63+
@Override public void accept(Disposable disposable) throws Exception {
64+
throw new TestException();
65+
}
5066
});
5167

5268
assertFalse(o.isDisposed());
5369

54-
Observable.just(1).subscribe(o);
70+
Observable.just(1)
71+
.subscribe(o);
5572

5673
assertTrue(received.toString(), received.get(0) instanceof TestException);
5774
assertEquals(received.toString(), 1, received.size());
@@ -62,14 +79,30 @@ public class LambdaObserverTest {
6279
@Test public void onNextThrows() {
6380
final List<Object> received = new ArrayList<>();
6481

65-
AutoDisposingObserver<Object> o = new AutoDisposingObserver<>(lifecycle, v -> {
66-
throw new TestException();
67-
}, received::add, () -> received.add(100), s -> {
68-
});
82+
AutoDisposingObserver<Object> o =
83+
new AutoDisposingObserverImpl<>(lifecycle, new Consumer<Object>() {
84+
@Override public void accept(Object o) throws Exception {
85+
throw new TestException();
86+
}
87+
}, new Consumer<Throwable>() {
88+
@Override public void accept(Throwable o) throws Exception {
89+
received.add(o);
90+
}
91+
}, new Action() {
92+
93+
@Override public void run() throws Exception {
94+
received.add(100);
95+
}
96+
}, new Consumer<Disposable>() {
97+
@Override public void accept(Disposable disposable) throws Exception {
98+
throw new TestException();
99+
}
100+
});
69101

70102
assertFalse(o.isDisposed());
71103

72-
Observable.just(1).subscribe(o);
104+
Observable.just(1)
105+
.subscribe(o);
73106

74107
assertTrue(received.toString(), received.get(0) instanceof TestException);
75108
assertEquals(received.toString(), 1, received.size());
@@ -80,10 +113,24 @@ public class LambdaObserverTest {
80113
@Test public void onErrorThrows() {
81114
final List<Object> received = new ArrayList<>();
82115

83-
AutoDisposingObserver<Object> o = new AutoDisposingObserver<>(lifecycle, received::add, e -> {
84-
throw new TestException("Inner");
85-
}, () -> received.add(100), s -> {
86-
});
116+
AutoDisposingObserver<Object> o =
117+
new AutoDisposingObserverImpl<>(lifecycle, new Consumer<Object>() {
118+
@Override public void accept(Object o) throws Exception {
119+
throw new TestException();
120+
}
121+
}, new Consumer<Throwable>() {
122+
@Override public void accept(Throwable o) throws Exception {
123+
throw new TestException("Inner");
124+
}
125+
}, new Action() {
126+
127+
@Override public void run() throws Exception {
128+
received.add(100);
129+
}
130+
}, new Consumer<Disposable>() {
131+
@Override public void accept(Disposable disposable) throws Exception {
132+
}
133+
});
87134

88135
assertFalse(o.isDisposed());
89136

@@ -104,9 +151,21 @@ public class LambdaObserverTest {
104151
final List<Object> received = new ArrayList<>();
105152

106153
AutoDisposingObserver<Object> o =
107-
new AutoDisposingObserver<>(lifecycle, received::add, received::add, () -> {
108-
throw new TestException();
109-
}, s -> {
154+
new AutoDisposingObserverImpl<>(lifecycle, new Consumer<Object>() {
155+
@Override public void accept(Object o) throws Exception {
156+
received.add(o);
157+
}
158+
}, new Consumer<Object>() {
159+
@Override public void accept(Object o) throws Exception {
160+
received.add(o);
161+
}
162+
}, new Action() {
163+
@Override public void run() throws Exception {
164+
throw new TestException();
165+
}
166+
}, new Consumer<Disposable>() {
167+
@Override public void accept(Disposable disposable) throws Exception {
168+
}
110169
});
111170

112171
assertFalse(o.isDisposed());
@@ -139,8 +198,24 @@ public class LambdaObserverTest {
139198
final List<Object> received = new ArrayList<>();
140199

141200
AutoDisposingObserver<Object> o =
142-
new AutoDisposingObserver<>(lifecycle, received::add, received::add,
143-
() -> received.add(100), s -> {});
201+
new AutoDisposingObserverImpl<>(lifecycle, new Consumer<Object>() {
202+
@Override public void accept(Object o) throws Exception {
203+
received.add(o);
204+
}
205+
}, new Consumer<Object>() {
206+
@Override public void accept(Object o) throws Exception {
207+
received.add(o);
208+
}
209+
}, new Action() {
210+
211+
@Override public void run() throws Exception {
212+
received.add(100);
213+
}
214+
}, new Consumer<Disposable>() {
215+
@Override public void accept(Disposable disposable) throws Exception {
216+
217+
}
218+
});
144219

145220
source.subscribe(o);
146221

@@ -163,8 +238,23 @@ public class LambdaObserverTest {
163238
final List<Object> received = new ArrayList<>();
164239

165240
AutoDisposingObserver<Object> o =
166-
new AutoDisposingObserver<>(lifecycle, received::add, received::add,
167-
() -> received.add(100), s -> {});
241+
new AutoDisposingObserverImpl<>(lifecycle, new Consumer<Object>() {
242+
@Override public void accept(Object o) throws Exception {
243+
received.add(o);
244+
}
245+
}, new Consumer<Object>() {
246+
@Override public void accept(Object o) throws Exception {
247+
received.add(o);
248+
}
249+
}, new Action() {
250+
251+
@Override public void run() throws Exception {
252+
received.add(100);
253+
}
254+
}, new Consumer<Disposable>() {
255+
@Override public void accept(Disposable disposable) throws Exception {
256+
}
257+
});
168258

169259
source.subscribe(o);
170260

autodispose/src/test/java/com/uber/autodispose/RxErrorsRule.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.uber.autodispose;
22

33
import io.reactivex.exceptions.CompositeException;
4+
import io.reactivex.functions.Consumer;
45
import io.reactivex.plugins.RxJavaPlugins;
56
import java.util.ArrayList;
67
import java.util.List;
@@ -16,13 +17,17 @@
1617
/**
1718
* JUnit rule to record RxJava errors.
1819
*/
19-
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
20-
public class RxErrorsRule extends TestWatcher {
20+
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") public class RxErrorsRule
21+
extends TestWatcher {
2122

2223
private BlockingDeque<Throwable> errors = new LinkedBlockingDeque<>();
2324

2425
@Override protected void starting(Description description) {
25-
RxJavaPlugins.setErrorHandler(t -> errors.add(t));
26+
RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() {
27+
@Override public void accept(Throwable t) throws Exception {
28+
errors.add(t);
29+
}
30+
});
2631
}
2732

2833
@Override protected void finished(Description description) {

0 commit comments

Comments
 (0)