Package org.atlanmod.testing
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 EqualsVerifierandVariants(java.lang.Object... variants)Variants are used to create instances oftypethat are different from the reference instance.static voidassertIsEqual(java.lang.Object one, java.lang.Object other)static voidassertIsEqualsToSelf(java.lang.Object one)static voidassertNotEqual(java.lang.Object one, java.lang.Object other)static voidassertNotEqualToNull(java.lang.Object one)voidcheck()Verifies the implementation of methodequals().EqualsVerifierwithArguments(java.lang.Object... arguments)Arguments are used to create a reference instance of classtype.
-
Method Details
-
withArguments
Arguments are used to create a reference instance of classtype. 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 ofargumentsmust match either a visible constructor or a static method (a factory) that returns an instance oftype.- Parameters:
arguments- an array of instances ofObject.- Returns:
- the current verifier.
-
andVariants
Variants are used to create instances oftypethat are different from the reference instance. Each different instance is created with 1 element ofvariants. 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 ofvariantsmust be exactly the same as the length ofarguments. The type of the elements ofvariantscan be different from those ofarguments. 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 methodequals(). -
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)
-