Class SerializableContractImpl
java.lang.Object
de.cuioss.test.valueobjects.contract.SerializableContractImpl
- All Implemented Interfaces:
ObjectTestContract
Tests whether the object in hand implements
Serializable
and than
serializes / deserializes the object, and compares the newly created object
with the original by using Object.equals(Object)
- Author:
- Oliver Wolff
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
assertContract
(ParameterizedInstantiator<?> instantiator, ObjectTestConfig objectTestConfig) Checks the concrete contract.static final Object
deserializeObject
(byte[] bytes) Deserializes an object from a given byte-arraystatic final Object
serializeAndDeserialize
(Object object) Shorthand combining the callsserializeObject(Object)
deserializeObject(byte[])
static final byte[]
serializeObject
(Object object) Serializes an object into a newly created byteArray
-
Constructor Details
-
SerializableContractImpl
public SerializableContractImpl()
-
-
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
-
serializeAndDeserialize
Shorthand combining the callsserializeObject(Object)
deserializeObject(byte[])
- Parameters:
object
- to be serialized, must not be null- Returns:
- the deserialized object.
-
serializeObject
Serializes an object into a newly created byteArray- Parameters:
object
- to be serialized- Returns:
- the resulting byte array
-
deserializeObject
Deserializes an object from a given byte-array- Parameters:
bytes
- to be deserialized- Returns:
- the deserialized object
-