Class AbstractFutureAssert<SELF extends AbstractFutureAssert<SELF,ACTUAL,RESULT>,ACTUAL extends Future<RESULT>,RESULT>

java.lang.Object
org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
org.assertj.core.api.AbstractFutureAssert<SELF,ACTUAL,RESULT>
All Implemented Interfaces:
Assert<SELF,ACTUAL>, Descriptable<SELF>, ExtensionPoints<SELF,ACTUAL>
Direct Known Subclasses:
FutureAssert

public abstract class AbstractFutureAssert<SELF extends AbstractFutureAssert<SELF,ACTUAL,RESULT>,ACTUAL extends Future<RESULT>,RESULT> extends AbstractAssert<SELF,ACTUAL>
  • Field Details

  • Constructor Details

    • AbstractFutureAssert

      protected AbstractFutureAssert(ACTUAL actual, Class<?> selfType)
  • Method Details

    • isCancelled

      public SELF isCancelled()
      Verifies that the Future is cancelled.

      Example:

       ExecutorService executorService = Executors.newSingleThreadExecutor();
                                                                              
       Future<String> future = executorService.submit(new Callable<String>() {
         @Override                                                            
         public String call() throws Exception {                              
           return "done";                                                     
         }                                                                    
       });                                                                    
                                                                              
       // assertion will fail:
       assertThat(future).isCancelled();
       
       // assertion will pass:
       future.cancel(true);
       assertThat(future).isCancelled();
      Returns:
      this assertion object.
      Since:
      2.7.0 / 3.7.0
      See Also:
    • isNotCancelled

      public SELF isNotCancelled()
      Verifies that the Future is not cancelled.

      Example:

       ExecutorService executorService = Executors.newSingleThreadExecutor();
                                                                              
       Future<String> future = executorService.submit(new Callable<String>() {
         @Override                                                            
         public String call() throws Exception {                              
           return "done";                                                     
         }                                                                    
       });                                                                    
                                                                              
       // assertion will pass:
       assertThat(future).isNotCancelled();
      
       // assertion will fail:
       future.cancel(true);
       assertThat(future).isNotCancelled();
      Returns:
      this assertion object.
      Since:
      2.7.0 / 3.7.0
      See Also:
    • isDone

      public SELF isDone()
      Verifies that the Future is done.

      Example:

       ExecutorService executorService = Executors.newSingleThreadExecutor();
                                                                              
       Future<String> future = executorService.submit(new Callable<String>() {
         @Override                                                            
         public String call() throws Exception {                              
           return "done";                                                     
         }                                                                    
       });                                                                    
                                                                              
       // assertion will pass:
       assertThat(future).isDone();
      
       future = executorService.submit(new Callable<String>() {
         @Override                                                            
         public String call() throws Exception {                              
           Thread.sleep(1000);
           return "done";                                                     
         }                                                                    
       });                                                                    
                                                                              
       // assertion will fail:
       assertThat(future).isDone();
      Returns:
      this assertion object.
      Since:
      2.7.0 / 3.7.0
      See Also:
    • isNotDone

      public SELF isNotDone()
      Verifies that the Future is not done.

      Example:

       ExecutorService executorService = Executors.newSingleThreadExecutor();
                                                                              
       Future<String> future = executorService.submit(new Callable<String>() {
         @Override                                                            
         public String call() throws Exception {                              
           Thread.sleep(1000);
           return "done";                                                     
         }                                                                    
       });
                                                                           
       // assertion will pass:
       assertThat(future).isNotDone();
                                                                              
       future = executorService.submit(new Callable<String>() {
         @Override                                                            
         public String call() throws Exception {                              
           return "done";                                                     
         }                                                                    
       });                                                             
      
       // assertion will fail:
       assertThat(future).isNotDone();
      Returns:
      this assertion object.
      Since:
      2.7.0 / 3.7.0
      See Also: