public class IsCollectionWithSize<E> extends FeatureMatcher<java.util.Collection<? extends E>,java.lang.Integer>
Constructor and Description |
---|
IsCollectionWithSize(Matcher<? super java.lang.Integer> sizeMatcher) |
Modifier and Type | Method and Description |
---|---|
protected java.lang.Integer |
featureValueOf(java.util.Collection<? extends E> actual)
Implement this to extract the interesting feature.
|
static <E> Matcher<java.util.Collection<? extends E>> |
hasSize(int size)
Creates a matcher for
Collection s that matches when the size() method returns
a value equal to the specified size . |
static <E> Matcher<java.util.Collection<? extends E>> |
hasSize(Matcher<? super java.lang.Integer> sizeMatcher)
Creates a matcher for
Collection s that matches when the size() method returns
a value that satisfies the specified matcher. |
describeTo, matchesSafely
describeMismatch, matches
_dont_implement_Matcher___instead_extend_BaseMatcher_, toString
public IsCollectionWithSize(Matcher<? super java.lang.Integer> sizeMatcher)
protected java.lang.Integer featureValueOf(java.util.Collection<? extends E> actual)
FeatureMatcher
featureValueOf
in class FeatureMatcher<java.util.Collection<? extends E>,java.lang.Integer>
actual
- the target objectpublic static <E> Matcher<java.util.Collection<? extends E>> hasSize(Matcher<? super java.lang.Integer> sizeMatcher)
Collection
s that matches when the size()
method returns
a value that satisfies the specified matcher.
For example:
assertThat(Arrays.asList("foo", "bar"), hasSize(equalTo(2)))
sizeMatcher
- a matcher for the size of an examined Collection
public static <E> Matcher<java.util.Collection<? extends E>> hasSize(int size)
Collection
s that matches when the size()
method returns
a value equal to the specified size
.
For example:
assertThat(Arrays.asList("foo", "bar"), hasSize(2))
size
- the expected size of an examined Collection