lundi 26 août 2019

Verify size of list of completablefutures

I have a code which looks similar to

public void myMethod(){
    List<CompletableFuture<Void>> futures = new ArrayList<>();                

    //getQuestion, getAnswer, both returns a CompletableFuture<Void>
    futures.add(getQuestion());                
    futures.add(getAnswer());

    // make sure all the futures are executed.
    CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()])).join();

}

  • Any pointers on how can I like test if the futures array was of size 2 after the execution of myMethod()*

Aucun commentaire:

Enregistrer un commentaire