Top Fields Constructors Methods
org.assertj.core.api

public abstract Class AbstractIntArrayAssert<SELF extends AbstractIntArrayAssert<SELF>>

extends AbstractArrayAssert<SELF extends AbstractIntArrayAssert<SELF>, int[], Integer>
Class Inheritance
Known Direct Subclasses
org.assertj.core.api.IntArrayAssert
Imports
java.util.Arrays, .Comparator, org.assertj.core.data.Index, org.assertj.core.internal.ComparatorBasedComparisonStrategy, .IntArrays, org.assertj.core.util.CheckReturnValue, .VisibleForTesting

Field Summary

Modifier and TypeField and Description
protected IntArrays

Constructor Summary

AccessConstructor and Description
protected
AbstractIntArrayAssert(int[] actual, Class<?> selfType)

Method Summary

Modifier and TypeMethod and Description
public SELF

Returns:

this assertion object.
contains
(int...
the given values.
values
)

Verifies that the actual array contains the given values, in any order.

public SELF

Returns:

this assertion object.
contains
(Integer[]
the given values.
values
)

Verifies that the actual array contains the values of the given array, in any order.

public SELF

Returns:

myself assertion object.
contains
(int
the value to look for.
value
,
Index
the index where the value should be stored in the actual array.
index
)

Verifies that the actual array contains the given value at the given index.

public SELF

Returns:

this assertion object.
containsAnyOf
(int...
the values whose at least one which is expected to be in the array under test.
values
)

Verifies that the actual array contains at least one of the given values.

public SELF

Returns:

this assertion object.
containsAnyOf
(Integer[]
the values whose at least one which is expected to be in the array under test.
values
)

Verifies that the actual array contains at least one of the values of the given array.

public SELF

Returns:

this assertion object.
containsExactly
(int...
the given values.
values
)

Verifies that the actual array contains only the given values and nothing else, in order.

public SELF

Returns:

this assertion object.
containsExactly
(Integer[]
the given values.
values
)

Verifies that the actual group contains only the values of the given array and nothing else, in order.

public SELF

Returns:

this assertion object.
containsExactlyInAnyOrder
(int...
the given values.
values
)

Verifies that the actual array contains exactly the given values and nothing else, in any order.

public SELF

Returns:

this assertion object.
containsExactlyInAnyOrder
(Integer[]
the given values.
values
)

Verifies that the actual group contains exactly the values of the given array and nothing else, in any order.

public SELF

Returns:

this assertion object.
containsOnly
(int...
the given values.
values
)

Verifies that the actual array contains only the given values and nothing else, in any order.

public SELF

Returns:

this assertion object.
containsOnly
(Integer[]
the given values.
values
)

Verifies that the actual array contains only the values of the given array and nothing else, in any order.

public SELF

Returns:

this assertion object.
containsOnlyOnce
(int...
the given values.
values
)

Verifies that the actual array contains the given values only once.

public SELF

Returns:

this assertion object.
containsOnlyOnce
(Integer[]
the given values.
values
)

Verifies that the actual array contains the values of the given array only once.

public SELF

Returns:

myself assertion object.
containsSequence
(int...
the sequence of values to look for.
sequence
)

Verifies that the actual array contains the given sequence, without any other values between them.

public SELF

Returns:

myself assertion object.
containsSequence
(Integer[]
the sequence of values to look for.
sequence
)

Verifies that the actual array contains the given sequence, without any other values between them.

public SELF

Returns:

myself assertion object.
containsSubsequence
(int...
the subsequence of values to look for.
subsequence
)

Verifies that the actual array contains the given subsequence (possibly with other values between them).

public SELF

Returns:

myself assertion object.
containsSubsequence
(Integer[]
the subsequence of values to look for.
subsequence
)

Verifies that the actual array contains the given subsequence (possibly with other values between them).

public SELF

Returns:

this assertion object.
doesNotContain
(int...
the given values.
values
)

Verifies that the actual array does not contain the given values.

public SELF

Returns:

this assertion object.
doesNotContain
(Integer[]
the given values.
values
)

Verifies that the actual array does not contain the values of the given array.

public SELF

Returns:

myself assertion object.
doesNotContain
(int
the value to look for.
value
,
Index
the index where the value should be stored in the actual array.
index
)

Verifies that the actual array does not contain the given value at the given index.

public SELF

Returns:

this assertion object.
doesNotHaveDuplicates
()

Verifies that the actual array does not contain duplicates.

public SELF

Returns:

myself assertion object.
endsWith
(int...
the sequence of values to look for.
sequence
)

Verifies that the actual array ends with the given sequence of values, without any other values between them.

public SELF

Returns:

myself assertion object.
endsWith
(Integer[]
the sequence of values to look for.
sequence
)

Verifies that the actual array ends with the given sequence of values, without any other values between them.

public SELF
hasSameSizeAs(Iterable<?>
the Iterable to compare size with actual group.
other
)

Implements org.assertj.core.api.EnumerableAssert.hasSameSizeAs.

Verifies that the actual group has the same size as given Iterable.
public SELF
hasSize(int
the expected number of values in the actual group.
expected
)

Implements org.assertj.core.api.EnumerableAssert.hasSize.

Verifies that the number of values in the actual group is equal to the given one.
public SELF

