Package org.assertj.core.api
Class Long2DArrayAssert
- java.lang.Object
-
- org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
-
- org.assertj.core.api.Abstract2DArrayAssert<Long2DArrayAssert,long[][],Long>
-
- org.assertj.core.api.Long2DArrayAssert
-
- All Implemented Interfaces:
Array2DAssert<Long2DArrayAssert,Long>
,Assert<Long2DArrayAssert,long[][]>
,Descriptable<Long2DArrayAssert>
,ExtensionPoints<Long2DArrayAssert,long[][]>
public class Long2DArrayAssert extends Abstract2DArrayAssert<Long2DArrayAssert,long[][],Long>
Assertion methods for two-dimensional arrays oflong
s.To create an instance of this class, invoke
.Assertions.assertThat(long[][])
- Since:
- 3.17.0
- Author:
- Maciej Wajcht
-
-
Field Summary
Fields Modifier and Type Field Description private Failures
failures
protected Long2DArrays
long2dArrays
-
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, assertionErrorCreator, conditions, info, myself, objects, throwUnsupportedExceptionOnEquals
-
-
Constructor Summary
Constructors Constructor Description Long2DArrayAssert(long[][] actual)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Long2DArrayAssert
contains(long[] value, Index index)
Verifies that the actual array contains the given long[] at the given index.Long2DArrayAssert
doesNotContain(long[] value, Index index)
Verifies that the actual array does not contain the given long[] at the given index.Long2DArrayAssert
hasDimensions(int expectedFirstDimension, int expectedSecondDimension)
Verifies that the actual 2D array has the given dimensions.Long2DArrayAssert
hasSameDimensionsAs(Object array)
Verifies that the actuallong[][]
has the same dimensions as the given array.Long2DArrayAssert
isDeepEqualTo(long[][] expected)
Verifies that the actual 2D array is deeply equal to the given one.void
isEmpty()
Verifies that the actual array is empty, empty means the array has no elements, said otherwise it can have any number of rows but all rows must be empty.Long2DArrayAssert
isEqualTo(Object expected)
Verifies that the actuallong[][]
is equal to the given one.Long2DArrayAssert
isNotEmpty()
Verifies that the actual array is not empty, not empty means the array has at least one element.void
isNullOrEmpty()
Verifies that the actual array isnull
or empty, empty means the array has no elements, said otherwise it can have any number of rows but all rows must be empty.-
Methods inherited from class org.assertj.core.api.AbstractAssert
asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, extracting, extracting, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, 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, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOf, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingRecursiveComparison, usingRecursiveComparison, withAssertionState, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.assertj.core.api.Descriptable
as, as, describedAs
-
-
-
-
Field Detail
-
failures
private final Failures failures
-
long2dArrays
protected Long2DArrays long2dArrays
-
-
Method Detail
-
isDeepEqualTo
public Long2DArrayAssert isDeepEqualTo(long[][] expected)
Verifies that the actual 2D array is deeply equal to the given one.Two arrays 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 long[][] {{1, 2}, {3, 4}}).isDeepEqualTo(new long[][] {{1, 2}, {3, 4}}); // assertions will fail assertThat(new long[][] {{1, 2}, {3, 4}}).isDeepEqualTo(new long[][] {{1, 2}, {9, 10}}); assertThat(new long[][] {{1, 2}, {3, 4}}).isDeepEqualTo(new long[][] {{1, 2, 3}, {4}});
- Specified by:
isDeepEqualTo
in classAbstract2DArrayAssert<Long2DArrayAssert,long[][],Long>
- Parameters:
expected
- the given value to compare the actual value to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual value is not deeply equal to the given one.
-
isEqualTo
public Long2DArrayAssert isEqualTo(Object expected)
Verifies that the actuallong[][]
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 withAbstractAssert.usingComparator(Comparator)
, it is advised to useisDeepEqualTo(long[][])
instead.Example:
long[][] 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 long[][] {{1, 2}, {3, 4}});
- Specified by:
isEqualTo
in interfaceAssert<Long2DArrayAssert,long[][]>
- Overrides:
isEqualTo
in classAbstractAssert<Long2DArrayAssert,long[][]>
- Parameters:
expected
- the given value to compare the actuallong[][]
to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actuallong[][]
is not equal to the given one.
-
isNullOrEmpty
public void isNullOrEmpty()
Verifies that the actual array isnull
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 long[][] array = null; assertThat(array).isNullOrEmpty(); assertThat(new long[][] { }).isNullOrEmpty(); assertThat(new long[][] {{ }}).isNullOrEmpty(); // this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows. assertThat(new long[][] {{ }, { }, { }}).isNullOrEmpty(); // assertion will fail assertThat(new String[][] {{"a"}, {"b"}}).isNullOrEmpty();
- Throws:
AssertionError
- if the actual array is notnull
or not empty.
-
isEmpty
public void isEmpty()
Verifies that the actual array 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:
// assertion will pass assertThat(new long[][] {{}}).isEmpty(); assertThat(new long[][] {{ }}).isNullOrEmpty(); // this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows. assertThat(new long[][] {{ }, { }, { }}).isNullOrEmpty(); // assertions will fail assertThat(new long[][] {{ 1 }, { 2 }}).isEmpty(); long[][] array = null; assertThat(array).isEmpty();
- Throws:
AssertionError
- if the actual array is not empty.
-
isNotEmpty
public Long2DArrayAssert isNotEmpty()
Verifies that the actual array is not empty, not empty means the array has at least one element.Example:
// assertions will pass assertThat(new long[][] {{ 1 }, { 2 }}).isNotEmpty(); assertThat(new long[][] {{ }, { 2 }}).isNotEmpty(); // assertions will fail assertThat(new long[][] { }).isNotEmpty(); assertThat(new long[][] {{ }}).isNotEmpty(); // this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows. assertThat(new long[][] {{ }, { }, { }}).isNotEmpty(); long[][] array = null; assertThat(array).isNotEmpty();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual array is empty or null.
-
hasDimensions
public Long2DArrayAssert hasDimensions(int expectedFirstDimension, int expectedSecondDimension)
Verifies that the actual 2D array has the given dimensions.Example:
// assertion will pass assertThat(new long[][] {{1, 2, 3}, {4, 5, 6}}).hasDimensions(2, 3); // assertions will fail assertThat(new long[][] { }).hasSize(1, 1); assertThat(new long[][] {{1, 2, 3}, {4, 5, 6}}).hasDimensions(3, 2); assertThat(new long[][] {{1, 2, 3}, {4, 5, 6, 7}}).hasDimensions(2, 3);
- Parameters:
expectedFirstDimension
- the expected number of values in first dimension of the actual array.expectedSecondDimension
- the expected number of values in second dimension of the actual array.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual array's dimensions are not equal to the given ones.
-
hasSameDimensionsAs
public Long2DArrayAssert hasSameDimensionsAs(Object array)
Verifies that the actuallong[][]
has the same dimensions as the given array.Parameter is declared as Object to accept both Object and primitive arrays.
Example:long[][] longArray = {{1, 2, 3}, {4, 5, 6}}; char[][] charArray = {{'a', 'b', 'c'}, {'d', 'e', 'f'}}; // assertion will pass assertThat(longArray).hasSameDimensionsAs(charArray); // assertions will fail assertThat(longArray).hasSameDimensionsAs(new char[][] {{'a', 'b'}, {'c', 'd'}, {'e', 'f'}}); assertThat(longArray).hasSameDimensionsAs(new char[][] {{'a', 'b'}, {'c', 'd', 'e'}}); assertThat(longArray).hasSameDimensionsAs(new char[][] {{'a', 'b', 'c'}, {'d', 'e'}});
- Parameters:
array
- the array to compare dimensions with actuallong[][]
.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actuallong[][]
isnull
.AssertionError
- if the array parameter isnull
or is not a true array.AssertionError
- if actuallong[][]
and given array don't have the same dimensions.
-
contains
public Long2DArrayAssert contains(long[] value, Index index)
Verifies that the actual array contains the given long[] at the given index.Example:
// assertion will pass assertThat(new long[][] {{1L, 2L}, {3L, 4L}, {5L, 6L}}).contains(new long[] {3L, 4L}, atIndex(1)); // assertions will fail assertThat(new long[][] {{1L, 2L}, {3L, 4L}, {5L, 6L}}).contains(new long[] {3L, 4L}, atIndex(0)); assertThat(new long[][] {{1L, 2L}, {3L, 4L}, {5L, 6L}}).contains(new long[] {7L, 8L}, atIndex(2));
- Parameters:
value
- the value to look for.index
- the index where the value should be stored in the actual array.- Returns:
- myself assertion object.
- Throws:
AssertionError
- if the actual array isnull
or empty.NullPointerException
- if the givenIndex
isnull
.IndexOutOfBoundsException
- if the value of the givenIndex
is equal to or greater than the size of the actual array.AssertionError
- if the actual array does not contain the given value at the given index.
-
doesNotContain
public Long2DArrayAssert doesNotContain(long[] value, Index index)
Verifies that the actual array does not contain the given long[] at the given index.Example:
// assertions will pass assertThat(new long[][] {{1L, 2L}, {3L, 4L}, {5L, 6L}}).doesNotContain(new long[] {3L, 4L}, atIndex(0)); assertThat(new long[][] {{1L, 2L}, {3L, 4L}, {5L, 6L}}).doesNotContain(new long[] {7L, 8L}, atIndex(2)); // assertion will fail assertThat(new long[][] {{1L, 2L}, {3L, 4L}, {5L, 6L}}).doesNotContain(new long[] {3L, 4L}, atIndex(1));
- Parameters:
value
- the value to look for.index
- the index where the value should be stored in the actual array.- Returns:
- myself assertion object.
- Throws:
AssertionError
- if the actual array isnull
.NullPointerException
- if the givenIndex
isnull
.AssertionError
- if the actual array contains the given value at the given index.
-
-