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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidverifyDeserialization(byte[] bytes, Object expected) Verifies that the object deserializes from the bytes to the expected object.static voidverifyDeserialization(SerdesProvider provider, byte[] bytes, Object expectedObject) Verifies that the object deserializes from the bytes to the expected object.static voidverifyDeserialization(SerdesProvider provider, String string, Object expectedObject) Verifies that the object deserializes from the bytes to the expected object.static voidverifyDeserialization(String string, Object expected) Verifies that the object deserializes from the bytes to the expected object.static voidverifySerdes(SerdesProvider provider, Object object) Verifies that the serialized object deserializes properly.static voidverifySerdes(SerdesProvider provider, Object object, byte[] expected) Verifies that the serialized object deserializes properly and that the generated bytes are as expected.static voidverifySerdes(SerdesProvider provider, Object object, String expected) Verifies that the serialized object deserializes properly and that the generated string equals the provided one.static voidverifySerdes(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 voidverifySerdes(Object object) Verifies that the serialized object deserializes properly.static voidverifySerdes(Object object, byte[] expected) Verifies that the serialized object deserializes properly and that the generated bytes are as expected.static voidverifySerdes(Object object, String string) Verifies that the serialized object deserializes properly and that the generated string equals the provided one.static voidverifySerdes(Object object, org.hamcrest.Matcher<String> stringMatcher) Verifies that the serialized object deserializes properly and that the generated string matches the provided matcher.static voidverifySerialization(SerdesProvider provider, Object object, byte[] expected) Verifies that the object serializes to the expected bytes.static voidverifySerialization(SerdesProvider provider, Object object, String expected) Verifies that the object serializes to the expected string.static voidverifySerialization(Object object, byte[] expected) Verifies that the object serializes to the expected bytes.static voidverifySerialization(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 theJacksonJsonSerdesprovider.- 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 theJacksonJsonSerdesprovider.- 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 theJacksonJsonSerdesprovider.- 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- theSerdesProviderto 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- theSerdesProviderto 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 theJacksonJsonSerdesprovider.- 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 theJacksonJsonSerdesprovider.- 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 theJacksonJsonSerdesprovider.- 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 theJacksonJsonSerdesprovider.- 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 theJacksonJsonSerdesprovider.- Parameters:
string- the serialized stringexpected- the expected deserialized object
-