Class EqualsVerifier<T>

java.lang.Object
org.atlanmod.testing.EqualsVerifier<T>
Type Parameters:
T -

public class EqualsVerifier<T>
extends java.lang.Object
Verifies that the equals() method of a class was correctly implemented, checking that: - An object is not equal to null - An object is equal to self - An object is equal to another similar object (created with the same arguments) - An object is not equal to objects created with different arguments
  • Method Summary

    Modifier and Type Method Description
    EqualsVerifier andVariants​(java.lang.Object... variants)
    Variants are used to create instances of type that are different from the reference instance.
    static void assertIsEqual​(java.lang.Object one, java.lang.Object other)  
    static void assertIsEqualsToSelf​(java.lang.Object one)  
    static void assertNotEqual​(java.lang.Object one, java.lang.Object other)  
    static void assertNotEqualToNull​(java.lang.Object one)  
    void check()
    Verifies the implementation of method equals().
    EqualsVerifier withArguments​(java.lang.Object... arguments)
    Arguments are used to create a reference instance of class type.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • withArguments

      public EqualsVerifier withArguments​(java.lang.Object... arguments)
      Arguments are used to create a reference instance of class type. The reference instance is used to the comparisons to self, null and to another instance created with the same arguments. The types and the length of arguments must match either a visible constructor or a static method (a factory) that returns an instance of type.
      Parameters:
      arguments - an array of instances of Object.
      Returns:
      the current verifier.
    • andVariants

      public EqualsVerifier andVariants​(java.lang.Object... variants)
      Variants are used to create instances of type that are different from the reference instance. Each different instance is created with 1 element of variants. For instance, if arguments = {a, b, c} and variants = {d, e, f}, three different instances will be created: - Type(d, b, c) - Type(a, e, c) and - Type(a, b, f) The length of variants must be exactly the same as the length of arguments. The type of the elements of variants can be different from those of arguments. However, they must be able to assign the correspondent parameter of the constructor or factory method.
      Parameters:
      variants -
      Returns:
    • check

      public void check()
      Verifies the implementation of method equals().
    • assertIsEqual

      public static void assertIsEqual​(java.lang.Object one, java.lang.Object other)
    • assertNotEqual

      public static void assertNotEqual​(java.lang.Object one, java.lang.Object other)
    • assertNotEqualToNull

      public static void assertNotEqualToNull​(java.lang.Object one)
    • assertIsEqualsToSelf

      public static void assertIsEqualsToSelf​(java.lang.Object one)