Returns:

this assertion object.
hasSizeBetween
(int
the lower boundary compared to which actual size should be greater than or equal to.
lowerBoundary
,
int
the higher boundary compared to which actual size should be less than or equal to.
higherBoundary
)

Implements org.assertj.core.api.EnumerableAssert.hasSizeBetween.

Verifies that the number of values in the actual array is between the given boundaries (inclusive).
public SELF

Returns:

this assertion object.
hasSizeGreaterThan
(int
the given value to compare the actual size to.
boundary
)

Implements org.assertj.core.api.EnumerableAssert.hasSizeGreaterThan.

Verifies that the number of values in the actual array is greater than the given boundary.
public SELF

Returns:

this assertion object.
hasSizeGreaterThanOrEqualTo
(int
the given value to compare the actual size to.
boundary
)

Implements org.assertj.core.api.EnumerableAssert.hasSizeGreaterThanOrEqualTo.

Verifies that the number of values in the actual array is greater than or equal to the given boundary.
public SELF

Returns:

this assertion object.
hasSizeLessThan
(int
the given value to compare the actual size to.
boundary
)

Implements org.assertj.core.api.EnumerableAssert.hasSizeLessThan.

Verifies that the number of values in the actual array is less than the given boundary.
public SELF

Returns:

this assertion object.
hasSizeLessThanOrEqualTo
(int
the given value to compare the actual size to.
boundary
)

Implements org.assertj.core.api.EnumerableAssert.hasSizeLessThanOrEqualTo.

Verifies that the number of values in the actual array is less than or equal to the given boundary.
public void
isEmpty()

Implements org.assertj.core.api.EnumerableAssert.isEmpty.

Verifies that the actual group of values is empty.
public SELF
isNotEmpty()

Implements org.assertj.core.api.EnumerableAssert.isNotEmpty.

Verifies that the actual group of values is not empty.
public void
isNullOrEmpty()

Implements org.assertj.core.api.EnumerableAssert.isNullOrEmpty.

Verifies that the actual group of values is null or empty.
public SELF
isSorted()

Implements org.assertj.core.api.ArraySortedAssert.isSorted.

Verifies that the actual array is sorted in ascending order according to the natural ordering of its elements.
public SELF
isSortedAccordingTo(Comparator<? super Integer>
the Comparator used to compare array elements
comparator
)

Implements org.assertj.core.api.ArraySortedAssert.isSortedAccordingTo.

Verifies that the actual array is sorted according to the given comparator.
public SELF

Returns:

myself assertion object.
startsWith
(int...
the sequence of values to look for.
sequence
)

Verifies that the actual array starts with the given sequence of values, without any other values between them.

public SELF

Returns:

myself assertion object.
startsWith
(Integer[]
the sequence of values to look for.
sequence
)

Verifies that the actual array starts with the given sequence of values, without any other values between them.

private static int[]
public SELF
usingDefaultElementComparator()

Implements org.assertj.core.api.EnumerableAssert.usingDefaultElementComparator.

Revert to standard comparison for incoming assertion group element checks.
public SELF
usingElementComparator(Comparator<? super Integer>
the comparator to use for incoming assertion checks.
customComparator
)

Implements org.assertj.core.api.EnumerableAssert.usingElementComparator.

Use given custom comparator instead of relying on actual type A equals method to compare group elements for incoming assertion checks.
Inherited from org.assertj.core.api.AbstractArrayAssert:
requireNonNullParameter

Field Detail

arraysback to summary
protected IntArrays arrays
Annotations
@VisibleForTesting

Constructor Detail

AbstractIntArrayAssertback to summary
protected AbstractIntArrayAssert(int[] actual, Class<?> selfType)

Method Detail

containsback to summary
public SELF contains(int... values)

Verifies that the actual array contains the given values, in any order.

Example:

 // assertions will pass
assertThat(new int[] { 1, 2, 3 }).contains(1, 2);
assertThat(new int[] { 1, 2, 3 }).contains(3, 1);
assertThat(new int[] { 1, 2, 3 }).contains(1, 3, 2);

// assertions will fail
assertThat(new int[] { 1, 2, 3 }).contains(1, 4);
assertThat(new int[] { 1, 2, 3 }).contains(4, 7);
Parameters
values:int[]

the given values.

Returns:SELF

this assertion object.

Exceptions
NullPointerException:
if the given argument is null.
AssertionError:
  • if the given argument is an empty array and the actual array is not empty.
  • if the actual array is null.
  • if the actual array does not contain the given values.
containsback to summary
public SELF contains(Integer[] values)

Verifies that the actual array contains the values of the given array, in any order.

Example:

 // assertion will pass
assertThat(new int[] { 1, 2, 3 }).contains(new Integer[] { 1, 2 });
assertThat(new int[] { 1, 2, 3 }).contains(new Integer[] { 3, 1 });
assertThat(new int[] { 1, 2, 3 }).contains(new Integer[] { 1, 3, 2 });

// assertion will fail
assertThat(new int[] { 1, 2, 3 }).contains(new Integer[] { 1, 4 });
assertThat(new int[] { 1, 2, 3 }).contains(new Integer[] { 4, 7 });
Parameters
values:Integer[]

the given values.

Returns:SELF

this assertion object.

