Class JUnitAssertArrayEqualsToAssertThat


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

    This visitor will handle the following JUnit 5 method signatures:

     Two parameter variants:
     

    assertArrayEquals(expected,actual) == assertThat(actual).containsExactly(expected)

    Three parameter variant where the third argument is a String:

    assertArrayEquals(expected, actual, "message") == assertThat(actual).as("message").containsExactly(expected)

    Three parameter variant where the third argument is a String supplier:

    assertArrayEquals(expected, actual, () == "message") == assertThat(actual).withFailureMessage("message").containsExactly(expected)

    Three parameter variant where args are all floating point numbers.

    assertArrayEquals(expected, actual, delta) == assertThat(actual).containsExactly(expected, within(delta));

    Four parameter variant when comparing floating point numbers with a delta and a message:

    assertArrayEquals(expected, actual, delta, "message") == assertThat(actual).withFailureMessage("message").containsExactly(expected, within(delta));

    • 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

        causesAnotherCycle, 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

      • JUnitAssertArrayEqualsToAssertThat

        public JUnitAssertArrayEqualsToAssertThat()
    • 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