Waiter waiter = new Waiter(); CompletableFuture<Connection> future = someService.connect(); future.whenComplete((connection, failure) -> { // Called from some other thread waiter.assertNotNull(connection); waiter.assertNull(failure); waiter.resume(); }); // Block the main test thread waiter.await();