org.hamcrest.collection
Class IsCollectionWithSize<E>
java.lang.Object
org.hamcrest.BaseMatcher<T>
org.hamcrest.TypeSafeDiagnosingMatcher<T>
org.hamcrest.FeatureMatcher<Collection<? extends E>,Integer>
org.hamcrest.collection.IsCollectionWithSize<E>
- All Implemented Interfaces:
- Matcher<Collection<? extends E>>, SelfDescribing
public class IsCollectionWithSize<E>
- extends FeatureMatcher<Collection<? extends E>,Integer>
Matches if collection size satisfies a nested matcher.
IsCollectionWithSize
public IsCollectionWithSize(Matcher<? super Integer> sizeMatcher)
featureValueOf
protected Integer featureValueOf(Collection<? extends E> actual)
- Specified by:
featureValueOf in class FeatureMatcher<Collection<? extends E>,Integer>
hasSize
public static <E> Matcher<Collection<? extends E>> hasSize(Matcher<? super Integer> sizeMatcher)
- Creates a matcher for
Collections that matches when the size() method returns
a value that satisfies the specified matcher.
For example:
assertThat(Arrays.asList("foo", "bar"), hasSize(equalTo(2)))
- Parameters:
sizeMatcher - a matcher for the size of an examined Collection
hasSize
public static <E> Matcher<Collection<? extends E>> hasSize(int size)
- Creates a matcher for
Collections that matches when the size() method returns
a value equal to the specified size.
For example:
assertThat(Arrays.asList("foo", "bar"), hasSize(2))
- Parameters:
size - the expected size of an examined Collection
Copyright © 2014. All rights reserved.