Exceptions
NullPointerException:
if the given argument is null.
AssertionError:
  • if the given argument is an empty array and the actual array is not empty.
  • if the actual array is null.
  • if the actual array does not contain the given values.
Since
3.19.0
containsback to summary
public SELF contains(int value, Index index)

Verifies that the actual array contains the given value at the given index.

Example:

 // assertions will pass
assertThat(new int[] { 1, 2, 3 }).contains(1, atIndex(O));
assertThat(new int[] { 1, 2, 3 }).contains(3, atIndex(2));

// assertions will fail
assertThat(new int[] { 1, 2, 3 }).contains(1, atIndex(1));
assertThat(new int[] { 1, 2, 3 }).contains(4, atIndex(2));
Parameters
value:int

the value to look for.

index:Index

the index where the value should be stored in the actual array.

Returns:SELF

myself assertion object.

Exceptions
AssertionError:
  • if the actual array is null or empty.
  • if the actual array does not contain the given value at the given index.
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 array.
containsAnyOfback to summary
public SELF containsAnyOf(int... values)

Verifies that the actual array contains at least one of the given values.

Example :

 int[] oneTwoThree = { 1, 2, 3 };

// assertions will pass
assertThat(oneTwoThree).containsAnyOf(2)
                       .containsAnyOf(2, 3)
                       .containsAnyOf(1, 2, 3)
                       .containsAnyOf(1, 2, 3, 4)
                       .containsAnyOf(5, 6, 7, 2);

// assertions will fail
assertThat(oneTwoThree).containsAnyOf(4);
assertThat(oneTwoThree).containsAnyOf(4, 5, 6, 7);
Parameters
values:int[]

the values whose at least one which is expected to be in the array under test.

Returns:SELF

this assertion object.

Exceptions
NullPointerException:
if the array of values is null.
AssertionError:
  • if the array of values is empty and the array under test is not empty.
  • if the array under test is null.
  • if the array under test does not contain any of the given values.
Since
2.9.0 / 3.9.0
containsAnyOfback to summary
public SELF containsAnyOf(Integer[] values)

Verifies that the actual array contains at least one of the values of the given array.

Example :

 int[] oneTwoThree = { 1, 2, 3 };

// assertions will pass
assertThat(oneTwoThree).containsAnyOf(new Integer[] { 2 })
                       .containsAnyOf(new Integer[] { 2, 3 })
                       .containsAnyOf(new Integer[] { 1, 2, 3 })
                       .containsAnyOf(new Integer[] { 1, 2, 3, 4 })
                       .containsAnyOf(new Integer[] { 5, 6, 7, 2 });

// assertions will fail
assertThat(oneTwoThree).containsAnyOf(new Integer[] { 4 });
assertThat(oneTwoThree).containsAnyOf(new Integer[] { 4, 5, 6, 7 });
Parameters
values:Integer[]

the values whose at least one which is expected to be in the array under test.

Returns:SELF

this assertion object.

Exceptions
NullPointerException:
if the array of values is null.
AssertionError:
  • if the array of values is empty and the array under test is not empty.
  • if the array under test is null.
  • if the array under test does not contain any of the given values.
Since
3.19.0
containsExactlyback to summary
public SELF containsExactly(int... values)

Verifies that the actual array contains only the given values and nothing else, in order.

Example :

 int[] ints = { 1, 2, 3 };

// assertion will pass
assertThat(ints).containsExactly(1, 2, 3);

// assertion will fail as actual and expected order differ
assertThat(ints).containsExactly(2, 1, 3);
Parameters
values:int[]

the given values.

Returns:SELF

this assertion object.

Exceptions
NullPointerException:
if the given argument is null.
AssertionError:
  • if the actual array is null.
  • if the given argument is an empty array and the actual array is not empty.
  • if the actual array does not contain the given values with same order, i.e. the actual array contains some or none of the given values, or the actual array contains more values than the given ones or values are the same but the order is not.
containsExactlyback to summary
public SELF containsExactly(Integer[] values)

Verifies that the actual group contains only the values of the given array and nothing else, in order.

Example :

 // assertion will pass
assertThat(new int[] { 1, 2, 3 }).containsExactly(new Integer[] { 1, 2, 3 });

// assertion will fail as actual and expected order differ
assertThat(new int[] { 1, 2, 3 }).containsExactly(new Integer[] { 1, 3, 2 });
Parameters
values:Integer[]

the given values.

Returns:SELF

this assertion object.

Exceptions
NullPointerException:
if the given argument is null.
AssertionError:
  • if the actual group is null.
  • if the given argument is an empty array and the actual array is not empty.
  • if the actual group does not contain the given values with same order, i.e. the actual group contains some or none of the given values, or the actual group contains more values than the given ones or values are the same but the order is not.
Since
3.19.0
containsExactlyInAnyOrderback to summary
public SELF containsExactlyInAnyOrder(int... values)

Verifies that the actual array contains exactly the given values and nothing else, in any order.

Example :

 // assertions will pass
assertThat(new int[] { 1, 2 }).containsExactlyInAnyOrder(1, 2);
assertThat(new int[] { 1, 2, 1 }).containsExactlyInAnyOrder(1, 1, 2);

