Class TestUtil


  • public class TestUtil
    extends Object
    Utility class for testing REST controllers.
    • Field Detail

      • APPLICATION_JSON_UTF8

        public static final org.springframework.http.MediaType APPLICATION_JSON_UTF8
        MediaType for JSON UTF8
    • Constructor Detail

      • TestUtil

        public TestUtil()
    • Method Detail

      • convertObjectToJsonBytes

        public static byte[] convertObjectToJsonBytes​(Object object)
                                               throws IOException
        Convert an object to JSON byte array.
        Parameters:
        object - the object to convert
        Returns:
        the JSON byte array
        Throws:
        IOException
      • createByteArray

        public static byte[] createByteArray​(int size,
                                             String data)
        Create a byte array with a specific size filled with specified data.
        Parameters:
        size - the size of the byte array
        data - the data to put in the byte array
        Returns:
        the JSON byte array
      • sameInstant

        public static TestUtil.ZonedDateTimeMatcher sameInstant​(ZonedDateTime date)
        Creates a matcher that matches when the examined string reprensents the same instant as the reference datetime
        Parameters:
        date - the reference datetime against which the examined string is checked
      • equalsVerifier

        public static void equalsVerifier​(Class clazz)
                                   throws Exception
        Verifies the equals/hashcode contract on the domain object.
        Throws:
        Exception