Class SerdesVerifiers
java.lang.Object
io.github.cjstehno.testthings.serdes.SerdesVerifiers
Test result verifiers useful for working with serialization and deserialization (serdes).
Most of these verifier methods take a SerdesProvider
, though there are some which do not - they are provided
as simplifications using the JacksonJsonSerdes
provider, since JSON tends to be a very common data format.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
verifyDeserialization
(byte[] bytes, Object expected) Verifies that the object deserializes from the bytes to the expected object.static void
verifyDeserialization
(SerdesProvider provider, byte[] bytes, Object expectedObject) Verifies that the object deserializes from the bytes to the expected object.static void
verifyDeserialization
(SerdesProvider provider, String string, Object expectedObject) Verifies that the object deserializes from the bytes to the expected object.static void
verifyDeserialization
(String string, Object expected) Verifies that the object deserializes from the bytes to the expected object.static void
verifySerdes
(SerdesProvider provider, Object object) Verifies that the serialized object deserializes properly.static void
verifySerdes
(SerdesProvider provider, Object object, byte[] expected) Verifies that the serialized object deserializes properly and that the generated bytes are as expected.static void
verifySerdes
(SerdesProvider provider, Object object, String expected) Verifies that the serialized object deserializes properly and that the generated string equals the provided one.static void
verifySerdes
(SerdesProvider provider, Object object, org.hamcrest.Matcher<String> stringMatcher) Verifies that the serialized object deserializes properly and that the generated string matches the provided matcher.static void
verifySerdes
(Object object) Verifies that the serialized object deserializes properly.static void
verifySerdes
(Object object, byte[] expected) Verifies that the serialized object deserializes properly and that the generated bytes are as expected.static void
verifySerdes
(Object object, String string) Verifies that the serialized object deserializes properly and that the generated string equals the provided one.static void
verifySerdes
(Object object, org.hamcrest.Matcher<String> stringMatcher) Verifies that the serialized object deserializes properly and that the generated string matches the provided matcher.static void
verifySerialization
(SerdesProvider provider, Object object, byte[] expected) Verifies that the object serializes to the expected bytes.static void
verifySerialization
(SerdesProvider provider, Object object, String expected) Verifies that the object serializes to the expected string.static void
verifySerialization
(Object object, byte[] expected) Verifies that the object serializes to the expected bytes.static void
verifySerialization
(Object object, String expected) Verifies that the object serializes to the expected string.
-
Constructor Details
-
SerdesVerifiers
public SerdesVerifiers()
-
-
Method Details
-
verifySerdes
Verifies that the serialized object deserializes properly and that the generated bytes are as expected.- Parameters:
provider
- the serdes providerobject
- the object to be verifiedexpected
- the expected byte array
-
verifySerdes
Verifies that the serialized object deserializes properly and that the generated bytes are as expected. This verifier uses theJacksonJsonSerdes
provider.- Parameters:
object
- the object to be verifiedexpected
- the expected byte array
-
verifySerdes
Verifies that the serialized object deserializes properly.- Parameters:
provider
- the serdes providerobject
- the object to be verified
-
verifySerdes
Verifies that the serialized object deserializes properly. This verifier uses theJacksonJsonSerdes
provider.- Parameters:
object
- the object to be verified
-
verifySerdes
Verifies that the serialized object deserializes properly and that the generated string equals the provided one. This verifier uses theJacksonJsonSerdes
provider.- Parameters:
object
- the object to be verifiedstring
- the serialized JSON string
-
verifySerdes
Verifies that the serialized object deserializes properly and that the generated string equals the provided one.- Parameters:
provider
- theSerdesProvider
to be usedobject
- the object to be verifiedexpected
- the serialized JSON string
-
verifySerdes
public static void verifySerdes(SerdesProvider provider, Object object, org.hamcrest.Matcher<String> stringMatcher) Verifies that the serialized object deserializes properly and that the generated string matches the provided matcher.- Parameters:
provider
- theSerdesProvider
to be usedobject
- the object to be verifiedstringMatcher
- the matcher used to verify the resulting serialized string
-
verifySerdes
Verifies that the serialized object deserializes properly and that the generated string matches the provided matcher. This verifier uses theJacksonJsonSerdes
provider.- Parameters:
object
- the object to be verifiedstringMatcher
- the matcher used to verify the resulting serialized string
-
verifySerialization
Verifies that the object serializes to the expected bytes.- Parameters:
provider
- the serdes providerobject
- the object to be verifiedexpected
- the expected byte array
-
verifySerialization
Verifies that the object serializes to the expected bytes. This verifier uses theJacksonJsonSerdes
provider.- Parameters:
object
- the object to be verifiedexpected
- the expected byte array
-
verifySerialization
Verifies that the object serializes to the expected string.- Parameters:
provider
- the serdes providerobject
- the object to be verifiedexpected
- the expected string
-
verifySerialization
Verifies that the object serializes to the expected string. This verifier uses theJacksonJsonSerdes
provider.- Parameters:
object
- the object to be verifiedexpected
- the expected string
-
verifyDeserialization
public static void verifyDeserialization(SerdesProvider provider, byte[] bytes, Object expectedObject) Verifies that the object deserializes from the bytes to the expected object.- Parameters:
provider
- the serdes providerbytes
- the serialized bytesexpectedObject
- the expected deserialized object
-
verifyDeserialization
Verifies that the object deserializes from the bytes to the expected object. This verifier uses theJacksonJsonSerdes
provider.- Parameters:
bytes
- the serialized bytesexpected
- the expected deserialized object
-
verifyDeserialization
public static void verifyDeserialization(SerdesProvider provider, String string, Object expectedObject) Verifies that the object deserializes from the bytes to the expected object.- Parameters:
provider
- the serdes providerstring
- the serialized stringexpectedObject
- the expected deserialized object
-
verifyDeserialization
Verifies that the object deserializes from the bytes to the expected object. This verifier uses theJacksonJsonSerdes
provider.- Parameters:
string
- the serialized stringexpected
- the expected deserialized object
-