2
2
3
3
import org .junit .Test ;
4
4
5
+ import java .util .Arrays ;
5
6
import java .util .Collections ;
6
7
import java .util .List ;
7
8
import java .util .concurrent .CompletableFuture ;
9
+ import java .util .concurrent .CompletionStage ;
8
10
import java .util .concurrent .atomic .AtomicBoolean ;
9
11
10
12
import static java .util .Arrays .asList ;
13
15
import static org .hamcrest .Matchers .equalTo ;
14
16
import static org .hamcrest .Matchers .instanceOf ;
15
17
import static org .hamcrest .Matchers .is ;
18
+ import static org .hamcrest .Matchers .notNullValue ;
16
19
import static org .hamcrest .Matchers .nullValue ;
17
20
import static org .junit .Assert .assertThat ;
18
21
@@ -178,5 +181,35 @@ public void exceptions_are_captured_and_reported() throws Exception {
178
181
179
182
assertThat (promisedValues .toList (), equalTo (asList (1 , null )));
180
183
assertThat (result , equalTo (asList (1 , null )));
181
- }
184
+ }
185
+
186
+ @ Test
187
+ public void type_generics_compile_as_expected () throws Exception {
188
+
189
+ PromisedValues <String > pvList = PromisedValues .allOf (Collections .singletonList (new CompletableFuture <String >()));
190
+ PromisedValues <String > pvList2 = PromisedValues .allOf (Collections .<CompletionStage <String >>singletonList (new CompletableFuture <>()));
191
+
192
+ assertThat (pvList , notNullValue ());
193
+ assertThat (pvList2 , notNullValue ());
194
+
195
+ PromisedValues <String > pv2args = PromisedValues .allOf (new CompletableFuture <>(), new CompletableFuture <>());
196
+ PromisedValues <String > pv3args = PromisedValues .allOf (new CompletableFuture <>(), new CompletableFuture <>(), new CompletableFuture <>());
197
+ PromisedValues <String > pv4args = PromisedValues .allOf (new CompletableFuture <>(), new CompletableFuture <>(), new CompletableFuture <>(), new CompletableFuture <>());
198
+
199
+ assertThat (pv2args , notNullValue ());
200
+ assertThat (pv3args , notNullValue ());
201
+ assertThat (pv4args , notNullValue ());
202
+
203
+ PromisedValues <String > pvListOfPVs = PromisedValues .allPromisedValues (Arrays .asList (pv2args , pv3args ));
204
+
205
+ assertThat (pvListOfPVs , notNullValue ());
206
+
207
+ PromisedValues <String > pv2ArgsOfPVs = PromisedValues .allPromisedValues (pv2args , pv3args );
208
+ PromisedValues <String > pv3ArgsOfPVs = PromisedValues .allPromisedValues (pv2args , pv3args , pv4args );
209
+ PromisedValues <String > pv4ArgsOfPVs = PromisedValues .allPromisedValues (pv2args , pv3args , pv4args , pv2args );
210
+
211
+ assertThat (pv2ArgsOfPVs , notNullValue ());
212
+ assertThat (pv3ArgsOfPVs , notNullValue ());
213
+ assertThat (pv4ArgsOfPVs , notNullValue ());
214
+ }
182
215
}
0 commit comments