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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classOrdered implementation that always fails.Nested classes/interfaces inherited from class Subject
Subject.HasField -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final OrderedOrdered implementation that does nothing because it's already known to be true.Fields inherited from class Subject
failureStrategy -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAttests (with a side-effect failure) that the subject contains the supplied item.private voidprivate OrderedcontainsAll(String failVerb, Iterable<?> expected) 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).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).voidcontainsAnyIn(Iterable<?> expected) Attests that a Collection contains at least one of the objects contained in the provided collection or fails.voidcontainsAnyOf(Object first, Object second, Object... rest) Attests that the subject contains at least one of the provided objects or fails.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).private OrderedcontainsExactly(String failVerb, Iterable<?> required) 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).voidAttests that the subject does not contain duplicate elements.private voidcontainsNone(String failVerb, Iterable<?> excluded) voidcontainsNoneIn(Iterable<?> excluded) Attests that a Collection contains none of the objects contained in the provided collection or fails, eliding duplicates.voidcontainsNoneOf(Object first, Object second, Object... rest) Attests that a subject contains none of the provided objects or fails, eliding duplicates.containsOnlyElements(Object first, Object second, Object... rest) Deprecated.containsOnlyElementsIn(Iterable<?> expected) Deprecated.UsecontainsExactlyElementsIn(Iterable)instead.(package private) static <T, C extends Iterable<T>>
IterableSubject<? extends IterableSubject<?, T, C>, T, C> create(FailureStrategy failureStrategy, Iterable<T> list) voiddoesNotContain(Object element) Attests (with a side-effect failure) that the subject does not contain the supplied item.final voidhasSize(int expectedSize) Fails if the subject does not have the given size.voidisEmpty()Fails if the subject is not empty.voidFails if the subject is empty.voiditeratesAs(Iterable<?> expectedItems) Asserts that the items are supplied in the order given by the iterable.voiditeratesAs(Object... expectedItems) Asserts that the items are supplied in the order given by the iterable.voiditeratesOverSequence(Object... expectedItems) Deprecated.UsecontainsExactly(Object, Object...).inOrder()instead.Methods inherited from class 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
-
Field Details
-
IN_ORDER
Ordered implementation that does nothing because it's already known to be true.
-
-
Constructor Details
-
IterableSubject
IterableSubject(FailureStrategy failureStrategy, C list)
-
-
Method Details
-
create
static <T, C extends Iterable<T>> IterableSubject<? extends IterableSubject<?,T, createC>, T, C> (FailureStrategy failureStrategy, Iterable<T> list) -
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
Asserts that the items are supplied in the order given by the iterable. If the iterable under test and/or theexpectedItemsdo 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.UsecontainsExactly(Object, Object...).inOrder()instead. -
iteratesAs
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
-
doesNotContain
-
containsNoDuplicates
public void containsNoDuplicates()Attests that the subject does not contain duplicate elements. -
containsAnyOf
-
containsAnyIn
Attests that a Collection contains at least one of the objects contained in the provided collection or fails. -
contains
-
containsAllOf
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
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. -
containsAll
-
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.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
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
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
-
containsNoneOf
-
containsNoneIn
Attests that a Collection contains none of the objects contained in the provided collection or fails, eliding duplicates. -
containsNone
-
containsExactly(Object...)instead.