public interface IterableOfProtosUsingCorrespondence<M extends com.google.protobuf.Message>
IterableOfProtosFluentAssertion
.Modifier and Type | Method and Description |
---|---|
void |
contains(M expected)
Checks that the subject contains at least one element that corresponds to the given expected
element.
|
Ordered |
containsAllIn(Iterable<? extends M> expected)
Checks that the subject contains elements that corresponds to all of the expected elements,
i.e.
|
Ordered |
containsAllIn(M[] expected)
Checks that the subject contains elements that corresponds to all of the expected elements,
i.e.
|
Ordered |
containsAllOf(M first,
M second,
M... rest)
Checks that the subject contains elements that corresponds to all of the expected elements,
i.e.
|
void |
containsAnyIn(Iterable<? extends M> expected)
Checks that the subject contains at least one element that corresponds to at least one of the
expected elements.
|
void |
containsAnyIn(M[] expected)
Checks that the subject contains at least one element that corresponds to at least one of the
expected elements.
|
void |
containsAnyOf(M first,
M second,
M... rest)
Checks that the subject contains at least one element that corresponds to at least one of the
expected elements.
|
Ordered |
containsExactly(M... expected)
Checks that subject contains exactly elements that correspond to the expected elements, i.e.
|
Ordered |
containsExactlyElementsIn(Iterable<? extends M> expected)
Checks that subject contains exactly elements that correspond to the expected elements, i.e.
|
Ordered |
containsExactlyElementsIn(M[] expected)
Checks that subject contains exactly elements that correspond to the expected elements, i.e.
|
void |
containsNoneIn(Iterable<? extends M> excluded)
Checks that the subject contains no elements that correspond to any of the given elements.
|
void |
containsNoneIn(M[] excluded)
Checks that the subject contains no elements that correspond to any of the given elements.
|
void |
containsNoneOf(M firstExcluded,
M secondExcluded,
M... restOfExcluded)
Checks that the subject contains no elements that correspond to any of the given elements.
|
IterableOfProtosUsingCorrespondence<M> |
displayingDiffsPairedBy(Function<? super M,?> keyFunction)
Specifies a way to pair up unexpected and missing elements in the message when an assertion
fails.
|
void |
doesNotContain(M excluded)
Checks that none of the actual elements correspond to the given element.
|
IterableOfProtosUsingCorrespondence<M> displayingDiffsPairedBy(Function<? super M,?> keyFunction)
assertThat(actualFoos)
.ignoringRepeatedFieldOrder()
.ignoringFields(Foo.BAR_FIELD_NUMBER)
.displayingDiffsPairedBy(Foo::getId)
.containsExactlyElementsIn(expectedFoos);
On assertions where it makes sense to do so, the elements are paired as follows: they are
keyed by keyFunction
, and if an unexpected element and a missing element have the same
non-null key then the they are paired up. (Elements with null keys are not paired.) The failure
message will show paired elements together, and a diff will be shown.
The expected elements given in the assertion should be uniquely keyed by keyFunction
. If multiple missing elements have the same key then the pairing will be skipped.
Useful key functions will have the property that key equality is less strict than the
already specified equality rules; i.e. given actual
and expected
values with
keys actualKey
and expectedKey
, if actual
and expected
compare
equal given the rest of the directives such as ignoringRepeatedFieldOrder
and ignoringFields
, then it is guaranteed that actualKey
is equal to expectedKey
,
but there are cases where actualKey
is equal to expectedKey
but the direct
comparison fails.
Note that calling this method makes no difference to whether a test passes or fails, it just improves the message if it fails.
void contains(@NullableDecl M expected)
void doesNotContain(@NullableDecl M excluded)
@CanIgnoreReturnValue Ordered containsExactly(@NullableDecl M... expected)
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(Message[])
. It makes clear that the given array is a list of
elements, not an element itself.
@CanIgnoreReturnValue Ordered containsExactlyElementsIn(Iterable<? extends M> expected)
To also test that the contents appear in the given order, make a call to inOrder()
on the object returned by this method.
@CanIgnoreReturnValue Ordered containsExactlyElementsIn(M[] expected)
To also test that the contents appear in the given order, make a call to inOrder()
on the object returned by this method.
@CanIgnoreReturnValue Ordered containsAllOf(@NullableDecl M first, @NullableDecl M second, @NullableDecl M... rest)
To also test that the contents appear in the given order, make a call to inOrder()
on the object returned by this method. The elements must appear in the given order within the
subject, but they are not required to be consecutive.
@CanIgnoreReturnValue Ordered containsAllIn(Iterable<? extends M> 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 elements must appear in the given order within the
subject, but they are not required to be consecutive.
@CanIgnoreReturnValue Ordered containsAllIn(M[] 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 elements must appear in the given order within the
subject, but they are not required to be consecutive.
void containsAnyOf(@NullableDecl M first, @NullableDecl M second, @NullableDecl M... rest)
void containsAnyIn(Iterable<? extends M> expected)
void containsAnyIn(M[] expected)
void containsNoneOf(@NullableDecl M firstExcluded, @NullableDecl M secondExcluded, @NullableDecl M... restOfExcluded)
void containsNoneIn(Iterable<? extends M> excluded)
void containsNoneIn(M[] excluded)
Copyright © 2018. All rights reserved.