Package org.atlanmod.testing
Class EqualsVerifier<T>
- java.lang.Object
-
- org.atlanmod.testing.EqualsVerifier<T>
-
- Type Parameters:
T-
public class EqualsVerifier<T> extends Object
Verifies that theequals()method of a class was correctly implemented, checking that: - An object is not equal tonull- 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description EqualsVerifier<T>andVariants(Object... variants)Variants are used to create instances oftypethat are different from the reference instance.static voidassertIsEqual(Object one, Object other)static voidassertIsEqualsToSelf(Object one)static voidassertNotEqual(Object one, Object other)static voidassertNotEqualToNull(Object one)voidcheck()Verifies the implementation of methodequals().EqualsVerifier<T>withArguments(Object... arguments)Arguments are used to create a reference instance of classtype.
-
-
-
Method Detail
-
withArguments
public EqualsVerifier<T> withArguments(Object... arguments)
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
public EqualsVerifier<T> andVariants(Object... variants)
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().
-
assertNotEqualToNull
public static void assertNotEqualToNull(Object one)
-
assertIsEqualsToSelf
public static void assertIsEqualsToSelf(Object one)
-
-