Package org.assertj.core.api
Class Byte2DArrayAssert
- java.lang.Object
-
- org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
-
- org.assertj.core.api.Abstract2DArrayAssert<Byte2DArrayAssert,byte[][],Byte>
-
- org.assertj.core.api.Byte2DArrayAssert
-
- All Implemented Interfaces:
Array2DAssert<Byte2DArrayAssert,Byte>
,Assert<Byte2DArrayAssert,byte[][]>
,Descriptable<Byte2DArrayAssert>
,ExtensionPoints<Byte2DArrayAssert,byte[][]>
public class Byte2DArrayAssert extends Abstract2DArrayAssert<Byte2DArrayAssert,byte[][],Byte>
Assertion methods for two-dimensional arrays ofbyte
s.To create an instance of this class, invoke
.Assertions.assertThat(byte[][])
- Since:
- 3.17.0
- Author:
- Maciej Wajcht
-
-
Field Summary
Fields Modifier and Type Field Description protected org.assertj.core.internal.Byte2DArrays
byte2dArrays
private org.assertj.core.internal.Failures
failures
-
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, assertionErrorCreator, conditions, customRepresentation, info, myself, objects, printAssertionsDescription, throwUnsupportedExceptionOnEquals
-
-
Constructor Summary
Constructors Constructor Description Byte2DArrayAssert(byte[][] actual)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Byte2DArrayAssert
contains(byte[] value, Index index)
Verifies that the actualbyte[][]
contains the given byte[] at the given index.Byte2DArrayAssert
doesNotContain(byte[] value, Index index)
Verifies that the actualbyte[][]
does not contain the given byte[] at the given index.Byte2DArrayAssert
hasDimensions(int expectedFirstDimension, int expectedSecondDimension)
Verifies that the actualbyte[][]
has the given dimensions.Byte2DArrayAssert
hasSameDimensionsAs(Object array)
Verifies that the actualbyte[][]
has the same dimensions as the given array.Byte2DArrayAssert
isDeepEqualTo(byte[][] expected)
Verifies that the actualbyte[][]
is deeply equal to the given one.void
isEmpty()
Verifies that the actualbyte[][]
is empty, empty means the array has no elements, said otherwise it can have any number of rows but all rows must be empty.Byte2DArrayAssert
isEqualTo(Object expected)
Verifies that the actualbyte[][]
is equal to the given one.Byte2DArrayAssert
isNotEmpty()
Verifies that the actualbyte[][]
is not empty, not empty means the array has at least one element.void
isNullOrEmpty()
Verifies that the actualbyte[][]
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, 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, 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, as, describedAs
-
-
-
-
Method Detail
-
isDeepEqualTo
public Byte2DArrayAssert isDeepEqualTo(byte[][] expected)
Verifies that the actualbyte[][]
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 byte[][] {{1, 2}, {3, 4}}).isDeepEqualTo(new byte[][] {{1, 2}, {3, 4}}); // assertions will fail assertThat(new byte[][] {{1, 2}, {3, 4}}).isDeepEqualTo(new byte[][] {{1, 2}, {9, 10}}); assertThat(new byte[][] {{1, 2}, {3, 4}}).isDeepEqualTo(new byte[][] {{1, 2, 3}, {4}});
- Specified by:
isDeepEqualTo
in classAbstract2DArrayAssert<Byte2DArrayAssert,byte[][],Byte>
- 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 Byte2DArrayAssert isEqualTo(Object expected)
Verifies that the actualbyte[][]
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(byte[][])
instead.Example:
byte[][] 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 byte[][] {{1, 2}, {3, 4}});
- Specified by:
isEqualTo
in interfaceAssert<Byte2DArrayAssert,byte[][]>
- Overrides:
isEqualTo
in classAbstractAssert<Byte2DArrayAssert,byte[][]>
- Parameters:
expected
- the given value to compare the actualbyte[][]
to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualbyte[][]
is not equal to the given one.
-
isNullOrEmpty
public void isNullOrEmpty()
Verifies that the actualbyte[][]
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 byte[][] array = null; assertThat(array).isNullOrEmpty(); assertThat(new byte[][] { }).isNullOrEmpty(); assertThat(new byte[][] {{ }}).isNullOrEmpty(); // this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows. assertThat(new byte[][] {{ }, { }, { }}).isNullOrEmpty(); // assertion will fail assertThat(new byte[][] {{ 1 }, { 2 }}).isNullOrEmpty();
- Throws:
AssertionError
- if the actualbyte[][]
is notnull
or not empty.
-
isEmpty
public void isEmpty()
Verifies that the actualbyte[][]
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 byte[][] {{}}).isEmpty(); // this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows. assertThat(new byte[][] {{ }, { }, { }}).isEmpty(); // assertions will fail assertThat(new byte[][] {{ 1 }, { 2 }}).isEmpty(); byte[][] array = null; assertThat(array).isEmpty();
- Throws:
AssertionError
- if the actualbyte[][]
is not empty.
-
isNotEmpty
public Byte2DArrayAssert isNotEmpty()
Verifies that the actualbyte[][]
is not empty, not empty means the array has at least one element.Example:
// assertions will pass assertThat(new byte[][] {{ 1 }, { 2 }}).isNotEmpty(); assertThat(new byte[][] {{ }, { 2 }}).isNotEmpty(); // assertions will fail assertThat(new byte[][] { }).isNotEmpty(); assertThat(new byte[][] {{ }}).isNotEmpty(); // this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows. assertThat(new byte[][] {{ }, { }, { }}).isNotEmpty(); byte[][] array = null; assertThat(array).isNotEmpty();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualbyte[][]
is empty or null.
-
hasDimensions
public Byte2DArrayAssert hasDimensions(int expectedFirstDimension, int expectedSecondDimension)
Verifies that the actualbyte[][]
has the given dimensions.Example:
// assertion will pass assertThat(new byte[][] {{1, 2, 3}, {4, 5, 6}}).hasDimensions(2, 3); // assertions will fail assertThat(new byte[][] { }).hasSize(1, 1); assertThat(new byte[][] {{1, 2, 3}, {4, 5, 6}}).hasDimensions(3, 2); assertThat(new byte[][] {{1, 2, 3}, {4, 5, 6, 7}}).hasDimensions(2, 3);
- Parameters:
expectedFirstDimension
- the expected number of values in first dimension of the actualbyte[][]
.expectedSecondDimension
- the expected number of values in second dimension of the actualbyte[][]
.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualbyte[][]
's dimensions are not equal to the given ones.
-
hasSameDimensionsAs
public Byte2DArrayAssert hasSameDimensionsAs(Object array)
Verifies that the actualbyte[][]
has the same dimensions as the given array.Parameter is declared as Object to accept both Object and primitive arrays.
Example:byte[][] byteArray = {{1, 2, 3}, {4, 5, 6}}; char[][] charArray = {{'a', 'b', 'c'}, {'d', 'e', 'f'}}; // assertion will pass assertThat(byteArray).hasSameDimensionsAs(charArray); // assertions will fail assertThat(byteArray).hasSameDimensionsAs(new char[][] {{'a', 'b'}, {'c', 'd'}, {'e', 'f'}}); assertThat(byteArray).hasSameDimensionsAs(new char[][] {{'a', 'b'}, {'c', 'd', 'e'}}); assertThat(byteArray).hasSameDimensionsAs(new char[][] {{'a', 'b', 'c'}, {'d', 'e'}});
- Parameters:
array
- the array to compare dimensions with actualbyte[][]
.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualbyte[][]
isnull
.AssertionError
- if the array parameter isnull
or is not a true array.AssertionError
- if actualbyte[][]
and given array don't have the same dimensions.
-
contains
public Byte2DArrayAssert contains(byte[] value, Index index)
Verifies that the actualbyte[][]
contains the given byte[] at the given index.Example:
// assertion will pass assertThat(new byte[][] {{1, 2}, {3, 4}, {5, 6}}).contains(new byte[] {3, 4}, atIndex(1)); // assertions will fail assertThat(new byte[][] {{1, 2}, {3, 4}, {5, 6}}).contains(new byte[] {3, 4}, atIndex(0)); assertThat(new byte[][] {{1, 2}, {3, 4}, {5, 6}}).contains(new byte[] {7, 8}, atIndex(2));
- Parameters:
value
- the value to look for.index
- the index where the value should be stored in the actualbyte[][]
.- Returns:
- myself assertion object.
- Throws:
AssertionError
- if the actualbyte[][]
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 actualbyte[][]
.AssertionError
- if the actualbyte[][]
does not contain the given value at the given index.
-
doesNotContain
public Byte2DArrayAssert doesNotContain(byte[] value, Index index)
Verifies that the actualbyte[][]
does not contain the given byte[] at the given index.Example:
// assertions will pass assertThat(new byte[][] {{1, 2}, {3, 4}, {5, 6}}).doesNotContain(new byte[] {3, 4}, atIndex(0)); assertThat(new byte[][] {{1, 2}, {3, 4}, {5, 6}}).doesNotContain(new byte[] {7, 8}, atIndex(2)); // assertion will fail assertThat(new byte[][] {{1, 2}, {3, 4}, {5, 6}}).doesNotContain(new byte[] {3, 4}, atIndex(1));
- Parameters:
value
- the value to look for.index
- the index where the value should be stored in the actualbyte[][]
.- Returns:
- myself assertion object.
- Throws:
AssertionError
- if the actualbyte[][]
isnull
.NullPointerException
- if the givenIndex
isnull
.AssertionError
- if the actualbyte[][]
contains the given value at the given index.
-
-