// assertions will fail
assertThat(new int[] { 1, 2 }).containsExactlyInAnyOrder(1);
assertThat(new int[] { 1 }).containsExactlyInAnyOrder(1, 2);
assertThat(new int[] { 1, 2, 1 }).containsExactlyInAnyOrder(1, 2);
Parameters
values:int[]

the given values.

Returns:SELF

this assertion object.

Exceptions
NullPointerException:
if the given argument is null.
AssertionError:
  • if the actual array is null.
  • if the given argument is an empty array and the actual array is not empty.
  • if the actual array does not contain the given values, i.e. the actual array contains some or none of the given values, or the actual array contains more values than the given ones.
Since
2.6.0 / 3.6.0
containsExactlyInAnyOrderback to summary
public SELF containsExactlyInAnyOrder(Integer[] values)

Verifies that the actual group contains exactly the values of the given array and nothing else, in any order.

Example :

 // assertions will pass
assertThat(new int[] { 1, 2 }).containsExactlyInAnyOrder(new Integer[] { 2, 1 });
assertThat(new int[] { 1, 2, 3 }).containsExactlyInAnyOrder(new Integer[] { 3, 2, 1 });

// assertions will fail
assertThat(new int[] { 1, 2 }).containsExactlyInAnyOrder(new Integer[] { 1, 4 });
assertThat(new int[] { 1 }).containsExactlyInAnyOrder(new Integer[] { 4, 1 });
assertThat(new int[] { 1, 2, 3 }).containsExactlyInAnyOrder(new Integer[] { 1, 2 });
Parameters
values:Integer[]

the given values.

Returns:SELF

this assertion object.

Exceptions
NullPointerException:
if the given argument is null.
AssertionError:
  • if the actual group is null.
  • if the given argument is an empty array and the actual array is not empty.
  • if the actual group does not contain the given values, i.e. the actual group contains some or none of the given values, or the actual group contains more values than the given ones.
Since
3.19.0
containsOnlyback to summary
public SELF containsOnly(int... values)

Verifies that the actual array contains only the given values and nothing else, in any order.

Example:

 // assertions will pass
assertThat(new int[] { 1, 2, 3 }).containsOnly(1, 2, 3);
assertThat(new int[] { 1, 2, 3 }).containsOnly(2, 3, 1);
assertThat(new int[] { 1, 1, 2 }).containsOnly(1, 2);

// assertions will fail
assertThat(new int[] { 1, 2, 3 }).containsOnly(1, 2, 3, 4);
assertThat(new int[] { 1, 2, 3 }).containsOnly(4, 7);
Parameters
values:int[]

the given values.

Returns:SELF

this assertion object.

Exceptions
NullPointerException:
if the given argument is null.
AssertionError:
  • if the given argument is an empty array and the actual array is not empty.
  • if the actual array is null.
  • if the actual array does not contain the given values, i.e. the actual array contains some or none of the given values, or the actual array contains more values than the given ones.
containsOnlyback to summary
public SELF containsOnly(Integer[] values)

Verifies that the actual array contains only the values of the given array and nothing else, in any order.

Example:

 // assertions will pass
assertThat(new int[] { 1, 2, 3 }).containsOnly(new Integer[] { 1, 2, 3 });
assertThat(new int[] { 1, 2, 3 }).containsOnly(new Integer[] { 2, 3, 1 });
assertThat(new int[] { 1, 1, 2 }).containsOnly(new Integer[] { 1, 2 });

// assertions will fail
assertThat(new int[] { 1, 2, 3 }).containsOnly(new Integer[] { 1, 2, 3, 4 });
assertThat(new int[] { 1, 2, 3 }).containsOnly(new Integer[] { 4, 7 });
Parameters
values:Integer[]

the given values.

Returns:SELF

this assertion object.

Exceptions
NullPointerException:
if the given argument is null.
AssertionError:
  • if the given argument is an empty array and the actual array is not empty.
  • if the actual array is null.
  • if the actual array does not contain the given values, i.e. the actual array contains some or none of the given values, or the actual array contains more values than the given ones.
Since
3.19.0
containsOnlyOnceback to summary
public SELF containsOnlyOnce(int... values)

Verifies that the actual array contains the given values only once.

Examples :

 // assertion will pass
assertThat(new int[] { 1, 2, 3 }).containsOnlyOnce(1, 2);

// assertions will fail
assertThat(new int[] { 1, 2, 1 }).containsOnlyOnce(1);
assertThat(new int[] { 1, 2, 3 }).containsOnlyOnce(4);
assertThat(new int[] { 1, 2, 3, 3 }).containsOnlyOnce(0, 1, 2, 3, 4, 5);
Parameters
values:int[]

the given values.

Returns:SELF

this assertion object.

Exceptions
NullPointerException:
if the given argument is null.
AssertionError:
  • if the given argument is an empty array and the actual array is not empty.
  • if the actual array is null.
  • if the actual array does not contain the given values, i.e. the actual array contains some or none of the given values, or the actual array contains more than once these values.
containsOnlyOnceback to summary
public SELF containsOnlyOnce(Integer[] values)

Verifies that the actual array contains the values of the given array only once.

Examples :

 // assertion will pass
assertThat(new int[] { 1, 2, 3 }).containsOnlyOnce(new Integer[] { 1, 2 });

