public class IterableSubject extends Subject
Iterable subjects.
 Note:
Iterable more than once. If you have an
       unusual implementation of Iterable which does not support multiple iterations
       (sometimes known as a "one-shot iterable"), you must copy your iterable into a collection
       which does (e.g. ImmutableList.copyOf(iterable) or, if your iterable may contain
       null, newArrayList(iterable)). If you don't, you may see surprising failures.
   Iterable implement
       Object.hashCode() correctly.
 | Modifier and Type | Class and Description | 
|---|---|
static class  | 
IterableSubject.UsingCorrespondence<A,E>
A partially specified check in which the actual elements (normally the elements of the  
Iterable under test) are compared to expected elements using a Correspondence. | 
| Modifier | Constructor and Description | 
|---|---|
protected  | 
IterableSubject(FailureMetadata metadata,
               Iterable<?> iterable)
Constructor for use by subclasses. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
protected String | 
actualCustomStringRepresentation()
Supplies the direct string representation of the actual value to other methods which may prefix
 or otherwise position it in an error message. 
 | 
<A,E> IterableSubject.UsingCorrespondence<A,E> | 
comparingElementsUsing(Correspondence<? super A,? super E> correspondence)
Starts a method chain for a check in which the actual elements (i.e. 
 | 
void | 
contains(Object element)
Checks (with a side-effect failure) that the subject contains the supplied item. 
 | 
void | 
containsAnyIn(Iterable<?> expected)
Checks that the subject contains at least one of the objects contained in the provided
 collection or fails. 
 | 
void | 
containsAnyIn(Object[] expected)
Checks that the subject contains at least one of the objects contained in the provided array or
 fails. 
 | 
void | 
containsAnyOf(Object first,
             Object second,
             Object... rest)
Checks that the subject contains at least one of the provided objects or fails. 
 | 
Ordered | 
containsAtLeast(Object firstExpected,
               Object secondExpected,
               Object... restOfExpected)
Checks that the actual iterable contains at least all of the expected elements or fails. 
 | 
Ordered | 
containsAtLeastElementsIn(Iterable<?> expectedIterable)
Checks that the actual iterable contains at least all of the expected elements or fails. 
 | 
Ordered | 
containsAtLeastElementsIn(Object[] expected)
Checks that the actual iterable contains at least all of the expected elements or fails. 
 | 
Ordered | 
containsExactly(Object... varargs)
Checks that a subject contains exactly the provided objects or fails. 
 | 
Ordered | 
containsExactlyElementsIn(Iterable<?> expected)
Checks that a subject contains exactly the provided objects or fails. 
 | 
Ordered | 
containsExactlyElementsIn(Object[] expected)
Checks that a subject contains exactly the provided objects or fails. 
 | 
void | 
containsNoDuplicates()
Checks that the subject does not contain duplicate elements. 
 | 
void | 
containsNoneIn(Iterable<?> excluded)
Checks that the actual iterable contains none of the elements contained in the excluded
 iterable or fails. 
 | 
void | 
containsNoneIn(Object[] excluded)
Checks that the actual iterable contains none of the elements contained in the excluded array
 or fails. 
 | 
void | 
containsNoneOf(Object firstExcluded,
              Object secondExcluded,
              Object... restOfExcluded)
Checks that a actual iterable contains none of the excluded objects or fails. 
 | 
void | 
doesNotContain(Object element)
Checks (with a side-effect failure) that the subject does not contain the supplied item. 
 | 
void | 
hasSize(int expectedSize)
Fails if the subject does not have the given size. 
 | 
void | 
isEmpty()
Fails if the subject is not empty. 
 | 
void | 
isEqualTo(Object expected)
Fails if the subject is not equal to the given object. 
 | 
void | 
isInOrder()
Fails if the iterable is not ordered, according to the natural ordering of its elements. 
 | 
void | 
isInOrder(Comparator<?> comparator)
Fails if the iterable is not ordered, according to the given comparator. 
 | 
void | 
isInStrictOrder()
Fails if the iterable is not strictly ordered, according to the natural ordering of its
 elements. 
 | 
void | 
isInStrictOrder(Comparator<?> comparator)
Fails if the iterable is not strictly ordered, according to the given comparator. 
 | 
void | 
isNoneOf(Object first,
        Object second,
        Object... rest)
Deprecated. 
 
You probably meant to call  
containsNoneOf(java.lang.Object, java.lang.Object, java.lang.Object...) instead. | 
void | 
isNotEmpty()
Fails if the subject is empty. 
 | 
void | 
isNotIn(Iterable<?> iterable)
Deprecated. 
 
You probably meant to call  
containsNoneIn(java.lang.Iterable<?>) instead. | 
check, equals, failWithActual, failWithActual, failWithoutActual, hashCode, ignoreCheck, isAnyOf, isIn, isInstanceOf, isNotEqualTo, isNotInstanceOf, isNotNull, isNotSameInstanceAs, isNull, isSameInstanceAs, toStringprotected IterableSubject(FailureMetadata metadata, @NullableDecl Iterable<?> iterable)
Subject.check().that(actual).protected String actualCustomStringRepresentation()
SubjectSubjects should override this with care.
By default, this returns String.ValueOf(getActualValue()).
actualCustomStringRepresentation in class Subjectpublic void isEqualTo(@NullableDecl
                      Object expected)
SubjectObjects.equal(java.lang.Object, java.lang.Object)
   Arrays.equals(long[], long[])
       overload
   Byte, Short, Character, Integer, or Long) and they are numerically equal when converted to Long.
 Note: This method does not test the Object.equals(java.lang.Object) implementation itself; it
 assumes that method is functioning correctly according to its contract. Testing an
 equals implementation requires a utility such as guava-testlib's EqualsTester.
 
