Debian Codegraph @

src/test/java/io/reactivex/rxjava3/observable/ObservableCombineLatestTests.java

raw
1 /*
2 * Copyright (c) 2016-present, RxJava Contributors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5 * compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is
10 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
11 * the License for the specific language governing permissions and limitations under the License.
12 */
13
14 package io.reactivex.rxjava3.observable;
15
16 import org.junit.Test;
17
18 import io.reactivex.rxjava3.core.*;
19 import io.reactivex.rxjava3.functions.*;
20 import io.reactivex.rxjava3.observable.ObservableCovarianceTest.*;
21
22 public class ObservableCombineLatestTests extends RxJavaTest {
23 /**
24 * This won't compile if super/extends isn't done correctly on generics.
25 */
26 @Test
27 public void covarianceOfCombineLatest() {
28 Observable<HorrorMovie> horrors = Observable.just(new HorrorMovie());
29 Observable<CoolRating> ratings = Observable.just(new CoolRating());
30
31 Observable.<Movie, CoolRating, Result> combineLatest(horrors, ratings, combine).blockingForEach(action);
32 Observable.<Movie, CoolRating, Result> combineLatest(horrors, ratings, combine).blockingForEach(action);
33 Observable.<Media, Rating, ExtendedResult> combineLatest(horrors, ratings, combine).blockingForEach(extendedAction);
34 Observable.<Media, Rating, Result> combineLatest(horrors, ratings, combine).blockingForEach(action);
35 Observable.<Media, Rating, ExtendedResult> combineLatest(horrors, ratings, combine).blockingForEach(action);
36
37 Observable.<Movie, CoolRating, Result> combineLatest(horrors, ratings, combine);
38 }
39
40 BiFunction<Media, Rating, ExtendedResult> combine = new BiFunction<Media, Rating, ExtendedResult>() {
41 @Override
42 public ExtendedResult apply(Media m, Rating r) {
43 return new ExtendedResult();
44 }
45 };
46
47 Consumer<Result> action = new Consumer<Result>() {
48 @Override
49 public void accept(Result t1) {
50 System.out.println("Result: " + t1);
51 }
52 };
53
54 Consumer<ExtendedResult> extendedAction = new Consumer<ExtendedResult>() {
55 @Override
56 public void accept(ExtendedResult t1) {
57 System.out.println("Result: " + t1);
58 }
59 };
60 }