@@ -41,7 +41,8 @@ class CompletableFutureUtilsTest {
41
41
42
42
////////////////////////////////////////////////////////////
43
43
// region## Multi-Actions(M*) Methods(create by actions)
44
- ////////////////////////////////////////////////////////////
44
+
45
+ /// /////////////////////////////////////////////////////////
45
46
46
47
@ Test
47
48
void test_mSupply () throws Exception {
@@ -85,13 +86,33 @@ void test_mSupply() throws Exception {
85
86
86
87
@ Test
87
88
void test_mSupply__failure () throws Exception {
88
- assertSame (rte , assertThrowsExactly (ExecutionException .class , () ->
89
- // allResultsOf: the ex of first given cf argument win.
90
- // ❗dependent on the implementation behavior of `CF.allOf`️
91
- mSupplyFailFastAsync (() -> 42 , () -> {
92
- throw rte ;
93
- }).get ()
94
- ).getCause ());
89
+ RuntimeException rte1 = new RuntimeException ("rte1" );
90
+ RuntimeException rte2 = new RuntimeException ("rte2" );
91
+
92
+ assertSame (rte1 , assertThrowsExactly (ExecutionException .class , () -> mSupplyFailFastAsync (
93
+ testExecutor ,
94
+ () -> 42 ,
95
+ supplyLater (rte1 , SHORT_WAIT_MS ),
96
+ supplyLater (rte2 , LONG_WAIT_MS )
97
+ ).get ()).getCause ());
98
+ assertSame (rte2 , assertThrowsExactly (ExecutionException .class , () -> mSupplyFailFastAsync (
99
+ testExecutor ,
100
+ () -> 42 ,
101
+ supplyLater (rte1 , LONG_WAIT_MS ),
102
+ supplyLater (rte2 , SHORT_WAIT_MS )).get ()).getCause ());
103
+ assertEquals (42 , mSupplyAnySuccessAsync (
104
+ testExecutor ,
105
+ () -> 42 ,
106
+ supplyLater (rte1 , SHORT_WAIT_MS ),
107
+ supplyLater (rte2 , LONG_WAIT_MS )
108
+ ).get ());
109
+
110
+ assertEquals (Tuple3 .of (42 , null , null ), mSupplyMostSuccessTupleAsync (
111
+ testExecutor , LONG_WAIT_MS , MILLISECONDS ,
112
+ () -> 42 ,
113
+ supplyLater (rte1 , SHORT_WAIT_MS ),
114
+ supplyLater (rte2 , LONG_WAIT_MS )
115
+ ).get ());
95
116
}
96
117
97
118
@ Test
@@ -120,7 +141,8 @@ void test_mRun() throws Exception {
120
141
// endregion
121
142
////////////////////////////////////////////////////////////
122
143
// region## Multi-Actions-Tuple(MTuple*) Methods(create by actions)
123
- ////////////////////////////////////////////////////////////
144
+
145
+ /// /////////////////////////////////////////////////////////
124
146
125
147
@ Test
126
148
void test_mSupplyMostSuccessTupleAsync () throws Exception {
@@ -233,7 +255,8 @@ void test_mSupplyAllSuccessTupleAsync() throws Exception {
233
255
// endregion
234
256
////////////////////////////////////////////////////////////
235
257
// region## allOf* Methods(including mostSuccessResultsOf)
236
- ////////////////////////////////////////////////////////////
258
+
259
+ /// /////////////////////////////////////////////////////////
237
260
238
261
@ Test
239
262
void test_allOf_methods__success__trivial_case () throws Exception {
@@ -591,7 +614,8 @@ void test_mostOf_wontModifyInputCf() throws Exception {
591
614
// endregion
592
615
////////////////////////////////////////////////////////////
593
616
// region## anyOf* Methods
594
- ////////////////////////////////////////////////////////////
617
+
618
+ /// /////////////////////////////////////////////////////////
595
619
596
620
@ Test
597
621
void test_anyOf_anySuccessOf__trivial_case () throws Exception {
@@ -817,7 +841,8 @@ void test_anyOf__concurrent() throws Exception {
817
841
// endregion
818
842
////////////////////////////////////////////////////////////
819
843
// region## allTupleOf*/mostSuccessTupleOf Methods
820
- ////////////////////////////////////////////////////////////
844
+
845
+ /// /////////////////////////////////////////////////////////
821
846
822
847
@ Test
823
848
void test_allTupleOf () throws Exception {
@@ -966,7 +991,8 @@ void test_mostSuccessTupleOf() throws Exception {
966
991
// endregion
967
992
////////////////////////////////////////////////////////////
968
993
// region## Immediate Value Argument Factory Methods(backport methods)
969
- ////////////////////////////////////////////////////////////
994
+
995
+ /// /////////////////////////////////////////////////////////
970
996
971
997
@ Test
972
998
void test_failedFuture () throws Exception {
@@ -978,7 +1004,8 @@ void test_failedFuture() throws Exception {
978
1004
// endregion
979
1005
////////////////////////////////////////////////////////////
980
1006
// region## Delay Execution(backport methods)
981
- ////////////////////////////////////////////////////////////
1007
+
1008
+ /// /////////////////////////////////////////////////////////
982
1009
983
1010
@ Test
984
1011
void test_delayedExecutor () throws Exception {
@@ -997,7 +1024,8 @@ void test_delayedExecutor() throws Exception {
997
1024
998
1025
////////////////////////////////////////////////////////////
999
1026
// region## Then-Multi-Actions(thenM*) Methods
1000
- ////////////////////////////////////////////////////////////
1027
+
1028
+ /// /////////////////////////////////////////////////////////
1001
1029
1002
1030
@ Test
1003
1031
void test_thenMRun () throws Exception {
@@ -1095,7 +1123,8 @@ void test_thenMApply() throws Exception {
1095
1123
// endregion
1096
1124
////////////////////////////////////////////////////////////
1097
1125
// region## Then-Multi-Actions-Tuple(thenMTuple*) Methods
1098
- ////////////////////////////////////////////////////////////
1126
+
1127
+ /// /////////////////////////////////////////////////////////
1099
1128
1100
1129
@ Test
1101
1130
void test_thenTuple_methods () throws Exception {
@@ -1183,7 +1212,8 @@ void test_thenTuple_methods() throws Exception {
1183
1212
// endregion
1184
1213
////////////////////////////////////////////////////////////
1185
1214
// region## thenBoth* Methods(binary input) with fail-fast support
1186
- ////////////////////////////////////////////////////////////
1215
+
1216
+ /// /////////////////////////////////////////////////////////
1187
1217
1188
1218
@ Test
1189
1219
void test_both () throws Exception {
@@ -1305,7 +1335,8 @@ void bothFailFast() throws Exception {
1305
1335
// endregion
1306
1336
////////////////////////////////////////////////////////////
1307
1337
// region## thenEither* Methods(binary input) with either(any)-success support
1308
- ////////////////////////////////////////////////////////////
1338
+
1339
+ /// /////////////////////////////////////////////////////////
1309
1340
1310
1341
@ Test
1311
1342
void test_either () throws Exception {
@@ -1391,7 +1422,8 @@ void test_either_success() throws Exception {
1391
1422
// endregion
1392
1423
////////////////////////////////////////////////////////////
1393
1424
// region## Error Handling Methods of CompletionStage
1394
- ////////////////////////////////////////////////////////////
1425
+
1426
+ /// /////////////////////////////////////////////////////////
1395
1427
1396
1428
@ Test
1397
1429
void test_exceptionallyAsync () throws Exception {
@@ -1453,7 +1485,8 @@ private static void test_catching_failedCf(CompletableFuture<Integer> failed) th
1453
1485
////////////////////////////////////////////////////////////////////////////////
1454
1486
//# Backport CF methods
1455
1487
// compatibility for low Java version
1456
- ////////////////////////////////////////////////////////////////////////////////
1488
+
1489
+ /// /////////////////////////////////////////////////////////////////////////////
1457
1490
1458
1491
@ Test
1459
1492
void test_timeout () throws Exception {
@@ -1545,7 +1578,8 @@ void test_safeBehavior_completeOnTimeout() {
1545
1578
// endregion
1546
1579
////////////////////////////////////////////////////////////
1547
1580
// region## Advanced Methods of CompletionStage(compose* and handle-like methods)
1548
- ////////////////////////////////////////////////////////////
1581
+
1582
+ /// /////////////////////////////////////////////////////////
1549
1583
1550
1584
@ Test
1551
1585
void test_exceptionallyCompose () throws Exception {
@@ -1630,7 +1664,8 @@ void test_peek() throws Exception {
1630
1664
// endregion
1631
1665
////////////////////////////////////////////////////////////
1632
1666
// region## Read(explicitly)/Write Methods of CompletableFuture(including Future)
1633
- ////////////////////////////////////////////////////////////
1667
+
1668
+ /// /////////////////////////////////////////////////////////
1634
1669
1635
1670
@ Test
1636
1671
@ SuppressWarnings ("ThrowableNotThrown" )
@@ -1851,7 +1886,8 @@ void test_write() throws Exception {
1851
1886
// endregion
1852
1887
////////////////////////////////////////////////////////////
1853
1888
// region## Re-Config Methods of CompletableFuture
1854
- ////////////////////////////////////////////////////////////
1889
+
1890
+ /// /////////////////////////////////////////////////////////
1855
1891
1856
1892
@ Test
1857
1893
void test_re_config () throws Exception {
@@ -1935,7 +1971,7 @@ void test_unwrapCfException() {
1935
1971
// endregion
1936
1972
////////////////////////////////////////////////////////////////////////////////
1937
1973
// region# Test helper fields
1938
- ////////////////////////////////////////////////////////////////////////////////
1974
+ /// /////////////////////////////////////////////////////////////////////////////
1939
1975
1940
1976
private static final String testName = "CompletableFutureUtilsTest" ;
1941
1977
}
0 commit comments