Package org.assertj.core.api
Class AtomicIntegerArrayAssert
- java.lang.Object
-
- org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
-
- org.assertj.core.api.AbstractEnumerableAssert<AtomicIntegerArrayAssert,AtomicIntegerArray,Integer>
-
- org.assertj.core.api.AtomicIntegerArrayAssert
-
- All Implemented Interfaces:
Assert<AtomicIntegerArrayAssert,AtomicIntegerArray>
,Descriptable<AtomicIntegerArrayAssert>
,EnumerableAssert<AbstractEnumerableAssert<AtomicIntegerArrayAssert,AtomicIntegerArray,Integer>,Integer>
,ExtensionPoints<AtomicIntegerArrayAssert,AtomicIntegerArray>
public class AtomicIntegerArrayAssert extends AbstractEnumerableAssert<AtomicIntegerArrayAssert,AtomicIntegerArray,Integer>
-
-
Field Summary
Fields Modifier and Type Field Description private int[]
array
protected IntArrays
arrays
-
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, assertionErrorCreator, conditions, info, myself, objects, throwUnsupportedExceptionOnEquals
-
-
Constructor Summary
Constructors Constructor Description AtomicIntegerArrayAssert(AtomicIntegerArray actual)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AtomicIntegerArrayAssert
contains(int... values)
Verifies that the actualAtomicIntegerArray
contains the given values, in any order.AtomicIntegerArrayAssert
contains(int value, Index index)
Verifies that the actual atomic array contains the given value at the given index.AtomicIntegerArrayAssert
containsAnyOf(int... values)
Verifies that the actual array contains at least one of the given values.AtomicIntegerArrayAssert
containsExactly(int... values)
Verifies that the actual AtomicIntegerArray contains only the given values and nothing else, in order.AtomicIntegerArrayAssert
containsExactlyInAnyOrder(int... values)
Verifies that the actual AtomicIntegerArray contains exactly the given values and nothing else, in any order.AtomicIntegerArrayAssert
containsOnly(int... values)
Verifies that the actual atomic array contains only the given values and nothing else, in any order.AtomicIntegerArrayAssert
containsOnlyOnce(int... values)
Verifies that the actual atomic array contains the given values only once.AtomicIntegerArrayAssert
containsSequence(int... sequence)
Verifies that the actual atomic array contains the given sequence, without any other values between them.AtomicIntegerArrayAssert
containsSubsequence(int... subsequence)
Verifies that the actual atomic array contains the given subsequence (possibly with other values between them).AtomicIntegerArrayAssert
doesNotContain(int... values)
Verifies that the actual atomic array does not contain the given values.AtomicIntegerArrayAssert
doesNotContain(int value, Index index)
Verifies that the actual atomic array does not contain the given value at the given index.AtomicIntegerArrayAssert
doesNotHaveDuplicates()
Verifies that the actual atomic array does not contain duplicates.AtomicIntegerArrayAssert
endsWith(int... sequence)
Verifies that the actual atomic array ends with the given sequence of values, without any other values between them.AtomicIntegerArrayAssert
hasArray(int[] expected)
Verifies that the AtomicIntegerArray has the given array.AtomicIntegerArrayAssert
hasSameSizeAs(Iterable<?> other)
Verifies that the AtomicIntegerArray has the same size as givenIterable
.AtomicIntegerArrayAssert
hasSize(int expected)
Verifies that the number of values in the AtomicIntegerArray is equal to the given one.AtomicIntegerArrayAssert
hasSizeBetween(int lowerBoundary, int higherBoundary)
Verifies that the number of values in the actual array is between the given boundaries (inclusive).AtomicIntegerArrayAssert
hasSizeGreaterThan(int boundary)
Verifies that the number of values in the actual array is greater than the given boundary.AtomicIntegerArrayAssert
hasSizeGreaterThanOrEqualTo(int boundary)
Verifies that the number of values in the actual array is greater than or equal to the given boundary.AtomicIntegerArrayAssert
hasSizeLessThan(int boundary)
Verifies that the number of values in the actual array is less than the given boundary.AtomicIntegerArrayAssert
hasSizeLessThanOrEqualTo(int boundary)
Verifies that the number of values in the actual array is less than or equal to the given boundary.void
isEmpty()
Verifies that the AtomicIntegerArray is empty.AtomicIntegerArrayAssert
isNotEmpty()
Verifies that the AtomicIntegerArray is not empty.void
isNullOrEmpty()
Verifies that the AtomicIntegerArray isnull
or empty.AtomicIntegerArrayAssert
isSorted()
Verifies that the actual AtomicIntegerArray is sorted in ascending order according to the natural ordering of its elements.AtomicIntegerArrayAssert
isSortedAccordingTo(Comparator<? super Integer> comparator)
Verifies that the actual AtomicIntegerArray 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.AtomicIntegerArrayAssert
startsWith(int... sequence)
Verifies that the actual atomic array starts with the given sequence of values, without any other values between them.AtomicIntegerArrayAssert
usingDefaultElementComparator()
Revert to standard comparison for incoming assertion group element checks.AtomicIntegerArrayAssert
usingElementComparator(Comparator<? super Integer> customComparator)
Use given custom comparator instead of relying on Integerequals
method to compare elements for incoming assertion checks.-
Methods inherited from class org.assertj.core.api.AbstractEnumerableAssert
hasSameSizeAs, inBinary, inHexadecimal
-
Methods inherited from class org.assertj.core.api.AbstractAssert
asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, is, isElementOfCustomAssert, isEqualTo, 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
-
arrays
protected IntArrays arrays
-
array
private int[] array
-
-
Constructor Detail
-
AtomicIntegerArrayAssert
public AtomicIntegerArrayAssert(AtomicIntegerArray actual)
-
-
Method Detail
-
isNullOrEmpty
public void isNullOrEmpty()
Verifies that the AtomicIntegerArray isnull
or empty.Example:
// assertions will pass assertThat(new AtomicIntegerArray(new int[0])).isNullOrEmpty(); AtomicIntegerArray array = null; assertThat(array).isNullOrEmpty(); // assertion will fail assertThat(new AtomicIntegerArray(new int[] { 1, 2, 3 })).isNullOrEmpty();
- Throws:
AssertionError
- if the AtomicIntegerArray is notnull
or not empty.- Since:
- 2.7.0 / 3.7.0
-
isEmpty
public void isEmpty()
Verifies that the AtomicIntegerArray is empty.Example:
// assertion will pass assertThat(new AtomicIntegerArray(new int[0])).isEmpty(); // assertion will fail assertThat(new AtomicIntegerArray(new int[] { 1, 2, 3 })).isEmpty();
- Throws:
AssertionError
- if the AtomicIntegerArray is not empty.- Since:
- 2.7.0 / 3.7.0
-
isNotEmpty
public AtomicIntegerArrayAssert isNotEmpty()
Verifies that the AtomicIntegerArray is not empty.Example:
// assertion will pass assertThat(new AtomicIntegerArray(new int[] { 1, 2, 3 })).isNotEmpty(); // assertion will fail assertThat(new AtomicIntegerArray(new int[0])).isNotEmpty();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the AtomicIntegerArray is empty.- Since:
- 2.7.0 / 3.7.0
-
hasArray
public AtomicIntegerArrayAssert hasArray(int[] expected)
Verifies that the AtomicIntegerArray has the given array.Example:
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 1, 2, 3 }); // assertion will pass assertThat(atomicIntegerArray).hasArray(new int[] { 1, 2, 3 }); // assertion will fail assertThat(atomicIntegerArray).hasArray(new int[] { 2, 3, 4 });
- Parameters:
expected
- the int[] array expected to be in the actual AtomicIntegerArray.- Returns:
this
assertion object.- Throws:
AssertionError
- if the AtomicIntegerArray does not have the given array.- Since:
- 2.7.0 / 3.7.0
-
hasSize
public AtomicIntegerArrayAssert hasSize(int expected)
Verifies that the number of values in the AtomicIntegerArray is equal to the given one.Example:
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 1, 2, 3 }); assertThat(atomicIntegerArray).hasSize(3); // assertion will fail assertThat(atomicIntegerArray).hasSize(1);
- Parameters:
expected
- the expected number of values in the actual AtomicIntegerArray.- Returns:
this
assertion object.- Throws:
AssertionError
- if the number of values of the AtomicIntegerArray is not equal to the given one.- Since:
- 2.7.0 / 3.7.0
-
hasSizeGreaterThan
public AtomicIntegerArrayAssert hasSizeGreaterThan(int boundary)
Verifies that the number of values in the actual array is greater than the given boundary.Example:
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 1, 2, 3 }); // assertion will pass assertThat(atomicIntegerArray).hasSizeGreaterThan(1); // assertion will fail assertThat(atomicIntegerArray).hasSizeGreaterThan(3);
- Parameters:
boundary
- the given value to compare the actual size to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the number of values of the actual array is not greater than the boundary.- Since:
- 3.12.0
-
hasSizeGreaterThanOrEqualTo
public AtomicIntegerArrayAssert hasSizeGreaterThanOrEqualTo(int boundary)
Verifies that the number of values in the actual array is greater than or equal to the given boundary.Example:
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 1, 2, 3 }); // assertion will pass assertThat(atomicIntegerArray).hasSizeGreaterThanOrEqualTo(3); // assertion will fail assertThat(atomicIntegerArray).hasSizeGreaterThanOrEqualTo(5);
- Parameters:
boundary
- the given value to compare the actual size to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the number of values of the actual array is not greater than or equal to the boundary.- Since:
- 3.12.0
-
hasSizeLessThan
public AtomicIntegerArrayAssert hasSizeLessThan(int boundary)
Verifies that the number of values in the actual array is less than the given boundary.Example:
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 1, 2, 3 }); // assertion will pass assertThat(atomicIntegerArray).hasSizeLessThan(4); // assertion will fail assertThat(atomicIntegerArray).hasSizeLessThan(2);
- Parameters:
boundary
- the given value to compare the actual size to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the number of values of the actual array is not less than the boundary.- Since:
- 3.12.0
-
hasSizeLessThanOrEqualTo
public AtomicIntegerArrayAssert hasSizeLessThanOrEqualTo(int boundary)
Verifies that the number of values in the actual array is less than or equal to the given boundary.Example:
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 1, 2, 3 }); // assertion will pass assertThat(atomicIntegerArray).hasSizeLessThanOrEqualTo(3); // assertion will fail assertThat(atomicIntegerArray).hasSizeLessThanOrEqualTo(2);
- Parameters:
boundary
- the given value to compare the actual size to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the number of values of the actual array is not less than or equal to the boundary.- Since:
- 3.12.0
-
hasSizeBetween
public AtomicIntegerArrayAssert hasSizeBetween(int lowerBoundary, int higherBoundary)
Verifies that the number of values in the actual array is between the given boundaries (inclusive).Example:
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 1, 2, 3 }); // assertion will pass assertThat(atomicIntegerArray).hasSizeBetween(3, 4); // assertion will fail assertThat(atomicIntegerArray).hasSizeBetween(4, 6);
- Parameters:
lowerBoundary
- the lower boundary compared to which actual size should be greater than or equal to.higherBoundary
- the higher boundary compared to which actual size should be less than or equal to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the number of values of the actual array is not between the boundaries.- Since:
- 3.12.0
-
hasSameSizeAs
public AtomicIntegerArrayAssert hasSameSizeAs(Iterable<?> other)
Verifies that the AtomicIntegerArray has the same size as givenIterable
.Example:
Iterable<String> abc = newArrayList("a", "b", "c"); AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 1, 2, 3 }); // assertion will pass assertThat(atomicIntegerArray).hasSameSizeAs(abc); // assertions will fail assertThat(atomicIntegerArray).hasSameSizeAs(Arrays.asList(1, 2)); assertThat(atomicIntegerArray).hasSameSizeAs(Arrays.asList(1, 2, 3, 4));
- Parameters:
other
- theIterable
to compare size with actual AtomicIntegerArray.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual AtomicIntegerArray isnull
.AssertionError
- if the otherIterable
isnull
.AssertionError
- if actual AtomicIntegerArray and givenIterable
don't have the same size.- Since:
- 2.7.0 / 3.7.0
-
contains
public AtomicIntegerArrayAssert contains(int... values)
Verifies that the actualAtomicIntegerArray
contains the given values, in any order.Example:
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 1, 2, 3 }); // assertions will pass assertThat(atomicIntegerArray).contains(1, 2) .contains(3, 1) .contains(1, 3, 2); // assertions will fail assertThat(atomicIntegerArray).contains(2, 3, 4); assertThat(atomicIntegerArray).contains(4, 5, 6);
- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual atomic array isnull
.AssertionError
- if the actual atomic array does not contain the given values.- Since:
- 2.7.0 / 3.7.0
-
containsOnly
public AtomicIntegerArrayAssert containsOnly(int... values)
Verifies that the actual atomic array contains only the given values and nothing else, in any order.Example:
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 1, 2, 3 }); // assertions will pass assertThat(atomicIntegerArray).containsOnly(1, 2, 3) .containsOnly(2, 3, 1); assertThat(new AtomicIntegerArray(new int[] { 1, 1, 2 })).containsOnly(1, 2); // assertions will fail assertThat(atomicIntegerArray).containsOnly(1, 2, 3, 4); assertThat(atomicIntegerArray).containsOnly(4, 7);
- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual atomic array isnull
.AssertionError
- if the actual atomic array does not contain the given values, i.e. it contains a subset of of the given values, or more values than the given ones.- Since:
- 2.7.0 / 3.7.0
-
containsOnlyOnce
public AtomicIntegerArrayAssert containsOnlyOnce(int... values)
Verifies that the actual atomic array contains the given values only once.Examples :
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 1, 2, 3 }); // assertion will pass assertThat(atomicIntegerArray).containsOnlyOnce(1, 2); // assertions will fail assertThat(atomicIntegerArray).containsOnlyOnce(4); assertThat(new AtomicIntegerArray(new int[] { 1, 2, 1 })).containsOnlyOnce(1); assertThat(new AtomicIntegerArray(new int[] { 1, 2, 3, 3 })).containsOnlyOnce(1, 2, 3);
- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual atomic array isnull
.AssertionError
- if the actual AtomicIntegerArray does not contain the given values or contains them more than once.- Since:
- 2.7.0 / 3.7.0
-
containsSequence
public AtomicIntegerArrayAssert containsSequence(int... sequence)
Verifies that the actual atomic array contains the given sequence, without any other values between them.Example:
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 1, 2, 3 }); // assertion will pass assertThat(atomicIntegerArray).containsSequence(1, 2); // assertion will fail assertThat(atomicIntegerArray).containsSequence(1, 3); assertThat(atomicIntegerArray).containsSequence(2, 1);
- Parameters:
sequence
- the sequence of values to look for.- Returns:
- myself assertion object.
- Throws:
AssertionError
- if the actual atomic array isnull
.AssertionError
- if the given array isnull
.AssertionError
- if the actual atomic array does not contain the given sequence.- Since:
- 2.7.0 / 3.7.0
-
containsSubsequence
public AtomicIntegerArrayAssert containsSubsequence(int... subsequence)
Verifies that the actual atomic array contains the given subsequence (possibly with other values between them).Example:
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 1, 2, 3 }); // assertions will pass assertThat(atomicIntegerArray).containsSubsequence(1, 2) .containsSubsequence(1, 3); // assertion will fail assertThat(atomicIntegerArray).containsSubsequence(2, 1);
- Parameters:
subsequence
- the subsequence of values to look for.- Returns:
- myself assertion object.
- Throws:
AssertionError
- if the actual atomic array isnull
.AssertionError
- if the given array isnull
.AssertionError
- if the actual atomic array does not contain the given subsequence.- Since:
- 2.7.0 / 3.7.0
-
contains
public AtomicIntegerArrayAssert contains(int value, Index index)
Verifies that the actual atomic array contains the given value at the given index.Example:
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 1, 2, 3 }); // assertions will pass assertThat(atomicIntegerArray).contains(1, atIndex(O)) .contains(3, atIndex(2)); // assertions will fail assertThat(atomicIntegerArray).contains(1, atIndex(1)); assertThat(atomicIntegerArray).contains(4, atIndex(2));
- Parameters:
value
- the value to look for.index
- the index where the value should be stored in the actual atomic array.- Returns:
- myself assertion object.
- Throws:
AssertionError
- if the actual atomic 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 atomic array.AssertionError
- if the actual atomic array does not contain the given value at the given index.- Since:
- 2.7.0 / 3.7.0
-
doesNotContain
public AtomicIntegerArrayAssert doesNotContain(int... values)
Verifies that the actual atomic array does not contain the given values.Example:
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 1, 2, 3 }); // assertion will pass assertThat(atomicIntegerArray).doesNotContain(4); // assertion will fail assertThat(atomicIntegerArray).doesNotContain(2);
- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual atomic array isnull
.AssertionError
- if the actual atomic array contains any of the given values.- Since:
- 2.7.0 / 3.7.0
-
doesNotContain
public AtomicIntegerArrayAssert doesNotContain(int value, Index index)
Verifies that the actual atomic array does not contain the given value at the given index.Example:
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 1, 2, 3 }); // assertions will pass assertThat(atomicIntegerArray).doesNotContain(1, atIndex(1)) .doesNotContain(2, atIndex(0)); // assertions will fail assertThat(atomicIntegerArray).doesNotContain(1, atIndex(0)); assertThat(atomicIntegerArray).doesNotContain(2, atIndex(1));
- Parameters:
value
- the value to look for.index
- the index where the value should be stored in the actual atomic array.- Returns:
- myself assertion object.
- Throws:
AssertionError
- if the actual atomic array isnull
.NullPointerException
- if the givenIndex
isnull
.AssertionError
- if the actual atomic array contains the given value at the given index.- Since:
- 2.7.0 / 3.7.0
-
doesNotHaveDuplicates
public AtomicIntegerArrayAssert doesNotHaveDuplicates()
Verifies that the actual atomic array does not contain duplicates.Example:
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 1, 2, 3 }); // assertion will pass assertThat(atomicIntegerArray).doesNotHaveDuplicates(); // assertion will fail assertThat(new AtomicIntegerArray(new int[] { 1, 1, 2, 3 })).doesNotHaveDuplicates();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual atomic array isnull
.AssertionError
- if the actual atomic array contains duplicates.- Since:
- 2.7.0 / 3.7.0
-
startsWith
public AtomicIntegerArrayAssert startsWith(int... sequence)
Verifies that the actual atomic array starts with the given sequence of values, without any other values between them. Similar to
, but it also verifies that the first element in the sequence is also first element of the actual atomic array.containsSequence(int...)
Example:
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 1, 2, 3 }); // assertion will pass assertThat(atomicIntegerArray).startsWith(1, 2); // assertion will fail assertThat(atomicIntegerArray).startsWith(2, 3);
- Parameters:
sequence
- the sequence of values to look for.- Returns:
- myself assertion object.
- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual atomic array isnull
.AssertionError
- if the actual atomic array does not start with the given sequence.- Since:
- 2.7.0 / 3.7.0
-
endsWith
public AtomicIntegerArrayAssert endsWith(int... sequence)
Verifies that the actual atomic array ends with the given sequence of values, without any other values between them. Similar to
, but it also verifies that the last element in the sequence is also last element of the actual atomic array.containsSequence(int...)
Example:
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 1, 2, 3 }); // assertion will pass assertThat(atomicIntegerArray).endsWith(2, 3); // assertion will fail assertThat(atomicIntegerArray).endsWith(3, 4);
- Parameters:
sequence
- the sequence of values to look for.- Returns:
- myself assertion object.
- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual atomic array isnull
.AssertionError
- if the actual atomic array does not end with the given sequence.- Since:
- 2.7.0 / 3.7.0
-
isSorted
public AtomicIntegerArrayAssert isSorted()
Verifies that the actual AtomicIntegerArray is sorted in ascending order according to the natural ordering of its elements.Empty or one element arrays are considered sorted (unless the array element type is not Comparable).
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual AtomicIntegerArray is not sorted in ascending order according to the natural ordering of its elements.AssertionError
- if the actual AtomicIntegerArray isnull
.
-
isSortedAccordingTo
public AtomicIntegerArrayAssert isSortedAccordingTo(Comparator<? super Integer> comparator)
Verifies that the actual AtomicIntegerArray 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
- theComparator
used to compare array elements- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual AtomicIntegerArray is not sorted according to the given comparator.AssertionError
- if the actual AtomicIntegerArray isnull
.NullPointerException
- if the given comparator isnull
.
-
usingElementComparator
public AtomicIntegerArrayAssert usingElementComparator(Comparator<? super Integer> customComparator)
Use given custom comparator instead of relying on Integerequals
method to compare elements for incoming assertion checks.Custom comparator is bound to the current assertion instance, meaning that if a new assertion is created, it will use default comparison strategy.
Examples :
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 1, 2, 3 }); // absolute value comparator Comparator<Integer> absComparator = ...; assertThat(invoiceList).usingComparator(absComparator).contains(-1, -2, 3);
- Parameters:
customComparator
- the comparator to use for incoming assertion checks.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given comparator isnull
.
-
usingDefaultElementComparator
public AtomicIntegerArrayAssert 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
EnumerableAssert.usingElementComparator(Comparator)
.- Returns:
this
assertion object.
-
containsExactly
public AtomicIntegerArrayAssert containsExactly(int... values)
Verifies that the actual AtomicIntegerArray contains only the given values and nothing else, in order.Example :
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[] { 1, 2, 3 }); // assertion will pass assertThat(atomicIntegerArray).containsExactly(1, 2, 3); // assertion will fail as actual and expected order differ assertThat(atomicIntegerArray).containsExactly(2, 1, 3);
- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.AssertionError
- if the actual AtomicIntegerArray isnull
.AssertionError
- if the actual AtomicIntegerArray does not contain the given values with same order, i.e. it contains some or none of the given values, or more values than the given ones or values are the same but the order is not.- Since:
- 2.7.0 / 3.7.0
-
containsExactlyInAnyOrder
public AtomicIntegerArrayAssert containsExactlyInAnyOrder(int... values)
Verifies that the actual AtomicIntegerArray contains exactly the given values and nothing else, in any order.
Example :
// assertions will pass assertThat(new AtomicIntegerArray(new int[] { 1, 2 })).containsExactlyInAnyOrder(1, 2); assertThat(new AtomicIntegerArray(new int[] { 1, 2, 1 })).containsExactlyInAnyOrder(1, 1, 2); // assertions will fail assertThat(new AtomicIntegerArray(new int[] { 1, 2 })).containsExactlyInAnyOrder(1); assertThat(new AtomicIntegerArray(new int[] { 1 })).containsExactlyInAnyOrder(1, 2); assertThat(new AtomicIntegerArray(new int[] { 1, 2, 1 })).containsExactlyInAnyOrder(1, 2);
- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.AssertionError
- if the actual AtomicIntegerArray isnull
.AssertionError
- if the actual AtomicIntegerArray does not contain the given values, i.e. it contains some or none of the given values, or more values than the given ones.- Since:
- 2.7.0 / 3.7.0
-
containsAnyOf
public AtomicIntegerArrayAssert containsAnyOf(int... values)
Verifies that the actual array contains at least one of the given values.Example :
AtomicIntegerArray oneTwoThree = new AtomicIntegerArray(new int[] { 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
- the values whose at least one which is expected to be in the array under test.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the array of values isnull
.IllegalArgumentException
- if the array of values is empty and the array under test is not empty.AssertionError
- if the array under test isnull
.AssertionError
- if the array under test does not contain any of the givenvalues
.- Since:
- 2.9.0 / 3.9.0
-
-