Class Object2DArrays<ELEMENT>

  • Type Parameters:
    ELEMENT - the type of elements of the 2D array.

    public class Object2DArrays<ELEMENT>
    extends Object
    Reusable assertions for two-dimensional arrays of objects.
    Author:
    Maciej Wajcht
    • Constructor Detail

      • Object2DArrays

        public Object2DArrays()
    • Method Detail

      • instance

        public static <ELEMENT> Object2DArrays<ELEMENT> instance()
        Returns the singleton instance of this class.
        Type Parameters:
        ELEMENT - the type of elements of the 2D array.
        Returns:
        the singleton instance of this class.
      • setArrays

        void setArrays​(Arrays2D arrays)
      • assertNullOrEmpty

        public void assertNullOrEmpty​(AssertionInfo info,
                                      ELEMENT[][] actual)
        Asserts that the given array is null or empty.
        Parameters:
        info - contains information about the assertion.
        actual - the given array.
        Throws:
        AssertionError - if the given array is not null *and* contains one or more elements.
      • assertEmpty

        public void assertEmpty​(AssertionInfo info,
                                ELEMENT[][] actual)
        Asserts that the given array is empty.
        Parameters:
        info - contains information about the assertion.
        actual - the given array.
        Throws:
        AssertionError - if the given array is null.
        AssertionError - if the given array is not empty.
      • assertNotEmpty

        public void assertNotEmpty​(AssertionInfo info,
                                   ELEMENT[][] actual)
        Asserts that the given array is not empty.
        Parameters:
        info - contains information about the assertion.
        actual - the given array.
        Throws:
        AssertionError - if the given array is null.
        AssertionError - if the given array is empty.
      • assertHasDimensions

        public void assertHasDimensions​(AssertionInfo info,
                                        ELEMENT[][] actual,
                                        int expectedFirstDimension,
                                        int expectedSecondDimension)
        Asserts that the number of elements in the given array is equal to the expected one.
        Parameters:
        info - contains information about the assertion.
        actual - the given array.
        expectedFirstDimension - the expected first dimension size of actual.
        expectedSecondDimension - the expected second dimension size of actual.
        Throws:
        AssertionError - if the given array is null.
        AssertionError - if the actual array's dimensions are not equal to the given ones.
      • assertHasSameDimensionsAs

        public void assertHasSameDimensionsAs​(AssertionInfo info,
                                              ELEMENT[][] actual,
                                              Object other)
        Assert that the actual array has the same dimensions as the other array.
        Parameters:
        info - contains information about the assertion.
        actual - the given array.
        other - the group to compare
        Throws:
        AssertionError - if the actual group is null.
        AssertionError - if the other group is null.
        AssertionError - if the actual group does not have the same dimension.
      • assertContains

        public void assertContains​(AssertionInfo info,
                                   ELEMENT[][] actual,
                                   ELEMENT[] value,
                                   Index index)
        Verifies that the given array contains the given object at the given index.
        Parameters:
        info - contains information about the assertion.
        actual - the given array.
        value - the object to look for.
        index - the index where the object should be stored in the given array.
        Throws:
        AssertionError - if the given array is null or empty.
        NullPointerException - if the given Index is null.
        IndexOutOfBoundsException - if the value of the given Index is equal to or greater than the size of the given array.
        AssertionError - if the given array does not contain the given object at the given index.
      • assertDoesNotContain

        public void assertDoesNotContain​(AssertionInfo info,
                                         ELEMENT[][] actual,
                                         ELEMENT[] value,
                                         Index index)
        Verifies that the given array does not contain the given object at the given index.
        Parameters:
        info - contains information about the assertion.
        actual - the given array.
        value - the object to look for.
        index - the index where the object should be stored in the given array.
        Throws:
        AssertionError - if the given array is null.
        NullPointerException - if the given Index is null.
        AssertionError - if the given array contains the given object at the given index.