// assertions will fail
assertThat(new int[] { 1, 2, 1 }).containsOnlyOnce(new Integer[] { 1 });
assertThat(new int[] { 1, 2, 3 }).containsOnlyOnce(new Integer[] { 4 });
assertThat(new int[] { 1, 2, 3, 3 }).containsOnlyOnce(new Integer[] { 0, 1, 2, 3, 4, 5 });
Parameters
values:Integer[]

the given values.

Returns:SELF

this assertion object.

Exceptions
NullPointerException:
if the given argument is null.
AssertionError:
  • if the given argument is an empty array and the actual array is not empty.
  • if the actual array is null.
  • if the actual group does not contain the given values, i.e. the actual group contains some or none of the given values, or the actual group contains more than once these values.
Since
3.19.0
containsSequenceback to summary
public SELF containsSequence(int... sequence)

Verifies that the actual array contains the given sequence, without any other values between them.

Example:

 // assertion will pass
assertThat(new int[] { 1, 2, 3 }).containsSequence(1, 2);

// assertion will fail
assertThat(new int[] { 1, 2, 3 }).containsSequence(1, 3);
assertThat(new int[] { 1, 2, 3 }).containsSequence(2, 1);
Parameters
sequence:int[]

the sequence of values to look for.

Returns:SELF

myself assertion object.

Exceptions
AssertionError:
  • if the actual array is null.
  • if the given array is null.
  • if the given argument is an empty array and the actual array is not empty.
  • if the actual array does not contain the given sequence.
containsSequenceback to summary
public SELF containsSequence(Integer[] sequence)

Verifies that the actual array contains the given sequence, without any other values between them.

Example:

 // assertion will pass
assertThat(new int[] { 1, 2, 3 }).containsSequence(new Integer[] { 1, 2 });

// assertion will fail
assertThat(new int[] { 1, 2, 3 }).containsSequence(new Integer[] { 1, 3 });
assertThat(new int[] { 1, 2, 3 }).containsSequence(new Integer[] { 2, 1 });
Parameters
sequence:Integer[]

the sequence of values to look for.

Returns:SELF

myself assertion object.

Exceptions
AssertionError:
  • if the actual array is null.
  • if the given array is null.
  • if the given argument is an empty array and the actual array is not empty.
  • if the actual array does not contain the given sequence.
Since
3.19.0
containsSubsequenceback to summary
public SELF containsSubsequence(int... subsequence)

Verifies that the actual array contains the given subsequence (possibly with other values between them).

Example:

 // assertion will pass
assertThat(new int[] { 1, 2, 3 }).containsSubsequence(1, 2);
assertThat(new int[] { 1, 2, 3 }).containsSubsequence(1, 3);

// assertion will fail
assertThat(new int[] { 1, 2, 3 }).containsSubsequence(2, 1);
Parameters
subsequence:int[]

the subsequence of values to look for.

Returns:SELF

myself assertion object.

Exceptions
AssertionError:
  • if the actual array is null.
  • if the given array is null.
  • if the given argument is an empty array and the actual array is not empty.
  • if the actual array does not contain the given subsequence.
containsSubsequenceback to summary
public SELF containsSubsequence(Integer[] subsequence)

Verifies that the actual array contains the given subsequence (possibly with other values between them).

Example:

 // assertion will pass
assertThat(new int[] { 1, 2, 3 }).containsSubsequence(new Integer[] { 1, 2 });
assertThat(new int[] { 1, 2, 3 }).containsSubsequence(new Integer[] { 1, 3 });

// assertion will fail
assertThat(new int[] { 1, 2, 3 }).containsSubsequence(new Integer[] { 2, 1 });
Parameters
subsequence:Integer[]

the subsequence of values to look for.

Returns:SELF

myself assertion object.

Exceptions
AssertionError:
  • if the actual array is null.
  • if the given array is null.
  • if the given argument is an empty array and the actual array is not empty.
  • if the actual array does not contain the given subsequence.
Since
3.19.0
doesNotContainback to summary
public SELF doesNotContain(int... values)

Verifies that the actual array does not contain the given values.

Example:

 // assertion will pass
assertThat(new int[] { 1, 2, 3 }).doesNotContain(4);

// assertion will fail
assertThat(new int[] { 1, 2, 3 }).doesNotContain(2);
Parameters
values:int[]

the given values.

Returns:SELF

this assertion object.

Exceptions
NullPointerException:
if the given argument is null.
IllegalArgumentException:
if the given argument is an empty array.
AssertionError:
  • if the actual array is null.
  • if the actual array contains any of the given values.
doesNotContainback to summary
public SELF doesNotContain(Integer[] values)

Verifies that the actual array does not contain the values of the given array.

Example:

 // assertion will pass
assertThat(new int[] { 1, 2, 3 }).doesNotContain(new Integer[] { 4 });

// assertion will fail
assertThat(new int[] { 1, 2, 3 }).doesNotContain(new Integer[] { 2 });
Parameters
values:Integer[]

the given values.

Returns:SELF

this assertion object.

Exceptions
NullPointerException:
if the given argument is null.
IllegalArgumentException:
if the given argument is an empty array.
AssertionError:
  • if the actual array is null.
  • if the actual array contains any of the given values.
Since
3.19.0
doesNotContainback to summary
public SELF doesNotContain(int value, Index index)

