There are 2 completable futures cf1
and cf2
defined as follows:
CompletableFuture<Boolean> cf1 = CompletableFuture.completedFuture(true);
CompletableFuture<Boolean> cf2 = CompletableFuture.completedFuture(true);
Technically, one could do:
var result1 = cf1.get();
var result2 = cf2.get();
assertThat(result1).isEqualTo(result2);
For example, if there was only one future, we could do the following:
assertThat(cf1)
.succeedsWithin(Duration.ofSeconds(1))
.isEqualTo(true);
Is there a more idiomatic way to compare the two futures against each other? Note that while the example here uses CompletableFuture<Boolean>
, the Boolean
can be replaced with any class.