Class EqualsAndHashcodeContractImpl
java.lang.Object
de.cuioss.test.valueobjects.contract.EqualsAndHashcodeContractImpl
- All Implemented Interfaces:
ObjectTestContract
Helper class providing base functionality for test for the
Object.equals(Object)
and Object.hashCode()
variants of
classes.- Author:
- Oliver Wolff
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
assertBasicContractOnEquals
(Object underTest) Verify object has implementedObject.equals(Object)
method.static void
assertBasicContractOnHashCode
(Object underTest) Verify object has implementedObject.hashCode()
method.void
assertContract
(ParameterizedInstantiator<?> instantiator, ObjectTestConfig objectTestConfig) Checks the concrete contract.
-
Constructor Details
-
EqualsAndHashcodeContractImpl
public EqualsAndHashcodeContractImpl()
-
-
Method Details
-
assertContract
public void assertContract(ParameterizedInstantiator<?> instantiator, ObjectTestConfig objectTestConfig) Description copied from interface:ObjectTestContract
Checks the concrete contract.- Specified by:
assertContract
in interfaceObjectTestContract
- Parameters:
instantiator
- must not be null. The actual type of theObject
is not of interest, because we checkObject
contractsobjectTestConfig
- optional configuration configuring the tests
-
assertBasicContractOnEquals
Verify object has implementedObject.equals(Object)
method. In addition it checks whether the basic functionality like- equals(null) will be 'false'
- equals(new Object()) will be 'false'
- underTest.equals(underTest) will be 'true'
- Parameters:
underTest
- object under test
-
assertBasicContractOnHashCode
Verify object has implementedObject.hashCode()
method.- Parameters:
underTest
- object under test
-