Package org.fest.assertions.internal
Class ObjectArrays
- java.lang.Object
-
- org.fest.assertions.internal.ObjectArrays
-
public class ObjectArrays extends java.lang.ObjectReusable assertions for arrays of objects.- Author:
- Alex Ruiz, Joel Costigliola, Nicolas François, Mikhail Mazursky
-
-
Constructor Summary
Constructors Constructor Description 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 is at least n array elements satisfying the given condition.<E> voidassertAreAtMost(AssertionInfo info, E[] actual, int n, Condition<? super E> condition)Assert that there is at most n array elements satisfying the given condition.<E> voidassertAreExactly(AssertionInfo info, E[] actual, int n, Condition<? super E> condition)Verifies that there is 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.<E> voidassertAreNotAtLeast(AssertionInfo info, E[] actual, int n, Condition<? super E> condition)Assert that there is at least n array elements not satisfying the given condition.<E> voidassertAreNotAtMost(AssertionInfo info, E[] actual, int n, Condition<? super E> condition)Verifies that there is at most n array elements not satisfying the given condition.<E> voidassertAreNotExactly(AssertionInfo info, E[] actual, int n, Condition<? super E> condition)Verifies that there is exactly n elements in the actualIterablenot satisfying the given condition.voidassertContains(AssertionInfo info, java.lang.Object[] actual, java.lang.Object[] values)Asserts that the given array contains the given values, in any order.voidassertContains(AssertionInfo info, java.lang.Object[] actual, java.lang.Object value, Index index)Verifies that the given array contains the given object at the given index.<E> voidassertContainsAll(AssertionInfo info, E[] actual, java.lang.Iterable<? extends E> other)Asserts that the given array contains all the elements of the givenIterable, in any order.voidassertContainsNull(AssertionInfo info, java.lang.Object[] actual)Asserts that the given array contains at least a null element.voidassertContainsOnly(AssertionInfo info, java.lang.Object[] actual, java.lang.Object[] values)Asserts that the given array contains only the given values and nothing else, in any order.voidassertContainsSequence(AssertionInfo info, java.lang.Object[] actual, java.lang.Object[] sequence)Verifies that the given array contains the given sequence of objects, without any other objects between them.voidassertDoesNotContain(AssertionInfo info, java.lang.Object[] actual, java.lang.Object[] values)Asserts that the given array does not contain the given values.voidassertDoesNotContain(AssertionInfo info, java.lang.Object[] actual, java.lang.Object value, Index index)Verifies that the given array does not contain the given object at the given index.voidassertDoesNotContainNull(AssertionInfo info, java.lang.Object[] actual)Asserts that the given array does not contain null elements.voidassertDoesNotHaveDuplicates(AssertionInfo info, java.lang.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.<E> voidassertDoNotHaveAtLeast(AssertionInfo info, E[] actual, int times, Condition<? super E> condition)An alias method ofassertAreNotAtLeast(AssertionInfo, Object[], int, Condition)to provide a richer fluent api (same logic, only error message differs).<E> voidassertDoNotHaveAtMost(AssertionInfo info, E[] actual, int times, Condition<? super E> condition)An alias method ofassertAreNotAtMost(AssertionInfo, Object[], int, Condition)to provide a richer fluent api (same logic, only error message differs).<E> voidassertDoNotHaveExactly(AssertionInfo info, E[] actual, int times, Condition<? super E> condition)An alias method ofassertAreNotExactly(AssertionInfo, Object[], int, Condition)to provide a richer fluent api (same logic, only error message differs).voidassertEmpty(AssertionInfo info, java.lang.Object[] actual)Asserts that the given array is empty.voidassertEndsWith(AssertionInfo info, java.lang.Object[] actual, java.lang.Object[] sequence)Verifies that the given array ends with the given sequence of objects, without any other objects between them.voidassertHasSameSizeAs(AssertionInfo info, java.lang.Object[] actual, java.lang.Iterable<?> other)Assert that the actual array has the same size as the otherIterable.voidassertHasSameSizeAs(AssertionInfo info, java.lang.Object[] actual, java.lang.Object[] other)Assert that the actual array has the same size as the other array.voidassertHasSize(AssertionInfo info, java.lang.Object[] actual, int expectedSize)Asserts that the number of elements in the given array is equal to the expected one.<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, java.lang.Object[] actual)Concrete implementation ofArraySortedAssert.isSorted().<E> voidassertIsSortedAccordingToComparator(AssertionInfo info, E[] actual, java.util.Comparator<? super E> comparator)Concrete implementation ofArraySortedAssert.isSortedAccordingTo(Comparator).voidassertNotEmpty(AssertionInfo info, java.lang.Object[] actual)Asserts that the given array is not empty.voidassertNullOrEmpty(AssertionInfo info, java.lang.Object[] actual)Asserts that the given array isnullor empty.voidassertStartsWith(AssertionInfo info, java.lang.Object[] actual, java.lang.Object[] sequence)Verifies that the given array starts with the given sequence of objects, without any other objects between them.java.util.Comparator<?>getComparator()static ObjectArraysinstance()Returns the singleton instance of this class.
-
-
-
Constructor Detail
-
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.
-
getComparator
public java.util.Comparator<?> getComparator()
-
assertNullOrEmpty
public void assertNullOrEmpty(AssertionInfo info, java.lang.Object[] actual)
Asserts that the given array isnullor empty.- Parameters:
info- contains information about the assertion.actual- the given array.- Throws:
java.lang.AssertionError- if the given array is notnull*and* contains one or more elements.
-
assertEmpty
public void assertEmpty(AssertionInfo info, java.lang.Object[] actual)
Asserts that the given array is empty.- Parameters:
info- contains information about the assertion.actual- the given array.- Throws:
java.lang.AssertionError- if the given array isnull.java.lang.AssertionError- if the given array is not empty.
-
assertNotEmpty
public void assertNotEmpty(AssertionInfo info, java.lang.Object[] actual)
Asserts that the given array is not empty.- Parameters:
info- contains information about the assertion.actual- the given array.- Throws:
java.lang.AssertionError- if the given array isnull.java.lang.AssertionError- if the given array is empty.
-
assertHasSize
public void assertHasSize(AssertionInfo info, java.lang.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:
java.lang.AssertionError- if the given array isnull.java.lang.AssertionError- if the number of elements in the given array is different than the expected one.
-
assertHasSameSizeAs
public void assertHasSameSizeAs(AssertionInfo info, java.lang.Object[] actual, java.lang.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:
java.lang.AssertionError- if the actual group isnull.java.lang.AssertionError- if the other group isnull.java.lang.AssertionError- if the actual group does not have the same size.
-
assertHasSameSizeAs
public void assertHasSameSizeAs(AssertionInfo info, java.lang.Object[] actual, java.lang.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:
java.lang.AssertionError- if the actual group isnull.java.lang.AssertionError- if the other group isnull.java.lang.AssertionError- if the actual group does not have the same size.
-
assertContains
public void assertContains(AssertionInfo info, java.lang.Object[] actual, java.lang.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:
java.lang.NullPointerException- if the array of values isnull.java.lang.IllegalArgumentException- if the array of values is empty.java.lang.AssertionError- if the given array isnull.java.lang.AssertionError- if the given array does not contain the given values.
-
assertContains
public void assertContains(AssertionInfo info, java.lang.Object[] actual, java.lang.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:
java.lang.AssertionError- if the given array isnullor empty.java.lang.NullPointerException- if the givenIndexisnull.java.lang.IndexOutOfBoundsException- if the value of the givenIndexis equal to or greater than the size of the given array.java.lang.AssertionError- if the given array does not contain the given object at the given index.
-
assertDoesNotContain
public void assertDoesNotContain(AssertionInfo info, java.lang.Object[] actual, java.lang.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:
java.lang.AssertionError- if the given array isnull.java.lang.NullPointerException- if the givenIndexisnull.java.lang.AssertionError- if the given array contains the given object at the given index.
-
assertContainsOnly
public void assertContainsOnly(AssertionInfo info, java.lang.Object[] actual, java.lang.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:
java.lang.NullPointerException- if the array of values isnull.java.lang.IllegalArgumentException- if the array of values is empty.java.lang.AssertionError- if the given array isnull.java.lang.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.
-
assertContainsSequence
public void assertContainsSequence(AssertionInfo info, java.lang.Object[] actual, java.lang.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:
java.lang.AssertionError- if the given array isnull.java.lang.NullPointerException- if the given sequence isnull.java.lang.IllegalArgumentException- if the given sequence is empty.java.lang.AssertionError- if the given array does not contain the given sequence of objects.
-
assertDoesNotContain
public void assertDoesNotContain(AssertionInfo info, java.lang.Object[] actual, java.lang.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:
java.lang.NullPointerException- if the array of values isnull.java.lang.IllegalArgumentException- if the array of values is empty.java.lang.AssertionError- if the given array isnull.java.lang.AssertionError- if the given array contains any of given values.
-
assertDoesNotHaveDuplicates
public void assertDoesNotHaveDuplicates(AssertionInfo info, java.lang.Object[] actual)
Asserts that the given array does not have duplicate values.- Parameters:
info- contains information about the assertion.actual- the given array.- Throws:
java.lang.NullPointerException- if the array of values isnull.java.lang.IllegalArgumentException- if the array of values is empty.java.lang.AssertionError- if the given array isnull.java.lang.AssertionError- if the given array contains duplicate values.
-
assertStartsWith
public void assertStartsWith(AssertionInfo info, java.lang.Object[] actual, java.lang.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:
java.lang.NullPointerException- if the given argument isnull.java.lang.IllegalArgumentException- if the given argument is an empty array.java.lang.AssertionError- if the given array isnull.java.lang.AssertionError- if the given array does not start with the given sequence of objects.
-
assertEndsWith
public void assertEndsWith(AssertionInfo info, java.lang.Object[] actual, java.lang.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:
java.lang.NullPointerException- if the given argument isnull.java.lang.IllegalArgumentException- if the given argument is an empty array.java.lang.AssertionError- if the given array isnull.java.lang.AssertionError- if the given array does not end with the given sequence of objects.
-
assertContainsNull
public void assertContainsNull(AssertionInfo info, java.lang.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:
java.lang.AssertionError- if the given array isnull.java.lang.AssertionError- if the given array does not contain a null element.
-
assertDoesNotContainNull
public void assertDoesNotContainNull(AssertionInfo info, java.lang.Object[] actual)
Asserts that the given array does not contain null elements.- Parameters:
info- contains information about the assertion.actual- the given array.- Throws:
java.lang.AssertionError- if the given array isnull.java.lang.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.- Parameters:
info- contains information about the assertion.actual- the given array.condition- the givenCondition.- Throws:
java.lang.NullPointerException- if the given condition isnull.java.lang.AssertionError- if one or more element 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.- Parameters:
info- contains information about the assertion.actual- the given array.condition- the givenCondition.- Throws:
java.lang.NullPointerException- if the given condition isnull.java.lang.AssertionError- if one or more element 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.- Parameters:
info- contains information about the assertion.actual- the given array.condition- the givenCondition.- Throws:
java.lang.NullPointerException- if the given condition isnull.java.lang.AssertionError- if one or more element 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.- Parameters:
info- contains information about the assertion.actual- the given array.condition- the givenCondition.- Throws:
java.lang.NullPointerException- if the given condition isnull.java.lang.AssertionError- if one or more element satisfy the given condition.
-
assertAreAtLeast
public <E> void assertAreAtLeast(AssertionInfo info, E[] actual, int n, Condition<? super E> condition)
Assert that there is at least n array elements satisfying the given condition.- 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:
java.lang.NullPointerException- if the given condition isnull.java.lang.AssertionError- if the number of elements satisfying the given condition is < n.
-
assertAreNotAtLeast
public <E> void assertAreNotAtLeast(AssertionInfo info, E[] actual, int n, Condition<? super E> condition)
Assert that there is at least n array elements not satisfying the given condition.- Parameters:
info- contains information about the assertion.actual- the given array.n- the number of times the condition should not be verified at least.condition- the givenCondition.- Throws:
java.lang.NullPointerException- if the given condition isnull.java.lang.AssertionError- if the number of elements not satisfying the given condition is < n.
-
assertAreAtMost
public <E> void assertAreAtMost(AssertionInfo info, E[] actual, int n, Condition<? super E> condition)
Assert that there is at most n array elements satisfying the given condition.- 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:
java.lang.NullPointerException- if the given condition isnull.java.lang.AssertionError- if the number of elements satisfying the given condition is > n.
-
assertAreNotAtMost
public <E> void assertAreNotAtMost(AssertionInfo info, E[] actual, int n, Condition<? super E> condition)
Verifies that there is at most n array elements not satisfying the given condition.- Parameters:
info- contains information about the assertion.actual- the given array.n- the number of times the condition should not be verified at most.condition- the givenCondition.- Throws:
java.lang.NullPointerException- if the given condition isnull.java.lang.AssertionError- if the number of elements not satisfying the given condition is > n.
-
assertAreExactly
public <E> void assertAreExactly(AssertionInfo info, E[] actual, int n, Condition<? super E> condition)
Verifies that there is exactly n array elements satisfying the given condition.- 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:
java.lang.NullPointerException- if the given condition isnull.java.lang.AssertionError- if the number of elements satisfying the given condition is ≠ n.
-
assertAreNotExactly
public <E> void assertAreNotExactly(AssertionInfo info, E[] actual, int n, Condition<? super E> condition)
Verifies that there is exactly n elements in the actualIterablenot satisfying the given condition.- Parameters:
info- contains information about the assertion.actual- the given array.n- most times the condition should not be verify.condition- the givenCondition.- Throws:
java.lang.NullPointerException- if the given condition isnull.java.lang.AssertionError- if the number of elements not 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).
-
assertDoNotHaveAtLeast
public <E> void assertDoNotHaveAtLeast(AssertionInfo info, E[] actual, int times, Condition<? super E> condition)
An alias method ofassertAreNotAtLeast(AssertionInfo, Object[], int, Condition)to provide a richer fluent api (same logic, only error message differs).
-
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).
-
assertDoNotHaveAtMost
public <E> void assertDoNotHaveAtMost(AssertionInfo info, E[] actual, int times, Condition<? super E> condition)
An alias method ofassertAreNotAtMost(AssertionInfo, Object[], int, Condition)to provide a richer fluent api (same logic, only error message differs).
-
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).
-
assertDoNotHaveExactly
public <E> void assertDoNotHaveExactly(AssertionInfo info, E[] actual, int times, Condition<? super E> condition)
An alias method ofassertAreNotExactly(AssertionInfo, Object[], int, Condition)to provide a richer fluent api (same logic, only error message differs).
-
assertIsSorted
public void assertIsSorted(AssertionInfo info, java.lang.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, java.util.Comparator<? super E> comparator)
Concrete implementation ofArraySortedAssert.isSortedAccordingTo(Comparator).- 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, java.lang.Iterable<? extends E> other)
Asserts that the given array contains all the elements of the givenIterable, in any order.- Parameters:
info- contains information about the assertion.actual- the given array.other- the otherIterable.- Throws:
java.lang.NullPointerException- ifIterableisnull.java.lang.AssertionError- if the givenIterableisnull.java.lang.AssertionError- if the givenIterabledoes not contain all the elements of the otherIterable, in any order.
-
-