Class EqualsHashCodeTestUtils

java.lang.Object
org.elasticsearch.test.EqualsHashCodeTestUtils

public class EqualsHashCodeTestUtils
extends java.lang.Object
Utility class that encapsulates standard checks and assertions around testing the equals() and hashCode() methods of objects that implement them.
  • Constructor Details

  • Method Details

    • checkEqualsAndHashCode

      public static <T> void checkEqualsAndHashCode​(T original, EqualsHashCodeTestUtils.CopyFunction<T> copyFunction)
      Perform common equality and hashCode checks on the input object
      Parameters:
      original - the object under test
      copyFunction - a function that creates a deep copy of the input object
    • checkEqualsAndHashCode

      public static <T> void checkEqualsAndHashCode​(T original, EqualsHashCodeTestUtils.CopyFunction<T> copyFunction, EqualsHashCodeTestUtils.MutateFunction<T> mutationFunction)
      Perform common equality and hashCode checks on the input object
      Parameters:
      original - the object under test
      copyFunction - a function that creates a deep copy of the input object
      mutationFunction - a function that creates a copy of the input object that is different from the input in one aspect. The output of this call is used to check that it is not equal() to the input object