ELEMENT - the type of elements of the "actual" value.public class Object2DArrayAssert<ELEMENT> extends Abstract2DArrayAssert<Object2DArrayAssert<ELEMENT>,ELEMENT[][],ELEMENT>
To create an instance of this class, invoke .Assertions.assertThat(Object[][])
| Modifier and Type | Field and Description |
|---|---|
protected Object2DArrays<ELEMENT> |
object2dArrays |
actual, info, myself, objects, throwUnsupportedExceptionOnEquals| Constructor and Description |
|---|
Object2DArrayAssert(ELEMENT[][] actual) |
| Modifier and Type | Method and Description |
|---|---|
Object2DArrayAssert<ELEMENT> |
contains(ELEMENT[] value,
Index index)
Verifies that the actual ELEMENT[][] contains the given ELEMENT[] at the given index.
|
Object2DArrayAssert<ELEMENT> |
doesNotContain(ELEMENT[] value,
Index index)
Verifies that the actual ELEMENT[][] does not contain the given ELEMENT[] at the given index.
|
Object2DArrayAssert<ELEMENT> |
hasDimensions(int expectedFirstDimension,
int expectedSecondDimension)
Verifies that the actual
ELEMENT[][] has the the given dimensions. |
Object2DArrayAssert<ELEMENT> |
hasNumberOfRows(int expected)
Verifies that the actual two-dimensional array has the given number of rows.
|
Object2DArrayAssert<ELEMENT> |
hasSameDimensionsAs(Object array)
Verifies that the actual
ELEMENT[][] has the same dimensions as the given array. |
Object2DArrayAssert<ELEMENT> |
isDeepEqualTo(ELEMENT[][] expected)
Verifies that the actual
ELEMENT[][] is deeply equal to the given one. |
void |
isEmpty()
Verifies that the actual
ELEMENT[][] is empty, empty means the array has no elements,
said otherwise it can have any number of rows but all rows must be empty. |
Object2DArrayAssert<ELEMENT> |
isEqualTo(Object expected)
Verifies that the actual
ELEMENT[][] is equal to the given one. |
Object2DArrayAssert<ELEMENT> |
isNotEmpty()
Verifies that the actual
ELEMENT[][] is not empty, not empty means the array has at least one char element. |
void |
isNullOrEmpty()
Verifies that the actual
ELEMENT[][] is null or empty, empty means the array has no elements,
said otherwise it can have any number of rows but all rows must be empty. |
areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingRecursiveComparison, usingRecursiveComparison, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnErrorclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitas, as, as, describedAsprotected Object2DArrays<ELEMENT> object2dArrays
public Object2DArrayAssert(ELEMENT[][] actual)
public Object2DArrayAssert<ELEMENT> isDeepEqualTo(ELEMENT[][] expected)
ELEMENT[][] is deeply equal to the given one.
Two array references are considered deeply equal if both
are null or if they refer to arrays that contain the same
number of elements and all corresponding pairs of elements in the two
arrays are deeply equal.
Example:
// assertion will pass
assertThat(new String[][] {{"1", "2"}, {"3", "4"}}).isDeepEqualTo(new String[][] {{"1", "2"}, {"3", "4"}});
// assertions will fail
assertThat(new String[][] {{"1", "2"}, {"3", "4"}}).isDeepEqualTo(new String[][] {{"1", "2"}, {"9", "0"}});
assertThat(new String[][] {{"1", "2"}, {"3", "4"}}).isDeepEqualTo(new String[][] {{"1", "2", "3"}, {"4"}});isDeepEqualTo in class Abstract2DArrayAssert<Object2DArrayAssert<ELEMENT>,ELEMENT[][],ELEMENT>expected - the given value to compare the actual value to.this assertion object.AssertionError - if the actual value is not deeply equal to the given one.public Object2DArrayAssert<ELEMENT> isEqualTo(Object expected)
ELEMENT[][] is equal to the given one.
WARNING! This method will use equals to compare (it will compare arrays references only).
Unless you specify a comparator with AbstractAssert.usingComparator(Comparator), it is advised to use
isDeepEqualTo(Object[][]) instead.
Example:
String[][] array = {{"1", "2"}, {"3", "4"}};
// assertion will pass
assertThat(array).isEqualTo(array);
// assertion will fail as isEqualTo calls equals which compares arrays references only.
assertThat(array).isEqualTo(new String[][] {{"1", "2"}, {"3", "4"}});isEqualTo in interface Assert<Object2DArrayAssert<ELEMENT>,ELEMENT[][]>isEqualTo in class AbstractAssert<Object2DArrayAssert<ELEMENT>,ELEMENT[][]>expected - the given value to compare the actual ELEMENT[][] to.this assertion object.AssertionError - if the actual ELEMENT[][] is not equal to the given one.public void isNullOrEmpty()
ELEMENT[][] is null or empty, empty means the array has no elements,
said otherwise it can have any number of rows but all rows must be empty.
Example:
// assertions will pass
String[][] array = null;
assertThat(array).isNullOrEmpty();
assertThat(new String[][] { }).isNullOrEmpty();
assertThat(new String[][] { { } }).isNullOrEmpty();
// this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows.
assertThat(new String[][] { { }, { }, { } }).isNullOrEmpty();
// assertion will fail
assertThat(new String[][] { {'a'}, {'b'} }).isNullOrEmpty();AssertionError - if the actual ELEMENT[][] is not null or not empty.public void isEmpty()
ELEMENT[][] is empty, empty means the array has no elements,
said otherwise it can have any number of rows but all rows must be empty.
Example:
// assertions will pass
assertThat(new String[][] { {} }).isEmpty();
// this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows.
assertThat(new String[][] { { }, { }, { } }).isEmpty();
// assertions will fail
assertThat(new String[][] { {'a'}, {'b'} }).isEmpty();
String[][] array = null;
assertThat(array).isEmpty();AssertionError - if the actual ELEMENT[][] is not empty.public Object2DArrayAssert<ELEMENT> isNotEmpty()
ELEMENT[][] is not empty, not empty means the array has at least one char element.
Example:
// assertion will pass
assertThat(new String[][] { {'a'}, {'b'} }).isNotEmpty();
assertThat(new String[][] { { }, {'b'} }).isNotEmpty();
// assertions will fail
assertThat(new String[][] { }).isNotEmpty();
assertThat(new String[][] { { } }).isNotEmpty();
// this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows.
assertThat(new String[][] { { }, { }, { } }).isNotEmpty();
String[][] array = null;
assertThat(array).isNotEmpty();this assertion object.AssertionError - if the actual ELEMENT[][] is empty or null.public Object2DArrayAssert<ELEMENT> hasDimensions(int expectedFirstDimension, int expectedSecondDimension)
ELEMENT[][] has the the given dimensions.
Example:
// assertion will pass
assertThat(new String[][] { {"1", "2", "3"}, {"4", "5", "6"} }).hasDimensions(2, 3);
// assertions will fail
assertThat(new String[][] { }).hasDimensions(1, 1);
assertThat(new String[][] { {"1", "2", "3"}, {"4", "5", "6"} }).hasDimensions(3, 2);
assertThat(new String[][] { {"1", "2", "3"}, {"4", "5", "6", "7"} }).hasDimensions(2, 3); expectedFirstDimension - the expected number of values in first dimension of the actual ELEMENT[][].expectedSecondDimension - the expected number of values in second dimension of the actual ELEMENT[][].this assertion object.AssertionError - if the number of values of the actual ELEMENT[][] is not equal to the given one.public Object2DArrayAssert<ELEMENT> hasNumberOfRows(int expected)
Example:
// assertion will pass
assertThat(new String[][] {{"1", "2", "3"}, {"4", "5", "6"}}).hasNumberOfRows(2);
assertThat(new String[][] {{"1"}, {"1", "2"}, {"1", "2", "3"}}).hasNumberOfRows(3);
// assertions will fail
assertThat(new String[][] { }).hasNumberOfRows(1);
assertThat(new String[][] {{"1", "2", "3"}, {"4", "5", "6"}}).hasNumberOfRows(3);
assertThat(new String[][] {{"1", "2", "3"}, {"4", "5", "6", "7"}}).hasNumberOfRows(1); expected - the expected number of rows of the two-dimensional array.this assertion object.AssertionError - if the actual number of rows are not equal to the given one.public Object2DArrayAssert<ELEMENT> hasSameDimensionsAs(Object array)
ELEMENT[][] has the same dimensions as the given array.
Parameter is declared as Object to accept both Object and primitive arrays.
Example: String[][] stringArray = {{"a", "b", "c""}, {"d", "e", "f""}};
char[][] charArray = {{'a', 'b', 'c'}, {'d', 'e', 'f'}};
// assertion will pass
assertThat(stringArray).hasSameDimensionsAs(charArray);
// assertions will fail
assertThat(stringArray).hasSameDimensionsAs(new char[][] {{'a', 'b'}, {'c', 'd'}, {'e', 'f'}});
assertThat(stringArray).hasSameDimensionsAs(new char[][] {{'a', 'b'}, {'c', 'd', 'e'}});
assertThat(stringArray).hasSameDimensionsAs(new char[][] {{'a', 'b', 'c'}, {'d', 'e'}});array - the array to compare dimensions with actual ELEMENT[][].this assertion object.AssertionError - if the actual ELEMENT[][] is null.AssertionError - if the array parameter is null or is not a true array.AssertionError - if actual ELEMENT[][] and given array don't have the same dimensions.public Object2DArrayAssert<ELEMENT> contains(ELEMENT[] value, Index index)
Example:
// assertion will pass
assertThat(new String[][] {{"a", "b"}, {"c", "d"}}).contains(new String[] {"a", "b"}, atIndex(0));
// assertion will fail
assertThat(new String[][] {{"a", "b"}, {"c", "d"}}).contains(new String[] {"a", "b"}, atIndex(1));value - the value to look for.index - the index where the value should be stored in the actual ELEMENT[][].AssertionError - if the actual ELEMENT[][] 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 actual ELEMENT[][].AssertionError - if the actual ELEMENT[][] does not contain the given value at the given index.public Object2DArrayAssert<ELEMENT> doesNotContain(ELEMENT[] value, Index index)
Example:
// assertion will pass
assertThat(new String[][] {{"a", "b"}, {"c", "d"}}).doesNotContain(new String[] {"a", "b"}, atIndex(1));
// assertion will fail
assertThat(new String[][] {{"a", "b"}, {"c", "d"}}).doesNotContain(new String[] {"a", "b"}, atIndex(0));value - the value to look for.index - the index where the value should be stored in the actual ELEMENT[][].AssertionError - if the actual ELEMENT[][] is null.NullPointerException - if the given Index is null.AssertionError - if the actual ELEMENT[][] contains the given value at the given index.Copyright © 2025. All rights reserved.