Package com.google.common.truth
Class IterableSubject<S extends IterableSubject<S,T,C>,T,C extends Iterable<T>>
- java.lang.Object
-
- com.google.common.truth.Subject<S,C>
-
- com.google.common.truth.IterableSubject<S,T,C>
-
- Direct Known Subclasses:
CollectionSubject
public class IterableSubject<S extends IterableSubject<S,T,C>,T,C extends Iterable<T>> extends Subject<S,C>
Propositions forIterable
subjects.- Author:
- Kurt Alfred Kluever
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.common.truth.Subject
Subject.HasField
-
-
Field Summary
-
Fields inherited from class com.google.common.truth.Subject
failureStrategy
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
contains(Object element)
Attests (with a side-effect failure) that the subject contains the supplied item.Ordered
containsAllIn(Iterable<?> expected)
Attests that the subject contains at least all of the provided objects or fails, potentially permitting duplicates in both the subject and the parameters (if the subject even can have duplicates).Ordered
containsAllOf(Object first, Object second, Object... rest)
Attests that the subject contains at least all of the provided objects or fails, potentially permitting duplicates in both the subject and the parameters (if the subject even can have duplicates).void
containsAnyIn(Iterable<?> expected)
Attests that a Collection contains at least one of the objects contained in the provided collection or fails.void
containsAnyOf(Object first, Object second, Object... rest)
Attests that the subject contains at least one of the provided objects or fails.Ordered
containsExactly(Object... varargs)
Attests that a subject contains all of the provided objects and only these objects or fails, potentially permitting duplicates in both the subject and the parameters (if the subject even can have duplicates).Ordered
containsExactlyElementsIn(Iterable<?> expected)
Attests that a subject contains all of the provided objects and only these objects or fails, potentially permitting duplicates in both the subject and the parameters (if the subject even can have duplicates).void
containsNoDuplicates()
Attests that the subject does not contain duplicate elements.void
containsNoneIn(Iterable<?> excluded)
Attests that a Collection contains none of the objects contained in the provided collection or fails, eliding duplicates.void
containsNoneOf(Object first, Object second, Object... rest)
Attests that a subject contains none of the provided objects or fails, eliding duplicates.Ordered
containsOnlyElements(Object first, Object second, Object... rest)
Deprecated.UsecontainsExactly(Object...)
instead.Ordered
containsOnlyElementsIn(Iterable<?> expected)
Deprecated.UsecontainsExactlyElementsIn(Iterable)
instead.void
doesNotContain(Object element)
Attests (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
isNotEmpty()
Fails if the subject is empty.void
iteratesAs(Iterable<?> expectedItems)
Asserts that the items are supplied in the order given by the iterable.void
iteratesAs(Object... expectedItems)
Asserts that the items are supplied in the order given by the iterable.void
iteratesOverSequence(Object... expectedItems)
Deprecated.UsecontainsExactly(Object, Object...).inOrder()
instead.-
Methods inherited from class com.google.common.truth.Subject
check, equals, fail, fail, fail, failWithBadResults, failWithCustomSubject, failWithoutSubject, failWithRawMessage, getDisplaySubject, getSubject, hasField, hashCode, internalCustomName, is, isA, isEqualTo, isInstanceOf, isNotA, isNotEqualTo, isNotInstanceOf, isNotNull, isNotSameAs, isNull, isSameAs, labeled, named
-
-
-
-
Method Detail
-
isEmpty
public void isEmpty()
Fails if the subject is not empty.
-
isNotEmpty
public void isNotEmpty()
Fails if the subject is empty.
-
hasSize
public final void hasSize(int expectedSize)
Fails if the subject does not have the given size.
-
iteratesAs
public void iteratesAs(Iterable<?> expectedItems)
Asserts that the items are supplied in the order given by the iterable. If the iterable under test and/or theexpectedItems
do not provide iteration order guarantees (say,Set
<?>
s), this method may provide unexpected results. Consider usingSubject.isEqualTo(Object)
in such cases, or using collections and iterables that provide strong order guarantees.
-
iteratesOverSequence
@Deprecated public void iteratesOverSequence(Object... expectedItems)
Deprecated.UsecontainsExactly(Object, Object...).inOrder()
instead.
-
iteratesAs
public void iteratesAs(Object... expectedItems)
Asserts that the items are supplied in the order given by the iterable. If the iterable under test does not provide iteration order guarantees (say, aSet
<?>
), this method is not suitable for asserting that order. Consider usingSubject.isEqualTo(Object)
-
contains
public void contains(@Nullable Object element)
Attests (with a side-effect failure) that the subject contains the supplied item.
-
doesNotContain
public void doesNotContain(@Nullable Object element)
Attests (with a side-effect failure) that the subject does not contain the supplied item.
-
containsNoDuplicates
public void containsNoDuplicates()
Attests that the subject does not contain duplicate elements.
-
containsAnyOf
public void containsAnyOf(@Nullable Object first, @Nullable Object second, Object... rest)
Attests that the subject contains at least one of the provided objects or fails.
-
containsAnyIn
public void containsAnyIn(Iterable<?> expected)
Attests that a Collection contains at least one of the objects contained in the provided collection or fails.
-
containsAllOf
public Ordered containsAllOf(@Nullable Object first, @Nullable Object second, Object... rest)
Attests that the subject contains at least all of the provided objects or fails, potentially permitting duplicates in both the subject and the parameters (if the subject even can have duplicates).Callers may optionally chain an
inOrder()
call if its expected contents must be contained in the given order.
-
containsAllIn
public Ordered containsAllIn(Iterable<?> expected)
Attests that the subject contains at least all of the provided objects or fails, potentially permitting duplicates in both the subject and the parameters (if the subject even can have duplicates).Callers may optionally chain an
inOrder()
call if its expected contents must be contained in the given order.
-
containsOnlyElements
@Deprecated public Ordered containsOnlyElements(@Nullable Object first, @Nullable Object second, Object... rest)
Deprecated.UsecontainsExactly(Object...)
instead.Attests that a subject contains all of the provided objects and only these objects or fails, potentially permitting duplicates in both the subject and the parameters (if the subject even can have duplicates).Callers may optionally chain an
inOrder()
call if its expected contents must be contained in the given order.
-
containsOnlyElementsIn
@Deprecated public Ordered containsOnlyElementsIn(Iterable<?> expected)
Deprecated.UsecontainsExactlyElementsIn(Iterable)
instead.Attests that a subject contains all of the provided objects and only these objects or fails, potentially permitting duplicates in both the subject and the parameters (if the subject even can have duplicates).Callers may optionally chain an
inOrder()
call if its expected contents must be contained in the given order.
-
containsExactly
public Ordered containsExactly(@Nullable Object... varargs)
Attests that a subject contains all of the provided objects and only these objects or fails, potentially permitting duplicates in both the subject and the parameters (if the subject even can have duplicates).Callers may optionally chain an
inOrder()
call if its expected contents must be contained in the given order.
-
containsExactlyElementsIn
public Ordered containsExactlyElementsIn(Iterable<?> expected)
Attests that a subject contains all of the provided objects and only these objects or fails, potentially permitting duplicates in both the subject and the parameters (if the subject even can have duplicates).Callers may optionally chain an
inOrder()
call if its expected contents must be contained in the given order.
-
containsNoneOf
public void containsNoneOf(@Nullable Object first, @Nullable Object second, Object... rest)
Attests that a subject contains none of the provided objects or fails, eliding duplicates.
-
containsNoneIn
public void containsNoneIn(Iterable<?> excluded)
Attests that a Collection contains none of the objects contained in the provided collection or fails, eliding duplicates.
-
-