Skip to content

Commit

Permalink
diamond operators in unit tests, observable package (#6786)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvolkovv authored and akarnokd committed Dec 22, 2019
1 parent e162d66 commit d6d6982
Show file tree
Hide file tree
Showing 95 changed files with 675 additions and 672 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void run() {
}

static <T> Iterable<T> next(ObservableSource<T> source) {
return new BlockingObservableNext<T>(source);
return new BlockingObservableNext<>(source);
}

@Test
Expand Down Expand Up @@ -356,7 +356,7 @@ public void remove() {

@Test
public void nextObserverError() {
NextObserver<Integer> no = new NextObserver<Integer>();
NextObserver<Integer> no = new NextObserver<>();

List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Expand All @@ -370,7 +370,7 @@ public void nextObserverError() {

@Test
public void nextObserverOnNext() throws Exception {
NextObserver<Integer> no = new NextObserver<Integer>();
NextObserver<Integer> no = new NextObserver<>();

no.setWaiting();
no.onNext(Notification.createOnNext(1));
Expand All @@ -383,7 +383,7 @@ public void nextObserverOnNext() throws Exception {

@Test
public void nextObserverOnCompleteOnNext() throws Exception {
NextObserver<Integer> no = new NextObserver<Integer>();
NextObserver<Integer> no = new NextObserver<>();

no.setWaiting();
no.onNext(Notification.<Integer>createOnComplete());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void subscribe(Observer<? super String> observer) {

@Test
public void dispose() {
BlockingObservableIterator<Integer> it = new BlockingObservableIterator<Integer>(128);
BlockingObservableIterator<Integer> it = new BlockingObservableIterator<>(128);

assertFalse(it.isDisposed());

Expand All @@ -84,7 +84,7 @@ public void dispose() {

@Test
public void interruptWait() {
BlockingObservableIterator<Integer> it = new BlockingObservableIterator<Integer>(128);
BlockingObservableIterator<Integer> it = new BlockingObservableIterator<>(128);

try {
Thread.currentThread().interrupt();
Expand All @@ -97,14 +97,14 @@ public void interruptWait() {

@Test(expected = NoSuchElementException.class)
public void emptyThrowsNoSuch() {
BlockingObservableIterator<Integer> it = new BlockingObservableIterator<Integer>(128);
BlockingObservableIterator<Integer> it = new BlockingObservableIterator<>(128);
it.onComplete();
it.next();
}

@Test(expected = UnsupportedOperationException.class)
public void remove() {
BlockingObservableIterator<Integer> it = new BlockingObservableIterator<Integer>(128);
BlockingObservableIterator<Integer> it = new BlockingObservableIterator<>(128);
it.remove();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static <T> Builder<T> item(T item) {

@SafeVarargs
public static <T> Builder<T> items(T... items) {
return new Builder<T>(Arrays.asList(items));
return new Builder<>(Arrays.asList(items));
}

public static final class Builder<T> {
Expand All @@ -71,7 +71,7 @@ public Observable<T> error(Throwable e) {
}

public Observable<T> create() {
return new Burst<T>(error, items);
return new Burst<>(error, items);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public Observable<Integer> apply(Boolean t1) {

@Test
public void predicateThrowsExceptionAndValueInCauseMessageObservable() {
TestObserverEx<Boolean> to = new TestObserverEx<Boolean>();
TestObserverEx<Boolean> to = new TestObserverEx<>();

final IllegalArgumentException ex = new IllegalArgumentException();

Expand Down Expand Up @@ -277,7 +277,7 @@ public Observable<Integer> apply(Boolean t1) {

@Test
public void predicateThrowsExceptionAndValueInCauseMessage() {
TestObserverEx<Boolean> to = new TestObserverEx<Boolean>();
TestObserverEx<Boolean> to = new TestObserverEx<>();

final IllegalArgumentException ex = new IllegalArgumentException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public void accept(Disposable d) {
//this stream emits second
Observable<Integer> o2 = Observable.just(1).doOnSubscribe(incrementer)
.delay(100, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.computation());
TestObserver<Integer> to = new TestObserver<Integer>();
TestObserver<Integer> to = new TestObserver<>();
Observable.ambArray(o1, o2).subscribe(to);
to.awaitDone(5, TimeUnit.SECONDS);
to.assertNoErrors();
Expand Down Expand Up @@ -212,7 +212,7 @@ public void ambCancelsOthers() {
PublishSubject<Integer> source2 = PublishSubject.create();
PublishSubject<Integer> source3 = PublishSubject.create();

TestObserver<Integer> to = new TestObserver<Integer>();
TestObserver<Integer> to = new TestObserver<>();

Observable.ambArray(source1, source2, source3).subscribe(to);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public Observable<Integer> apply(Boolean t1) {

@Test
public void predicateThrowsExceptionAndValueInCauseMessageObservable() {
TestObserverEx<Boolean> to = new TestObserverEx<Boolean>();
TestObserverEx<Boolean> to = new TestObserverEx<>();
final IllegalArgumentException ex = new IllegalArgumentException();

Observable.just("Boo!").any(new Predicate<String>() {
Expand Down Expand Up @@ -469,7 +469,7 @@ public Observable<Integer> apply(Boolean t1) {

@Test
public void predicateThrowsExceptionAndValueInCauseMessage() {
TestObserverEx<Boolean> to = new TestObserverEx<Boolean>();
TestObserverEx<Boolean> to = new TestObserverEx<>();
final IllegalArgumentException ex = new IllegalArgumentException();

Observable.just("Boo!").any(new Predicate<String>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void blockingFirstDefault() {

@Test
public void blockingSubscribeConsumer() {
final List<Integer> list = new ArrayList<Integer>();
final List<Integer> list = new ArrayList<>();

Observable.range(1, 5)
.subscribeOn(Schedulers.computation())
Expand All @@ -64,7 +64,7 @@ public void accept(Integer v) throws Exception {

@Test
public void blockingSubscribeConsumerConsumer() {
final List<Object> list = new ArrayList<Object>();
final List<Object> list = new ArrayList<>();

Observable.range(1, 5)
.subscribeOn(Schedulers.computation())
Expand All @@ -80,7 +80,7 @@ public void accept(Integer v) throws Exception {

@Test
public void blockingSubscribeConsumerConsumerError() {
final List<Object> list = new ArrayList<Object>();
final List<Object> list = new ArrayList<>();

TestException ex = new TestException();

Expand All @@ -100,7 +100,7 @@ public void accept(Object v) throws Exception {

@Test
public void blockingSubscribeConsumerConsumerAction() {
final List<Object> list = new ArrayList<Object>();
final List<Object> list = new ArrayList<>();

Consumer<Object> cons = new Consumer<Object>() {
@Override
Expand All @@ -123,7 +123,7 @@ public void run() throws Exception {

@Test
public void blockingSubscribeObserver() {
final List<Object> list = new ArrayList<Object>();
final List<Object> list = new ArrayList<>();

Observable.range(1, 5)
.subscribeOn(Schedulers.computation())
Expand Down Expand Up @@ -156,7 +156,7 @@ public void onComplete() {

@Test
public void blockingSubscribeObserverError() {
final List<Object> list = new ArrayList<Object>();
final List<Object> list = new ArrayList<>();

final TestException ex = new TestException();

Expand Down Expand Up @@ -232,7 +232,7 @@ public void utilityClass() {

@Test
public void disposeUpFront() {
TestObserver<Object> to = new TestObserver<Object>();
TestObserver<Object> to = new TestObserver<>();
to.dispose();
Observable.just(1).blockingSubscribe(to);

Expand All @@ -242,7 +242,7 @@ public void disposeUpFront() {
@SuppressWarnings("rawtypes")
@Test
public void delayed() throws Exception {
final TestObserver<Object> to = new TestObserver<Object>();
final TestObserver<Object> to = new TestObserver<>();
final Observer[] s = { null };

Schedulers.single().scheduleDirect(new Runnable() {
Expand Down Expand Up @@ -271,14 +271,14 @@ protected void subscribeActual(Observer<? super Integer> observer) {

@Test
public void interrupt() {
TestObserver<Object> to = new TestObserver<Object>();
TestObserver<Object> to = new TestObserver<>();
Thread.currentThread().interrupt();
Observable.never().blockingSubscribe(to);
}

@Test
public void onCompleteDelayed() {
TestObserver<Object> to = new TestObserver<Object>();
TestObserver<Object> to = new TestObserver<>();

Observable.empty().delay(100, TimeUnit.MILLISECONDS)
.blockingSubscribe(to);
Expand All @@ -288,7 +288,7 @@ public void onCompleteDelayed() {

@Test
public void blockingCancelUpfront() {
BlockingFirstObserver<Integer> o = new BlockingFirstObserver<Integer>();
BlockingFirstObserver<Integer> o = new BlockingFirstObserver<>();

assertFalse(o.isDisposed());
o.dispose();
Expand Down
Loading

0 comments on commit d6d6982

Please sign in to comment.