Package org.assertj.core.internal
Class ObjectArrays
- java.lang.Object
-
- org.assertj.core.internal.ObjectArrays
-
public class ObjectArrays extends Object
Reusable assertions for arrays of objects.- Author:
- Alex Ruiz, Joel Costigliola, Nicolas François, Mikhail Mazursky
-
-
Field Summary
Fields Modifier and Type Field Description private Arraysarrays(package private) Conditionsconditions(package private) Failuresfailuresprivate static ObjectArraysINSTANCE
-
Constructor Summary
Constructors Constructor Description ObjectArrays()ObjectArrays(ComparisonStrategy comparisonStrategy)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <E> voidassertAre(AssertionInfo info, E[] actual, Condition<? super E> condition)Assert that each element of given array satisfies the given condition.<E> voidassertAreAtLeast(AssertionInfo info, E[] actual, int n, Condition<? super E> condition)Assert that there are at least n array elements satisfying the given condition.<E> voidassertAreAtMost(AssertionInfo info, E[] actual, int n, Condition<? super E> condition)Assert that there are at most n array elements satisfying the given condition.<E> voidassertAreExactly(AssertionInfo info, E[] actual, int n, Condition<? super E> condition)Verifies that there are exactly n array elements satisfying the given condition.<E> voidassertAreNot(AssertionInfo info, E[] actual, Condition<? super E> condition)Assert that each element of given array not satisfies the given condition.voidassertContains(AssertionInfo info, Object[] actual, Object[] values)Asserts that the given array contains the given values, in any order.voidassertContains(AssertionInfo info, Object[] actual, Object value, Index index)Verifies that the given array contains the given object at the given index.<E> voidassertContainsAll(AssertionInfo info, E[] actual, Iterable<? extends E> other)Asserts that the given array contains all the elements of the givenIterable, in any order.voidassertContainsAnyOf(AssertionInfo info, Object[] actual, Object[] values)voidassertContainsExactly(AssertionInfo info, Object[] actual, Object[] values)voidassertContainsExactlyInAnyOrder(AssertionInfo info, Object[] actual, Object[] values)voidassertContainsNull(AssertionInfo info, Object[] actual)Asserts that the given array contains at least a null element.voidassertContainsOnly(AssertionInfo info, Object[] actual, Object[] values)Asserts that the given array contains only the given values and nothing else, in any order.voidassertContainsOnlyNulls(AssertionInfo info, Object[] actual)Asserts that the given array contains only null elements.voidassertContainsOnlyOnce(AssertionInfo info, Object[] actual, Object[] values)Asserts that the given array contains only once the given values.voidassertContainsSequence(AssertionInfo info, Object[] actual, Object[] sequence)Verifies that the given array contains the given sequence of objects, without any other objects between them.voidassertContainsSubsequence(AssertionInfo info, Object[] actual, Object[] subsequence)Verifies that the given array contains the given subsequence of objects (possibly with other values between them).voidassertDoesNotContain(AssertionInfo info, Object[] actual, Object[] values)Asserts that the given array does not contain the given values.voidassertDoesNotContain(AssertionInfo info, Object[] actual, Object value, Index index)Verifies that the given array does not contain the given object at the given index.<T> voidassertDoesNotContainAnyElementsOf(AssertionInfo info, Object[] actual, Iterable<? extends T> iterable)voidassertDoesNotContainNull(AssertionInfo info, Object[] actual)Asserts that the given array does not contain null elements.voidassertDoesNotContainSequence(AssertionInfo info, Object[] actual, Object[] sequence)Verifies that the given array does not contain the given sequence of objects in order.voidassertDoesNotContainSubsequence(AssertionInfo info, Object[] actual, Object[] subsequence)Verifies that the given array does not contain the given subsequence of objects (possibly with other values between them).<E> voidassertDoesNotHaveAnyElementsOfTypes(AssertionInfo info, E[] actual, Class<?>... unexpectedTypes)voidassertDoesNotHaveDuplicates(AssertionInfo info, Object[] actual)Asserts that the given array does not have duplicate values.<E> voidassertDoNotHave(AssertionInfo info, E[] actual, Condition<? super E> condition)Assert that each element of given array not satisfies the given condition.voidassertEmpty(AssertionInfo info, Object[] actual)Asserts that the given array is empty.voidassertEndsWith(AssertionInfo info, Object[] actual, Object[] sequence)Verifies that the given array ends with the given sequence of objects, without any other objects between them.voidassertEndsWith(AssertionInfo info, Object[] actual, Object first, Object[] rest)Verifies that the given array ends with the given sequence of objects, without any other objects between them.<E> voidassertHasAtLeastOneElementOfType(AssertionInfo info, E[] actual, Class<?> type)<E> voidassertHasOnlyElementsOfType(AssertionInfo info, E[] actual, Class<?> type)<E> voidassertHasOnlyElementsOfTypes(AssertionInfo info, E[] actual, Class<?>... types)voidassertHasSameSizeAs(AssertionInfo info, Object[] actual, Iterable<?> other)Assert that the actual array has the same size as the otherIterable.voidassertHasSameSizeAs(AssertionInfo info, Object[] actual, Object other)Assert that the actual array has the same size as the other array.voidassertHasSize(AssertionInfo info, Object[] actual, int expectedSize)Asserts that the number of elements in the given array is equal to the expected one.voidassertHasSizeBetween(AssertionInfo info, Object[] actual, int lowerBoundary, int higherBoundary)Asserts that the number of elements in the given array is between the given lower and higher boundary (inclusive).voidassertHasSizeGreaterThan(AssertionInfo info, Object[] actual, int boundary)Asserts that the number of elements in the given array is greater than the given boundary.voidassertHasSizeGreaterThanOrEqualTo(AssertionInfo info, Object[] actual, int boundary)Asserts that the number of elements in the given array is greater than or equal to the given boundary.voidassertHasSizeLessThan(AssertionInfo info, Object[] actual, int boundary)Asserts that the number of elements in the given array is less than the given boundary.voidassertHasSizeLessThanOrEqualTo(AssertionInfo info, Object[] actual, int boundary)Asserts that the number of elements in the given array is less than or equal to the given boundary.<E> voidassertHave(AssertionInfo info, E[] actual, Condition<? super E> condition)Assert that each element of given array satisfies the given condition.<E> voidassertHaveAtLeast(AssertionInfo info, E[] actual, int times, Condition<? super E> condition)An alias method ofassertAreAtLeast(AssertionInfo, Object[], int, Condition)to provide a richer fluent api (same logic, only error message differs).<E> voidassertHaveAtMost(AssertionInfo info, E[] actual, int times, Condition<? super E> condition)An alias method ofassertAreAtMost(AssertionInfo, Object[], int, Condition)to provide a richer fluent api (same logic, only error message differs).<E> voidassertHaveExactly(AssertionInfo info, E[] actual, int times, Condition<? super E> condition)An alias method ofassertAreExactly(AssertionInfo, Object[], int, Condition)to provide a richer fluent api (same logic, only error message differs).voidassertIsSorted(AssertionInfo info, Object[] actual)Concrete implementation ofArraySortedAssert.isSorted().<E> voidassertIsSortedAccordingToComparator(AssertionInfo info, E[] actual, Comparator<? super E> comparator)Concrete implementation ofArraySortedAssert.isSortedAccordingTo(Comparator).voidassertIsSubsetOf(AssertionInfo info, Object actual, Iterable<?> values)voidassertNotEmpty(AssertionInfo info, Object[] actual)Asserts that the given array is not empty.voidassertNullOrEmpty(AssertionInfo info, Object[] actual)Asserts that the given array isnullor empty.voidassertStartsWith(AssertionInfo info, Object[] actual, Object[] sequence)Verifies that the given array starts with the given sequence of objects, without any other objects between them.Comparator<?>getComparator()ComparisonStrategygetComparisonStrategy()static ObjectArraysinstance()Returns the singleton instance of this class.(package private) voidsetArrays(Arrays arrays)
-
-
-
Field Detail
-
INSTANCE
private static final ObjectArrays INSTANCE
-
arrays
private Arrays arrays
-
failures
Failures failures
-
conditions
Conditions conditions
-
-
Constructor Detail
-
ObjectArrays
ObjectArrays()
-
ObjectArrays
public ObjectArrays(ComparisonStrategy comparisonStrategy)
-
-
Method Detail
-
instance
public static ObjectArrays instance()
Returns the singleton instance of this class.- Returns:
- the singleton instance of this class.
-
setArrays
void setArrays(Arrays arrays)
-
getComparator
public Comparator<?> getComparator()
-
getComparisonStrategy
public ComparisonStrategy getComparisonStrategy()
-
assertNullOrEmpty
public void assertNullOrEmpty(AssertionInfo info, Object[] actual)
Asserts that the given array isnullor empty.- Parameters:
info- contains information about the assertion.actual- the given array.- Throws:
AssertionError- if the given array is notnull*and* contains one or more elements.
-
assertEmpty
public void assertEmpty(AssertionInfo info, Object[] actual)
Asserts that the given array is empty.- Parameters:
info- contains information about the assertion.actual- the given array.- Throws:
AssertionError- if the given array isnull.AssertionError- if the given array is not empty.
-
assertNotEmpty
public void assertNotEmpty(AssertionInfo info, Object[] actual)
Asserts that the given array is not empty.- Parameters:
info- contains information about the assertion.actual- the given array.- Throws:
AssertionError- if the given array isnull.AssertionError- if the given array is empty.
-
assertHasSize
public void assertHasSize(AssertionInfo info, Object[] actual, int expectedSize)
Asserts that the number of elements in the given array is equal to the expected one.- Parameters:
info- contains information about the assertion.actual- the given array.expectedSize- the expected size ofactual.- Throws:
AssertionError- if the given array isnull.AssertionError- if the number of elements in the given array is different than the expected one.
-
assertHasSizeGreaterThan
public void assertHasSizeGreaterThan(AssertionInfo info, Object[] actual, int boundary)
Asserts that the number of elements in the given array is greater than the given boundary.- Parameters:
info- contains information about the assertion.actual- the given array.boundary- the given value to compare the size ofactualto.- Throws:
AssertionError- if the given array isnull.AssertionError- if the number of elements in the given array is not greater than the boundary.
-
assertHasSizeGreaterThanOrEqualTo
public void assertHasSizeGreaterThanOrEqualTo(AssertionInfo info, Object[] actual, int boundary)
Asserts that the number of elements in the given array is greater than or equal to the given boundary.- Parameters:
info- contains information about the assertion.actual- the given array.boundary- the given value to compare the size ofactualto.- Throws:
AssertionError- if the given array isnull.AssertionError- if the number of elements in the given array is not greater than or equal to the boundary.
-
assertHasSizeLessThan
public void assertHasSizeLessThan(AssertionInfo info, Object[] actual, int boundary)
Asserts that the number of elements in the given array is less than the given boundary.- Parameters:
info- contains information about the assertion.actual- the given array.boundary- the given value to compare the size ofactualto.- Throws:
AssertionError- if the given array isnull.AssertionError- if the number of elements in the given array is not less than the boundary.
-
assertHasSizeLessThanOrEqualTo
public void assertHasSizeLessThanOrEqualTo(AssertionInfo info, Object[] actual, int boundary)
Asserts that the number of elements in the given array is less than or equal to the given boundary.- Parameters:
info- contains information about the assertion.actual- the given array.boundary- the given value to compare the size ofactualto.- Throws:
AssertionError- if the given array isnull.AssertionError- if the number of elements in the given array is not less than or equal to the boundary.
-
assertHasSizeBetween
public void assertHasSizeBetween(AssertionInfo info, Object[] actual, int lowerBoundary, int higherBoundary)
Asserts that the number of elements in the given array is between the given lower and higher boundary (inclusive).- Parameters:
info- contains information about the assertion.actual- the given array.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.- Throws:
AssertionError- if the given array isnull.AssertionError- if the number of elements in the given array is not between the boundaries.
-
assertHasSameSizeAs
public void assertHasSameSizeAs(AssertionInfo info, Object[] actual, Iterable<?> other)
Assert that the actual array has the same size as the otherIterable.- Parameters:
info- contains information about the assertion.actual- the given iterable.other- the group to compare- Throws:
AssertionError- if the actual group isnull.AssertionError- if the other group isnull.AssertionError- if the actual group does not have the same size.
-
assertHasSameSizeAs
public void assertHasSameSizeAs(AssertionInfo info, Object[] actual, Object other)
Assert that the actual array has the same size as the other array.- Parameters:
info- contains information about the assertion.actual- the given array.other- the group to compare- Throws:
AssertionError- if the actual group isnull.AssertionError- if the other group isnull.AssertionError- if the actual group does not have the same size.
-
assertContains
public void assertContains(AssertionInfo info, Object[] actual, Object[] values)
Asserts that the given array contains the given values, in any order.- Parameters:
info- contains information about the assertion.actual- the given array.values- the values that are expected to be in the given array.- Throws:
NullPointerException- if the array of values isnull.IllegalArgumentException- if the array of values is empty.AssertionError- if the given array isnull.AssertionError- if the given array does not contain the given values.
-
assertContains
public void assertContains(AssertionInfo info, Object[] actual, Object value, Index index)
Verifies that the given array contains the given object at the given index.- Parameters:
info- contains information about the assertion.actual- the given array.value- the object to look for.index- the index where the object should be stored in the given array.- Throws:
AssertionError- if the given array isnullor empty.NullPointerException- if the givenIndexisnull.IndexOutOfBoundsException- if the value of the givenIndexis equal to or greater than the size of the given array.AssertionError- if the given array does not contain the given object at the given index.
-
assertDoesNotContain
public void assertDoesNotContain(AssertionInfo info, Object[] actual, Object value, Index index)
Verifies that the given array does not contain the given object at the given index.- Parameters:
info- contains information about the assertion.actual- the given array.value- the object to look for.index- the index where the object should be stored in the given array.- Throws:
AssertionError- if the given array isnull.NullPointerException- if the givenIndexisnull.AssertionError- if the given array contains the given object at the given index.
-
assertContainsOnly
public void assertContainsOnly(AssertionInfo info, Object[] actual, Object[] values)
Asserts that the given array contains only the given values and nothing else, in any order.- Parameters:
info- contains information about the assertion.actual- the given array.values- the values that are expected to be in the given array.- Throws:
NullPointerException- if the array of values isnull.IllegalArgumentException- if the array of values is empty.AssertionError- if the given array isnull.AssertionError- if the given array does not contain the given values or if the given array contains values that are not in the given array.
-
assertContainsExactly
public void assertContainsExactly(AssertionInfo info, Object[] actual, Object[] values)
-
assertContainsExactlyInAnyOrder
public void assertContainsExactlyInAnyOrder(AssertionInfo info, Object[] actual, Object[] values)
-
assertContainsOnlyOnce
public void assertContainsOnlyOnce(AssertionInfo info, Object[] actual, Object[] values)
Asserts that the given array contains only once the given values.- Parameters:
info- contains information about the assertion.actual- the given array.values- the values that are expected to be in the given array.- Throws:
NullPointerException- if the array of values isnull.IllegalArgumentException- if the array of values is empty.AssertionError- if the given array isnull.AssertionError- if the given array does not contain the given values or if the given array contains values that are not in the given array.
-
assertContainsOnlyNulls
public void assertContainsOnlyNulls(AssertionInfo info, Object[] actual)
Asserts that the given array contains only null elements.- Parameters:
info- contains information about the assertionactual- the given array- Throws:
AssertionError- if the given array isnull.AssertionError- if the given array does not contain at least a null element or contains values that are not null elements.
-
assertContainsSequence
public void assertContainsSequence(AssertionInfo info, Object[] actual, Object[] sequence)
Verifies that the given array contains the given sequence of objects, without any other objects between them.- Parameters:
info- contains information about the assertion.actual- the given array.sequence- the sequence of objects to look for.- Throws:
AssertionError- if the given array isnull.NullPointerException- if the given sequence isnull.IllegalArgumentException- if the given sequence is empty.AssertionError- if the given array does not contain the given sequence of objects.
-
assertDoesNotContainSequence
public void assertDoesNotContainSequence(AssertionInfo info, Object[] actual, Object[] sequence)
Verifies that the given array does not contain the given sequence of objects in order.- Parameters:
info- contains information about the assertion.actual- the given array.sequence- the sequence of objects to look for.- Throws:
AssertionError- if the given array isnull.NullPointerException- if the given sequence isnull.IllegalArgumentException- if the given sequence is empty.AssertionError- if the given array does contain the given sequence of objects in order.
-
assertContainsSubsequence
public void assertContainsSubsequence(AssertionInfo info, Object[] actual, Object[] subsequence)
Verifies that the given array contains the given subsequence of objects (possibly with other values between them).- Parameters:
info- contains information about the assertion.actual- the given array.subsequence- the subsequence of objects to look for.- Throws:
AssertionError- if the given array isnull.NullPointerException- if the given subsequence isnull.IllegalArgumentException- if the given subsequence is empty.AssertionError- if the given array does not contain the given subsequence of objects.
-
assertDoesNotContainSubsequence
public void assertDoesNotContainSubsequence(AssertionInfo info, Object[] actual, Object[] subsequence)
Verifies that the given array does not contain the given subsequence of objects (possibly with other values between them).- Parameters:
info- contains information about the assertion.actual- the given array.subsequence- the subsequence of objects to look for.- Throws:
AssertionError- if the given array isnull.NullPointerException- if the given subsequence isnull.IllegalArgumentException- if the given subsequence is empty.AssertionError- if the given array contains the given subsequence of objects.
-
assertDoesNotContain
public void assertDoesNotContain(AssertionInfo info, Object[] actual, Object[] values)
Asserts that the given array does not contain the given values.- Parameters:
info- contains information about the assertion.actual- the given array.values- the values that are expected not to be in the given array.- Throws:
NullPointerException- if the array of values isnull.IllegalArgumentException- if the array of values is empty.AssertionError- if the given array isnull.AssertionError- if the given array contains any of given values.
-
assertDoesNotContainAnyElementsOf
public <T> void assertDoesNotContainAnyElementsOf(AssertionInfo info, Object[] actual, Iterable<? extends T> iterable)
-
assertDoesNotHaveDuplicates
public void assertDoesNotHaveDuplicates(AssertionInfo info, Object[] actual)
Asserts that the given array does not have duplicate values.- Parameters:
info- contains information about the assertion.actual- the given array.- Throws:
NullPointerException- if the array of values isnull.IllegalArgumentException- if the array of values is empty.AssertionError- if the given array isnull.AssertionError- if the given array contains duplicate values.
-
assertStartsWith
public void assertStartsWith(AssertionInfo info, Object[] actual, Object[] sequence)
Verifies that the given array starts with the given sequence of objects, without any other objects between them. Similar to, but it also verifies that the first element in the sequence is also the first element of the given array.assertContainsSequence(AssertionInfo, Object[], Object[])- Parameters:
info- contains information about the assertion.actual- the given array.sequence- the sequence of objects to look for.- Throws:
NullPointerException- if the given argument isnull.IllegalArgumentException- if the given argument is an empty array.AssertionError- if the given array isnull.AssertionError- if the given array does not start with the given sequence of objects.
-
assertEndsWith
public void assertEndsWith(AssertionInfo info, Object[] actual, Object first, Object[] rest)
Verifies that the given array ends with the given sequence of objects, without any other objects between them. Similar to, but it also verifies that the last element in the sequence is also the last element of the given array.assertContainsSequence(AssertionInfo, Object[], Object[])- Parameters:
info- contains information about the assertion.actual- the given array.first- the first element of the end sequence of objects to look for.rest- the rest of the end sequence of objects to look for.- Throws:
NullPointerException- if the given argument isnull.AssertionError- if the given array isnull.AssertionError- if the given array does not end with the given sequence of objects.
-
assertEndsWith
public void assertEndsWith(AssertionInfo info, Object[] actual, Object[] sequence)
Verifies that the given array ends with the given sequence of objects, without any other objects between them. Similar to, but it also verifies that the last element in the sequence is also the last element of the given array.assertContainsSequence(AssertionInfo, Object[], Object[])- Parameters:
info- contains information about the assertion.actual- the given array.sequence- the sequence of objects to look for.- Throws:
NullPointerException- if the given argument isnull.AssertionError- if the given array isnull.AssertionError- if the given array does not end with the given sequence of objects.
-
assertIsSubsetOf
public void assertIsSubsetOf(AssertionInfo info, Object actual, Iterable<?> values)
-
assertContainsNull
public void assertContainsNull(AssertionInfo info, Object[] actual)
Asserts that the given array contains at least a null element.- Parameters:
info- contains information about the assertion.actual- the given array.- Throws:
AssertionError- if the given array isnull.AssertionError- if the given array does not contain a null element.
-
assertDoesNotContainNull
public void assertDoesNotContainNull(AssertionInfo info, Object[] actual)
Asserts that the given array does not contain null elements.- Parameters:
info- contains information about the assertion.actual- the given array.- Throws:
AssertionError- if the given array isnull.AssertionError- if the given array contains a null element.
-
assertAre
public <E> void assertAre(AssertionInfo info, E[] actual, Condition<? super E> condition)
Assert that each element of given array satisfies the given condition.- Type Parameters:
E- element type- Parameters:
info- contains information about the assertion.actual- the given array.condition- the givenCondition.- Throws:
NullPointerException- if the given condition isnull.AssertionError- if one or more elements do not satisfy the given condition.
-
assertAreNot
public <E> void assertAreNot(AssertionInfo info, E[] actual, Condition<? super E> condition)
Assert that each element of given array not satisfies the given condition.- Type Parameters:
E- element type- Parameters:
info- contains information about the assertion.actual- the given array.condition- the givenCondition.- Throws:
NullPointerException- if the given condition isnull.AssertionError- if one or more elements satisfy the given condition.
-
assertHave
public <E> void assertHave(AssertionInfo info, E[] actual, Condition<? super E> condition)
Assert that each element of given array satisfies the given condition.- Type Parameters:
E- element type- Parameters:
info- contains information about the assertion.actual- the given array.condition- the givenCondition.- Throws:
NullPointerException- if the given condition isnull.AssertionError- if one or more elements do not satisfy the given condition.
-
assertDoNotHave
public <E> void assertDoNotHave(AssertionInfo info, E[] actual, Condition<? super E> condition)
Assert that each element of given array not satisfies the given condition.- Type Parameters:
E- element type- Parameters:
info- contains information about the assertion.actual- the given array.condition- the givenCondition.- Throws:
NullPointerException- if the given condition isnull.AssertionError- if one or more elements satisfy the given condition.
-
assertAreAtLeast
public <E> void assertAreAtLeast(AssertionInfo info, E[] actual, int n, Condition<? super E> condition)
Assert that there are at least n array elements satisfying the given condition.- Type Parameters:
E- element type- Parameters:
info- contains information about the assertion.actual- the given array.n- the minimum number of times the condition should be verified.condition- the givenCondition.- Throws:
NullPointerException- if the given condition isnull.AssertionError- if the number of elements satisfying the given condition is < n.
-
assertAreAtMost
public <E> void assertAreAtMost(AssertionInfo info, E[] actual, int n, Condition<? super E> condition)
Assert that there are at most n array elements satisfying the given condition.- Type Parameters:
E- element type- Parameters:
info- contains information about the assertion.actual- the given array.n- the number of times the condition should be at most verified.condition- the givenCondition.- Throws:
NullPointerException- if the given condition isnull.AssertionError- if the number of elements satisfying the given condition is > n.
-
assertAreExactly
public <E> void assertAreExactly(AssertionInfo info, E[] actual, int n, Condition<? super E> condition)
Verifies that there are exactly n array elements satisfying the given condition.- Type Parameters:
E- element type- Parameters:
info- contains information about the assertion.actual- the given array.n- the exact number of times the condition should be verified.condition- the givenCondition.- Throws:
NullPointerException- if the given condition isnull.AssertionError- if the number of elements satisfying the given condition is ≠ n.
-
assertHaveAtLeast
public <E> void assertHaveAtLeast(AssertionInfo info, E[] actual, int times, Condition<? super E> condition)
An alias method ofassertAreAtLeast(AssertionInfo, Object[], int, Condition)to provide a richer fluent api (same logic, only error message differs).- Type Parameters:
E- element type- Parameters:
info- contains information about the assertion.actual- the given array.times- the minimum number of times the condition should be verified.condition- the givenCondition.- Throws:
NullPointerException- if the given condition isnull.AssertionError- if the number of elements satisfying the given condition is < n.
-
assertHaveAtMost
public <E> void assertHaveAtMost(AssertionInfo info, E[] actual, int times, Condition<? super E> condition)
An alias method ofassertAreAtMost(AssertionInfo, Object[], int, Condition)to provide a richer fluent api (same logic, only error message differs).- Type Parameters:
E- element type- Parameters:
info- contains information about the assertion.actual- the given array.times- the number of times the condition should be at most verified.condition- the givenCondition.- Throws:
NullPointerException- if the given condition isnull.AssertionError- if the number of elements satisfying the given condition is > n.
-
assertHaveExactly
public <E> void assertHaveExactly(AssertionInfo info, E[] actual, int times, Condition<? super E> condition)
An alias method ofassertAreExactly(AssertionInfo, Object[], int, Condition)to provide a richer fluent api (same logic, only error message differs).- Type Parameters:
E- element type- Parameters:
info- contains information about the assertion.actual- the given array.times- the exact number of times the condition should be verified.condition- the givenCondition.- Throws:
NullPointerException- if the given condition isnull.AssertionError- if the number of elements satisfying the given condition is ≠ n.
-
assertHasAtLeastOneElementOfType
public <E> void assertHasAtLeastOneElementOfType(AssertionInfo info, E[] actual, Class<?> type)
-
assertHasOnlyElementsOfType
public <E> void assertHasOnlyElementsOfType(AssertionInfo info, E[] actual, Class<?> type)
-
assertHasOnlyElementsOfTypes
public <E> void assertHasOnlyElementsOfTypes(AssertionInfo info, E[] actual, Class<?>... types)
-
assertDoesNotHaveAnyElementsOfTypes
public <E> void assertDoesNotHaveAnyElementsOfTypes(AssertionInfo info, E[] actual, Class<?>... unexpectedTypes)
-
assertIsSorted
public void assertIsSorted(AssertionInfo info, Object[] actual)
Concrete implementation ofArraySortedAssert.isSorted().- Parameters:
info- contains information about the assertion.actual- the given array.
-
assertIsSortedAccordingToComparator
public <E> void assertIsSortedAccordingToComparator(AssertionInfo info, E[] actual, Comparator<? super E> comparator)
Concrete implementation ofArraySortedAssert.isSortedAccordingTo(Comparator).- Type Parameters:
E- element type- Parameters:
info- contains information about the assertion.actual- the given array.comparator- theComparatorused to compare array elements
-
assertContainsAll
public <E> void assertContainsAll(AssertionInfo info, E[] actual, Iterable<? extends E> other)
Asserts that the given array contains all the elements of the givenIterable, in any order.- Type Parameters:
E- element type- Parameters:
info- contains information about the assertion.actual- the given array.other- the otherIterable.- Throws:
NullPointerException- ifIterableisnull.AssertionError- if the givenIterableisnull.AssertionError- if the givenIterabledoes not contain all the elements of the otherIterable, in any order.
-
assertContainsAnyOf
public void assertContainsAnyOf(AssertionInfo info, Object[] actual, Object[] values)
-
-