Class SerdesVerifiers

java.lang.Object
io.github.cjstehno.testthings.serdes.SerdesVerifiers

public final class SerdesVerifiers extends Object
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 Details

    • SerdesVerifiers

      public SerdesVerifiers()
  • Method Details

    • verifySerdes

      public static void verifySerdes(SerdesProvider provider, Object object, byte[] expected)
      Verifies that the serialized object deserializes properly and that the generated bytes are as expected.
      Parameters:
      provider - the serdes provider
      object - the object to be verified
      expected - the expected byte array
    • verifySerdes

      public static void verifySerdes(Object object, byte[] expected)
      Verifies that the serialized object deserializes properly and that the generated bytes are as expected. This verifier uses the JacksonJsonSerdes provider.
      Parameters:
      object - the object to be verified
      expected - the expected byte array
    • verifySerdes

      public static void verifySerdes(SerdesProvider provider, Object object)
      Verifies that the serialized object deserializes properly.
      Parameters:
      provider - the serdes provider
      object - the object to be verified
    • verifySerdes

      public static void verifySerdes(Object object)
      Verifies that the serialized object deserializes properly. This verifier uses the JacksonJsonSerdes provider.
      Parameters:
      object - the object to be verified
    • verifySerdes

      public static void verifySerdes(Object object, String string)
      Verifies that the serialized object deserializes properly and that the generated string equals the provided one. This verifier uses the JacksonJsonSerdes provider.
      Parameters:
      object - the object to be verified
      string - the serialized JSON string
    • verifySerdes

      public 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.
      Parameters:
      provider - the SerdesProvider to be used
      object - the object to be verified
      expected - 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 - the SerdesProvider to be used
      object - the object to be verified
      stringMatcher - the matcher used to verify the resulting serialized string
    • verifySerdes

      public 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. This verifier uses the JacksonJsonSerdes provider.
      Parameters:
      object - the object to be verified
      stringMatcher - the matcher used to verify the resulting serialized string
    • verifySerialization

      public static void verifySerialization(SerdesProvider provider, Object object, byte[] expected)
      Verifies that the object serializes to the expected bytes.
      Parameters:
      provider - the serdes provider
      object - the object to be verified
      expected - the expected byte array
    • verifySerialization

      public static void verifySerialization(Object object, byte[] expected)
      Verifies that the object serializes to the expected bytes. This verifier uses the JacksonJsonSerdes provider.
      Parameters:
      object - the object to be verified
      expected - the expected byte array
    • verifySerialization

      public static void verifySerialization(SerdesProvider provider, Object object, String expected)
      Verifies that the object serializes to the expected string.
      Parameters:
      provider - the serdes provider
      object - the object to be verified
      expected - the expected string
    • verifySerialization

      public static void verifySerialization(Object object, String expected)
      Verifies that the object serializes to the expected string. This verifier uses the JacksonJsonSerdes provider.
      Parameters:
      object - the object to be verified
      expected - 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 provider
      bytes - the serialized bytes
      expectedObject - the expected deserialized object
    • verifyDeserialization

      public static void verifyDeserialization(byte[] bytes, Object expected)
      Verifies that the object deserializes from the bytes to the expected object. This verifier uses the JacksonJsonSerdes provider.
      Parameters:
      bytes - the serialized bytes
      expected - 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 provider
      string - the serialized string
      expectedObject - the expected deserialized object
    • verifyDeserialization

      public static void verifyDeserialization(String string, Object expected)
      Verifies that the object deserializes from the bytes to the expected object. This verifier uses the JacksonJsonSerdes provider.
      Parameters:
      string - the serialized string
      expected - the expected deserialized object