title: How to unit test CompletableFuture.thenAccept() by avoiding manual sleep
body: <p>How to avoid manual sleep in unit test. 
  Suppose In below code the <code>Process</code> and <code>notify</code> takes around 5 seconds for processing. So in order to complete the processing, i have added sleep of 5 seconds. </p>
  
  <pre><code>public class ClassToTest {
  
      public ProcessService processService;
      public NotificationService notificationService;
  
      public ClassToTest(ProcessService pService ,NotificationService nService ) {
          this.notificationService=nService;
          this.processService = pService;
      }
      public CompletableFuture&lt;Void&gt; testMethod()
      {
            return CompletableFuture.supplyAsync(processService::process)
                          .thenAccept(notificationService::notify);
      }
  
  }
  </code></pre>
  
  <p>is there any better way to handle this ?    </p>
  
  <pre><code> @Test
      public void comletableFutureThenAccept() {
           CompletableFuture&lt;Void&gt; thenAccept = 
            sleep(6);
            assertTrue(thenAccept.isDone());  
            verify(mocknotificationService, times(1)).notify(Mockito.anystring());
      }
  </code></pre>