JavaMatchers.java 文件源码

java
阅读 28 收藏 0 点赞 0 评论 0

项目:oscm 作者:
/**
 * Checks if collection has the given number of items.
 */
public static Matcher<Collection<?>> hasItems(final int numberOfItems) {
    return new TypeSafeMatcher<Collection<?>>() {

        @Override
        public boolean matchesSafely(Collection<?> collection) {
            if (collection == null || collection.size() != numberOfItems) {
                return false;
            }
            return true;
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("expected a collection with "
                    + numberOfItems + " items");
        }

    };
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号