Class TestHelper


  • public final class TestHelper
    extends Object
    • Constructor Detail

      • TestHelper

        public TestHelper()
    • Method Detail

      • assertContains

        public static void assertContains​(String expectedContent,
                                          String value)
      • assertContains

        public static void assertContains​(Iterable<?> expected,
                                          Object actual)
      • assertContainsValuesAtKeys

        public static void assertContainsValuesAtKeys​(Set<?> expectedKeys,
                                                      Set<?> expectedValues,
                                                      Object actual)
      • assertSameItems

        public static void assertSameItems​(Object expected,
                                           Object actual)
      • assertEmpty

        public static void assertEmpty​(List<?> actual)
      • submap

        public static <K,​V> Map<K,​V> submap​(Map<K,​V> map,
                                                        K... keys)
      • submap

        public static <K,​V> Map<K,​V> submap​(Map<K,​V> map,
                                                        Iterable<?> keys)
      • assertContainsEntries

        public static void assertContainsEntries​(Map<Object,​Object> expected,
                                                 Object actual)
      • assertEmpty

        public static void assertEmpty​(String actual)
      • assertEndsWith

        public static void assertEndsWith​(String expectedSuffix,
                                          String actual)
      • assertIsInstance

        public static <T> T assertIsInstance​(Class<T> clazz,
                                             Object item)
      • assertLinesEqual

        public static void assertLinesEqual​(String expected,
                                            String actual)
      • assertStartsWith

        public static void assertStartsWith​(String expectedPrefix,
                                            String actual)
      • createTmpFile

        public static File createTmpFile​(String content,
                                         String fileName,
                                         String extension)
                                  throws IOException
        Creates a file in the temp folder with the specified content
        Parameters:
        content - the file content
        fileName - Name of the tmp file
        extension - Extension of the tmp file.
        Returns:
        the File instance
        Throws:
        IOException - When the text file could not be created.
      • createTmpFile

        public static File createTmpFile​(byte[] content,
                                         String fileName,
                                         String extension)
                                  throws IOException
        Creates a file in the temp folder with the specified content
        Parameters:
        content - the file content
        fileName - Name of the tmp file
        extension - Extension of the tmp file.
        Returns:
        the File instance
        Throws:
        IOException - When the text file could not be created.
      • createTmpTextFile

        public static File createTmpTextFile​(String content)
                                      throws IOException
        Creates a file in the temp folder with the specified content
        Parameters:
        content - the file content
        Returns:
        the File instance
        Throws:
        IOException - When the text file could not be created.
      • assertIsOrHasCause

        public static <T extends Throwable> T assertIsOrHasCause​(Throwable actual,
                                                                 Class<T> expectedType)
      • list

        public static <T> List<T> list​(T... items)
      • set

        public static <T> Set<T> set​(T... items)
      • map

        public static <K,​V> Map<K,​V> map​(Object... items)
      • str

        public static String str​(byte[] bytes)