Class AssertUtils


  • public class AssertUtils
    extends Object
    A collection of assertion helper to make UT easier to read
    Author:
    patricelamarque
    • Method Detail

      • assertContains

        public static <T> void assertContains​(Collection<T> actual,
                                              T... expected)
        Assert a set of expected items to be all contained in a collection
        Parameters:
        actual - containment
        expected - items expected to be contained
      • assertNotContains

        public static <T> void assertNotContains​(Collection<T> actual,
                                                 T... expected)
        Assert a set of expected items NOT to be all contained in a collection
        Parameters:
        actual - containment
        expected - items expected to be contained
      • assertContains

        public static void assertContains​(List<String> actual,
                                          String... expected)
        Assert a set of expected string items to be all contained in a collection
        Parameters:
        actual - containment
        expected - items expected to be contained
      • assertContains

        public static void assertContains​(String[] actual,
                                          String... expected)
        Assert a set of expected string items to be all contained in a string array
        Parameters:
        actual - containment
        expected - items expected to be contained
      • assertNotContains

        public static void assertNotContains​(List<String> actual,
                                             String... expected)
        Assert a set of expected string items NOT to be all contained in a collection
        Parameters:
        actual - containment
        expected - items expected to be contained
      • assertEmpty

        public static void assertEmpty​(Collection value)
        Assert a collection is empty (not null)
        Parameters:
        value -
      • assertNotEmpty

        public static <T> void assertNotEmpty​(Collection<T> value)
        Assert a collection is not empty and not null
        Type Parameters:
        T -
        Parameters:
        value -
      • assertEmpty

        public static <T> void assertEmpty​(T[] value)
      • assertContainsAll

        public static void assertContainsAll​(String message,
                                             List<String> expected,
                                             List<String> actual)
        All elements of a list should be contained in the expected array of String
        Parameters:
        message -
        expected -
        actual -
      • assertEquals

        public static void assertEquals​(String message,
                                        String[] expected,
                                        String[] actual)
        Assertion method on string arrays
        Parameters:
        message -
        expected -
        actual -
      • assertException

        public static void assertException​(Closure code)
      • assertException

        public static void assertException​(Class<? extends Exception> exceptionType,
                                           Closure code)
        Assert an exception of a given type is thrown by he code in closure
        Parameters:
        exceptionType -
        code -