Class JUnitAssertFalseToAssertThat


  • public class JUnitAssertFalseToAssertThat
    extends org.openrewrite.Recipe
    This is a refactoring visitor that will convert JUnit-style assertFalse() to assertJ's assertThat().isFalse().

    This visitor only supports the migration of the following JUnit 5 assertFalse() methods:

     assertFalse(boolean condition) == assertThat(condition).isFalse()
     assertFalse(boolean condition, String message) == assertThat(condition).as(message).isFalse();
     assertFalse(boolean condition, Supplier messageSupplier) == assertThat(condition).withFailMessage(messageSupplier).isFalse();
     

    Note: There are three additional method signatures in JUnit that use a BooleanSupplier for the condition. Attempts to map these signatures into assertJ's model obfuscates the original assertion. It would be possible to use a shim method to support these method signatures, however, those shims would need to exist on each compilation unit or in a shared testing utilities library.

    • Field Summary

      • Fields inherited from class org.openrewrite.Recipe

        NOOP
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getDescription()  
      java.lang.String getDisplayName()  
      protected org.openrewrite.TreeVisitor<?,​org.openrewrite.ExecutionContext> getVisitor()  
      • Methods inherited from class org.openrewrite.Recipe

        doNext, equals, getApplicableTest, getDescriptor, getJacksonPolymorphicTypeTag, getLanguages, getName, getRecipeList, getTags, hashCode, run, run, run, run, validate, validate, validateAll, validateAll, visit
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JUnitAssertFalseToAssertThat

        public JUnitAssertFalseToAssertThat()
    • Method Detail

      • getDisplayName

        public java.lang.String getDisplayName()
        Specified by:
        getDisplayName in class org.openrewrite.Recipe
      • getDescription

        public java.lang.String getDescription()
        Overrides:
        getDescription in class org.openrewrite.Recipe
      • getVisitor

        protected org.openrewrite.TreeVisitor<?,​org.openrewrite.ExecutionContext> getVisitor()
        Overrides:
        getVisitor in class org.openrewrite.Recipe