Verifies that the actual array does not contain the given value at the given index.

Example:

 // assertions will pass
assertThat(new int[] { 1, 2, 3 }).doesNotContain(1, atIndex(1));
assertThat(new int[] { 1, 2, 3 }).doesNotContain(2, atIndex(0));

// assertions will fail
assertThat(new int[] { 1, 2, 3 }).doesNotContain(1, atIndex(0));
assertThat(new int[] { 1, 2, 3 }).doesNotContain(2, atIndex(1));
Parameters
value:int

the value to look for.

index:Index

the index where the value should be stored in the actual array.

Returns:SELF

myself assertion object.

Exceptions
AssertionError:
  • if the actual array is null.
  • if the actual array contains the given value at the given index.
NullPointerException:
if the given Index is null.
doesNotHaveDuplicatesback to summary
public SELF doesNotHaveDuplicates()

Verifies that the actual array does not contain duplicates.

Example:

 // assertion will pass
assertThat(new int[] { 1, 2, 3 }).doesNotHaveDuplicates();

// assertion will fail
assertThat(new int[] { 1, 1, 2, 3 }).doesNotHaveDuplicates();
Returns:SELF

this assertion object.

Exceptions
AssertionError:
  • if the actual array is null.
  • if the actual array contains duplicates.
endsWithback to summary
public SELF endsWith(int... sequence)

Verifies that the actual array ends with the given sequence of values, without any other values between them. Similar to containsSequence(int...), but it also verifies that the last element in the sequence is also last element of the actual array.

Example:

 // assertion will pass
assertThat(new int[] { 1, 2, 3 }).endsWith(2, 3);

// assertion will fail
assertThat(new int[] { 1, 2, 3 }).endsWith(3, 4);
Parameters
sequence:int[]

the sequence of values to look for.

Returns:SELF

myself assertion object.

Exceptions
NullPointerException:
if the given argument is null.
AssertionError:
  • if the actual array is null.
  • if the actual array does not end with the given sequence.
endsWithback to summary
public SELF endsWith(Integer[] sequence)

Verifies that the actual array ends with the given sequence of values, without any other values between them. Similar to containsSequence(int...), but it also verifies that the last element in the sequence is also last element of the actual array.

Example:

 // assertion will pass
assertThat(new int[] { 1, 2, 3 }).endsWith(new Integer[] { 2, 3 });

// assertion will fail
assertThat(new int[] { 1, 2, 3 }).endsWith(new Integer[] { 3, 4 });
Parameters
sequence:Integer[]

the sequence of values to look for.

Returns:SELF

myself assertion object.

Exceptions
NullPointerException:
if the given argument is null.
AssertionError:
  • if the actual array is null.
  • if the actual array does not end with the given sequence.
Since
3.19.0
hasSameSizeAsback to summary
public SELF hasSameSizeAs(Iterable<?> other)

Implements org.assertj.core.api.EnumerableAssert.hasSameSizeAs.

Doc from org.assertj.core.api.EnumerableAssert.hasSameSizeAs.

Verifies that the actual group has the same size as given Iterable.

Example:

 Iterable<String> abc = newArrayList("a", "b", "c");
Iterable<Ring> elvesRings = newArrayList(vilya, nenya, narya);

// assertion will pass
assertThat(elvesRings).hasSameSizeAs(abc);

// assertions will fail
assertThat(elvesRings).hasSameSizeAs(Arrays.asList(1, 2));
assertThat(elvesRings).hasSameSizeAs(Arrays.asList(1, 2, 3, 4));
Parameters
other:Iterable<?>

the Iterable to compare size with actual group.

Returns:SELF

this assertion object.

Annotations
@Override
hasSizeback to summary
public SELF hasSize(int expected)

Implements org.assertj.core.api.EnumerableAssert.hasSize.

Doc from org.assertj.core.api.EnumerableAssert.hasSize.

Verifies that the number of values in the actual group is equal to the given one.

Example:

 // assertions will pass
assertThat(new String[] { "a", "b" }).hasSize(2);
assertThat(Arrays.asList(1, 2, 3)).hasSize(3);

// assertions will fail
assertThat(new ArrayList()).hasSize(1);
assertThat(new int[] { 1, 2, 3 }).hasSize(2);
Parameters
expected:int

the expected number of values in the actual group.

Returns:SELF

this assertion object.

Annotations
@Override
hasSizeBetweenback to summary
public SELF hasSizeBetween(int lowerBoundary, int higherBoundary)

Implements org.assertj.core.api.EnumerableAssert.hasSizeBetween.

Verifies that the number of values in the actual array is between the given boundaries (inclusive).

Example:

 // assertions will pass
assertThat(new int[] { 1, 2, 3 }).hasSizeBetween(0, 4)
                                 .hasSizeBetween(3, 3);

// assertions will fail
assertThat(new int[] { 1, 2, 3 }).hasSizeBetween(4, 6);
assertThat(new int[] { 1, 2, 3 }).hasSizeBetween(0, 2);
Parameters
lowerBoundary:int

the lower boundary compared to which actual size should be greater than or equal to.

higherBoundary:int

the higher boundary compared to which actual size should be less than or equal to.

Returns:SELF

this assertion object.

