Class TestUtils


  • public class TestUtils
    extends Object
    • Constructor Detail

      • TestUtils

        public TestUtils()
    • Method Detail

      • createTempDirectory

        public static File createTempDirectory​(String name)
                                        throws IOException
        Create a temporary directory. NOTE: This is a quick and dirty implementation suitable for tests, not production code.
        Parameters:
        name -
        Returns:
        Throws:
        IOException
      • createTempFile

        public static File createTempFile​(String filename,
                                          String contents)
                                   throws IOException
        Creates a temporary file with the given contents. This is useful in the case where Java's resource mechanism is not applicable, for instance when importing from files with Spark (as they need to be located by path, not using an InputStream).
        Parameters:
        filename - the filename of the temporary file to create
        contents - the contents to write in the file
        Returns:
        a {%class java.io.File} object, use File.getAbsolutePath() to obtain its path.
        Throws:
        IOException
      • assertEqualsAsJson

        public static void assertEqualsAsJson​(String actual,
                                              String expected)
        Assert that two JSON strings are equal as JSON objects.
      • equalAsJson

        public static boolean equalAsJson​(String a,
                                          String b)
      • isSerializedTo

        public static void isSerializedTo​(Object o,
                                          String targetJson,
                                          com.fasterxml.jackson.databind.ObjectWriter writer)
      • jsonDiff

        public static void jsonDiff​(String a,
                                    String b)
                             throws com.fasterxml.jackson.core.JsonParseException,
                                    com.fasterxml.jackson.databind.JsonMappingException
        Throws:
        com.fasterxml.jackson.core.JsonParseException
        com.fasterxml.jackson.databind.JsonMappingException