In some cases, this method might not even call equals. It may instead perform other
 tests that will return the same result as long as equals is implemented according to
 the contract for its type.
public final void isEmpty()
public final void isNotEmpty()
public final void hasSize(int expectedSize)
public final void contains(@NullableDecl
                           Object element)
public final void doesNotContain(@NullableDecl
                                 Object element)
public final void containsNoDuplicates()
public final void containsAnyOf(@NullableDecl
                                Object first,
                                @NullableDecl
                                Object second,
                                @NullableDecl
                                Object... rest)
public final void containsAnyIn(Iterable<?> expected)
public final void containsAnyIn(Object[] expected)
@CanIgnoreReturnValue public final Ordered containsAtLeast(@NullableDecl Object firstExpected, @NullableDecl Object secondExpected, @NullableDecl Object... restOfExpected)
To also test that the contents appear in the given order, make a call to inOrder()
 on the object returned by this method. The expected elements must appear in the given order
 within the actual elements, but they are not required to be consecutive.
@CanIgnoreReturnValue public final Ordered containsAtLeastElementsIn(Iterable<?> expectedIterable)
To also test that the contents appear in the given order, make a call to inOrder()
 on the object returned by this method. The expected elements must appear in the given order
 within the actual elements, but they are not required to be consecutive.
@CanIgnoreReturnValue public final Ordered containsAtLeastElementsIn(Object[] expected)
To also test that the contents appear in the given order, make a call to inOrder()
 on the object returned by this method. The expected elements must appear in the given order
 within the actual elements, but they are not required to be consecutive.
@CanIgnoreReturnValue public final Ordered containsExactly(@NullableDecl Object... varargs)
Multiplicity is respected. For example, an object duplicated exactly 3 times in the parameters asserts that the object must likewise be duplicated exactly 3 times in the subject.
To also test that the contents appear in the given order, make a call to inOrder()
 on the object returned by this method.
 
To test that the iterable contains the same elements as an array, prefer containsExactlyElementsIn(Object[]). It makes clear that the given array is a list of
 elements, not an element itself. This helps human readers and avoids a compiler warning.
@CanIgnoreReturnValue public final Ordered containsExactlyElementsIn(Iterable<?> expected)
Multiplicity is respected. For example, an object duplicated exactly 3 times in the Iterable parameter asserts that the object must likewise be duplicated exactly 3 times in the
 subject.
 
To also test that the contents appear in the given order, make a call to inOrder()
 on the object returned by this method.
@CanIgnoreReturnValue public final Ordered containsExactlyElementsIn(Object[] expected)
Multiplicity is respected. For example, an object duplicated exactly 3 times in the array parameter asserts that the object must likewise be duplicated exactly 3 times in the subject.
To also test that the contents appear in the given order, make a call to inOrder()
 on the object returned by this method.
public final void containsNoneOf(@NullableDecl
                                 Object firstExcluded,
                                 @NullableDecl
                                 Object secondExcluded,
                                 @NullableDecl
                                 Object... restOfExcluded)
public final void containsNoneIn(Iterable<?> excluded)
public final void containsNoneIn(Object[] excluded)
public void isInStrictOrder()
ClassCastException - if any pair of elements is not mutually ComparableNullPointerException - if any element is nullpublic final void isInStrictOrder(Comparator<?> comparator)
ClassCastException - if any pair of elements is not mutually Comparablepublic void isInOrder()
ClassCastException - if any pair of elements is not mutually ComparableNullPointerException - if any element is nullpublic final void isInOrder(Comparator<?> comparator)
ClassCastException - if any pair of elements is not mutually Comparable@Deprecated public void isNoneOf(@NullableDecl Object first, @NullableDecl Object second, @NullableDecl Object... rest)
containsNoneOf(java.lang.Object, java.lang.Object, java.lang.Object...) instead.Subject@Deprecated public void isNotIn(Iterable<?> iterable)
containsNoneIn(java.lang.Iterable<?>) instead.Subjectpublic <A,E> IterableSubject.UsingCorrespondence<A,E> comparingElementsUsing(Correspondence<? super A,? super E> correspondence)
Iterable under test) are compared to expected elements using the given Correspondence.
 The actual elements must be of type A, the expected elements must be of type E.
 The check is actually executed by continuing the method chain. For example:
 
 assertThat(actualIterable).comparingElementsUsing(correspondence).contains(expected);
 
 where actualIterable is an Iterable<A> (or, more generally, an Iterable<? extends A>), correspondence is a Correspondence<A, E>, and expected is an E.
 Any of the methods on the returned object may throw ClassCastException if they
 encounter an actual element that is not of type A.
Copyright © 2019. All rights reserved.