Annotations
@Override
Exceptions
AssertionError:
if the number of values of the actual array is not between the boundaries.
Since
3.12.0
hasSizeGreaterThanback to summary
public SELF hasSizeGreaterThan(int boundary)

Implements org.assertj.core.api.EnumerableAssert.hasSizeGreaterThan.

Verifies that the number of values in the actual array is greater than the given boundary.

Example:

 // assertion will pass
assertThat(new int[] { 1, 2, 3 }).hasSizeGreaterThan(2);

// assertion will fail
assertThat(new int[] { 1, 2, 3 }).hasSizeGreaterThan(6);
Parameters
boundary:int

the given value to compare the actual size to.

Returns:SELF

this assertion object.

Annotations
@Override
Exceptions
AssertionError:
if the number of values of the actual array is not greater than the boundary.
Since
3.12.0
hasSizeGreaterThanOrEqualToback to summary
public SELF hasSizeGreaterThanOrEqualTo(int boundary)

Implements org.assertj.core.api.EnumerableAssert.hasSizeGreaterThanOrEqualTo.

Verifies that the number of values in the actual array is greater than or equal to the given boundary.

Example:

 // assertions will pass
assertThat(new int[] { 1, 2, 3 }).hasSizeGreaterThanOrEqualTo(2)
                                 .hasSizeGreaterThanOrEqualTo(3);

// assertion will fail
assertThat(new int[] { 1, 2, 3 }).hasSizeGreaterThanOrEqualTo(4);
Parameters
boundary:int

the given value to compare the actual size to.

Returns:SELF

this assertion object.

Annotations
@Override
Exceptions
AssertionError:
if the number of values of the actual array is not greater than or equal to the boundary.
Since
3.12.0
hasSizeLessThanback to summary
public SELF hasSizeLessThan(int boundary)

Implements org.assertj.core.api.EnumerableAssert.hasSizeLessThan.

Verifies that the number of values in the actual array is less than the given boundary.

Example:

 // assertion will pass
assertThat(new int[] { 1, 2, 3 }).hasSizeLessThan(5);

// assertion will fail
assertThat(new int[] { 1, 2, 3 }).hasSizeLessThan(4);
Parameters
boundary:int

the given value to compare the actual size to.

Returns:SELF

this assertion object.

Annotations
@Override
Exceptions
AssertionError:
if the number of values of the actual array is not less than the boundary.
Since
3.12.0
hasSizeLessThanOrEqualToback to summary
public SELF hasSizeLessThanOrEqualTo(int boundary)

Implements org.assertj.core.api.EnumerableAssert.hasSizeLessThanOrEqualTo.

Verifies that the number of values in the actual array is less than or equal to the given boundary.

Example:

 // assertions will pass
assertThat(new int[] { 1, 2, 3 }).hasSizeLessThanOrEqualTo(5)
                                 .hasSizeLessThanOrEqualTo(3);

// assertions will fail
assertThat(new int[] { 1, 2, 3 }).hasSizeLessThanOrEqualTo(4);
Parameters
boundary:int

the given value to compare the actual size to.

Returns:SELF

this assertion object.

Annotations
@Override
Exceptions
AssertionError:
if the number of values of the actual array is not less than or equal to the boundary.
Since
3.12.0
isEmptyback to summary
public void isEmpty()

Implements org.assertj.core.api.EnumerableAssert.isEmpty.

Doc from org.assertj.core.api.EnumerableAssert.isEmpty.

Verifies that the actual group of values is empty.

Example:

 // assertions will pass
assertThat(new ArrayList()).isEmpty();
assertThat(new int[] { }).isEmpty();

// assertions will fail
assertThat(new String[] { "a", "b" }).isEmpty();
assertThat(Arrays.asList(1, 2, 3)).isEmpty();
Annotations
@Override
isNotEmptyback to summary
public SELF isNotEmpty()

Implements org.assertj.core.api.EnumerableAssert.isNotEmpty.

Doc from org.assertj.core.api.EnumerableAssert.isNotEmpty.

Verifies that the actual group of values is not empty.

Example:

 // assertions will pass
assertThat(new String[] { "a", "b" }).isNotEmpty();
assertThat(Arrays.asList(1, 2, 3)).isNotEmpty();

// assertions will fail
assertThat(new ArrayList()).isNotEmpty();
assertThat(new int[] { }).isNotEmpty();
Returns:SELF

this assertion object.

Annotations
@Override
isNullOrEmptyback to summary
public void isNullOrEmpty()

Implements org.assertj.core.api.EnumerableAssert.isNullOrEmpty.

Doc from org.assertj.core.api.EnumerableAssert.isNullOrEmpty.

Verifies that the actual group of values is null or empty.

Example:

 // assertions will pass
List<String> strings = new ArrayList<>();
assertThat(strings).isNullOrEmpty();
assertThat(new int[] { }).isNullOrEmpty();

// assertions will fail
assertThat(new String[] { "a", "b"}).isNullOrEmpty();
assertThat(Arrays.asList(1, 2, 3)).isNullOrEmpty();
Annotations
@Override
isSortedback to summary
public SELF isSorted()

Implements org.assertj.core.api.ArraySortedAssert.isSorted.

Doc from org.assertj.core.api.ArraySortedAssert.isSorted.

