3203 |
|
final CompletableFuture<Integer> v42 = CompletableFuture.completedFuture(42); |
3204 |
|
final CompletableFuture<Integer> incomplete = new CompletableFuture<>(); |
3205 |
|
|
3206 |
< |
List<Function<CompletableFuture<Integer>, CompletableFuture<?>>> dependentFactories |
3206 |
> |
List<Function<CompletableFuture<Integer>, CompletableFuture<?>>> funs |
3207 |
|
= new ArrayList<>(); |
3208 |
|
|
3209 |
< |
dependentFactories.add((y) -> m.thenRun(y, new Noop(m))); |
3210 |
< |
dependentFactories.add((y) -> m.thenAccept(y, new NoopConsumer(m))); |
3211 |
< |
dependentFactories.add((y) -> m.thenApply(y, new IncFunction(m))); |
3209 |
> |
funs.add((y) -> m.thenRun(y, new Noop(m))); |
3210 |
> |
funs.add((y) -> m.thenAccept(y, new NoopConsumer(m))); |
3211 |
> |
funs.add((y) -> m.thenApply(y, new IncFunction(m))); |
3212 |
|
|
3213 |
< |
dependentFactories.add((y) -> m.runAfterEither(y, incomplete, new Noop(m))); |
3214 |
< |
dependentFactories.add((y) -> m.acceptEither(y, incomplete, new NoopConsumer(m))); |
3215 |
< |
dependentFactories.add((y) -> m.applyToEither(y, incomplete, new IncFunction(m))); |
3213 |
> |
funs.add((y) -> m.runAfterEither(y, incomplete, new Noop(m))); |
3214 |
> |
funs.add((y) -> m.acceptEither(y, incomplete, new NoopConsumer(m))); |
3215 |
> |
funs.add((y) -> m.applyToEither(y, incomplete, new IncFunction(m))); |
3216 |
|
|
3217 |
< |
dependentFactories.add((y) -> m.runAfterBoth(y, v42, new Noop(m))); |
3218 |
< |
dependentFactories.add((y) -> m.thenAcceptBoth(y, v42, new SubtractAction(m))); |
3219 |
< |
dependentFactories.add((y) -> m.thenCombine(y, v42, new SubtractFunction(m))); |
3217 |
> |
funs.add((y) -> m.runAfterBoth(y, v42, new Noop(m))); |
3218 |
> |
funs.add((y) -> m.thenAcceptBoth(y, v42, new SubtractAction(m))); |
3219 |
> |
funs.add((y) -> m.thenCombine(y, v42, new SubtractFunction(m))); |
3220 |
|
|
3221 |
< |
dependentFactories.add((y) -> m.whenComplete(y, (Integer x, Throwable t) -> {})); |
3221 |
> |
funs.add((y) -> m.whenComplete(y, (Integer x, Throwable t) -> {})); |
3222 |
|
|
3223 |
< |
dependentFactories.add((y) -> m.thenCompose(y, new CompletableFutureInc(m))); |
3223 |
> |
funs.add((y) -> m.thenCompose(y, new CompletableFutureInc(m))); |
3224 |
|
|
3225 |
< |
dependentFactories.add((y) -> CompletableFuture.allOf(new CompletableFuture<?>[] {y, v42})); |
3226 |
< |
dependentFactories.add((y) -> CompletableFuture.anyOf(new CompletableFuture<?>[] {y, incomplete})); |
3225 |
> |
funs.add((y) -> CompletableFuture.allOf(new CompletableFuture<?>[] {y, v42})); |
3226 |
> |
funs.add((y) -> CompletableFuture.anyOf(new CompletableFuture<?>[] {y, incomplete})); |
3227 |
|
|
3228 |
|
for (Function<CompletableFuture<Integer>, CompletableFuture<?>> |
3229 |
< |
dependentFactory : dependentFactories) { |
3229 |
> |
fun : funs) { |
3230 |
|
CompletableFuture<Integer> f = new CompletableFuture<>(); |
3231 |
|
f.completeExceptionally(ex); |
3232 |
|
CompletableFuture<Integer> src = m.thenApply(f, new IncFunction(m)); |
3233 |
|
checkCompletedWithWrappedException(src, ex); |
3234 |
< |
CompletableFuture<?> dep = dependentFactory.apply(src); |
3234 |
> |
CompletableFuture<?> dep = fun.apply(src); |
3235 |
|
checkCompletedWithWrappedException(dep, ex); |
3236 |
|
assertSame(resultOf(src), resultOf(dep)); |
3237 |
|
} |
3238 |
|
|
3239 |
|
for (Function<CompletableFuture<Integer>, CompletableFuture<?>> |
3240 |
< |
dependentFactory : dependentFactories) { |
3240 |
> |
fun : funs) { |
3241 |
|
CompletableFuture<Integer> f = new CompletableFuture<>(); |
3242 |
|
CompletableFuture<Integer> src = m.thenApply(f, new IncFunction(m)); |
3243 |
< |
CompletableFuture<?> dep = dependentFactory.apply(src); |
3243 |
> |
CompletableFuture<?> dep = fun.apply(src); |
3244 |
|
f.completeExceptionally(ex); |
3245 |
|
checkCompletedWithWrappedException(src, ex); |
3246 |
|
checkCompletedWithWrappedException(dep, ex); |
3249 |
|
|
3250 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
3251 |
|
for (Function<CompletableFuture<Integer>, CompletableFuture<?>> |
3252 |
< |
dependentFactory : dependentFactories) { |
3252 |
> |
fun : funs) { |
3253 |
|
CompletableFuture<Integer> f = new CompletableFuture<>(); |
3254 |
|
f.cancel(mayInterruptIfRunning); |
3255 |
|
checkCancelled(f); |
3256 |
|
CompletableFuture<Integer> src = m.thenApply(f, new IncFunction(m)); |
3257 |
|
checkCompletedWithWrappedCancellationException(src); |
3258 |
< |
CompletableFuture<?> dep = dependentFactory.apply(src); |
3258 |
> |
CompletableFuture<?> dep = fun.apply(src); |
3259 |
|
checkCompletedWithWrappedCancellationException(dep); |
3260 |
|
assertSame(resultOf(src), resultOf(dep)); |
3261 |
|
} |
3262 |
|
|
3263 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
3264 |
|
for (Function<CompletableFuture<Integer>, CompletableFuture<?>> |
3265 |
< |
dependentFactory : dependentFactories) { |
3265 |
> |
fun : funs) { |
3266 |
|
CompletableFuture<Integer> f = new CompletableFuture<>(); |
3267 |
|
CompletableFuture<Integer> src = m.thenApply(f, new IncFunction(m)); |
3268 |
< |
CompletableFuture<?> dep = dependentFactory.apply(src); |
3268 |
> |
CompletableFuture<?> dep = fun.apply(src); |
3269 |
|
f.cancel(mayInterruptIfRunning); |
3270 |
|
checkCancelled(f); |
3271 |
|
checkCompletedWithWrappedCancellationException(src); |