Verifies that the actual array is sorted in ascending order according to the natural ordering of its elements.

All array elements must be primitive or implement the Comparable interface and must be mutually comparable (that is, e1.compareTo(e2) must not throw a ClassCastException for any elements e1 and e2 in the array), examples :

  • a array composed of {2, 4, 6} is ok because the element type is a primitive type.
  • a array composed of {"a1", "a2", "a3"} is ok because the element type (String) is Comparable
  • a array composed of Rectangle {r1, r2, r3} is NOT ok because Rectangle is not Comparable
  • a array composed of {True, "abc", False} is NOT ok because elements are not mutually comparable (even though each element type implements Comparable)
Empty or one element arrays are considered sorted (unless the array element type is not Comparable).

Returns:SELF

this assertion object.

Annotations
@Override
isSortedAccordingToback to summary
public SELF isSortedAccordingTo(Comparator<? super Integer> comparator)

Implements org.assertj.core.api.ArraySortedAssert.isSortedAccordingTo.

Doc from org.assertj.core.api.ArraySortedAssert.isSortedAccordingTo.

Verifies that the actual array is sorted according to the given comparator.
Empty arrays are considered sorted whatever the comparator is.
One element arrays are considered sorted if the element is compatible with comparator, otherwise an AssertionError is thrown.

Parameters
comparator:Comparator<? super Integer>

the Comparator used to compare array elements

Returns:SELF

this assertion object.

Annotations
@Override
startsWithback to summary
public SELF startsWith(int... sequence)

Verifies that the actual array starts with the given sequence of values, without any other values between them. Similar to containsSequence(int...), but it also verifies that the first element in the sequence is also first element of the actual array.

Example:

 // assertion will pass
assertThat(new int[] { 1, 2, 3 }).startsWith(1, 2);

// assertion will fail
assertThat(new int[] { 1, 2, 3 }).startsWith(2, 3);
Parameters
sequence:int[]

the sequence of values to look for.

Returns:SELF

myself assertion object.

Exceptions
NullPointerException:
if the given argument is null.
AssertionError:
  • if the given argument is an empty array and the actual array is not empty.
  • if the actual array is null.
  • if the actual array does not start with the given sequence.
startsWithback to summary
public SELF startsWith(Integer[] sequence)

Verifies that the actual array starts with the given sequence of values, without any other values between them. Similar to containsSequence(int...), but it also verifies that the first element in the sequence is also first element of the actual array.

Example:

 // assertion will pass
assertThat(new int[] { 1, 2, 3 }).startsWith(new Integer[] { 1, 2 });

// assertion will fail
assertThat(new int[] { 1, 2, 3 }).startsWith(new Integer[] { 2, 3 });
Parameters
sequence:Integer[]

the sequence of values to look for.

Returns:SELF

myself assertion object.

Exceptions
NullPointerException:
if the given argument is null.
AssertionError:
  • if the given argument is an empty array and the actual array is not empty.
  • if the actual array is null.
  • if the actual array does not start with the given sequence.
Since
3.19.0
toPrimitiveIntArrayback to summary
private static int[] toPrimitiveIntArray(Integer[] values)
usingDefaultElementComparatorback to summary
public SELF usingDefaultElementComparator()

Implements org.assertj.core.api.EnumerableAssert.usingDefaultElementComparator.

Doc from org.assertj.core.api.EnumerableAssert.usingDefaultElementComparator.

Revert to standard comparison for incoming assertion group element checks.

This method should be used to disable a custom comparison strategy set by calling usingElementComparator(Comparator).

Returns:SELF

this assertion object.

Annotations
@Override
@CheckReturnValue
usingElementComparatorback to summary
public SELF usingElementComparator(Comparator<? super Integer> customComparator)

Implements org.assertj.core.api.EnumerableAssert.usingElementComparator.

Doc from org.assertj.core.api.EnumerableAssert.usingElementComparator.

Use given custom comparator instead of relying on actual type A equals method to compare group elements for incoming assertion checks.

Custom comparator is bound to assertion instance, meaning that if a new assertion is created, it will use default comparison strategy.

Examples :
 // compares invoices by payee
assertThat(invoiceList).usingComparator(invoicePayeeComparator).isEqualTo(expectedInvoiceList);

// compares invoices by date, doesNotHaveDuplicates and contains both use the given invoice date comparator
assertThat(invoiceList).usingComparator(invoiceDateComparator).doesNotHaveDuplicates().contains(may2010Invoice);

// as assertThat(invoiceList) creates a new assertion, it falls back to standard comparison strategy
// based on Invoice's equal method to compare invoiceList elements to lowestInvoice.
assertThat(invoiceList).contains(lowestInvoice);

// standard comparison : the fellowshipOfTheRing includes Gandalf but not Sauron (believe me) ...
assertThat(fellowshipOfTheRing).contains(gandalf)
                               .doesNotContain(sauron);

// ... but if we compare only races, Sauron is in fellowshipOfTheRing because he's a Maia like Gandalf.
assertThat(fellowshipOfTheRing).usingElementComparator(raceComparator)
                               .contains(sauron);
Parameters
customComparator:Comparator<? super Integer>

the comparator to use for incoming assertion checks.

Returns:SELF

this assertion object.

Annotations
@Override
@CheckReturnValue