Class IsCollectionWithSize<E>

  • All Implemented Interfaces:
    org.hamcrest.Matcher<Collection<? extends E>>, org.hamcrest.SelfDescribing

    public class IsCollectionWithSize<E>
    extends CollectionMatcher<Collection<? extends E>>
    Matches if collection size satisfies a nested matcher.
    • Constructor Detail

      • IsCollectionWithSize

        public IsCollectionWithSize​(org.hamcrest.Matcher<? super Integer> sizeMatcher)
    • Method Detail

      • describeTo

        public void describeTo​(org.hamcrest.Description description)
      • hasSize

        public static <E> org.hamcrest.Matcher<? super Collection<? extends E>> hasSize​(org.hamcrest.Matcher<? super Integer> size)
        Does collection size satisfy a given matcher?
      • hasSize

        public static <E> org.hamcrest.Matcher<? super Collection<? extends E>> hasSize​(int size)
        This is a shortcut to the frequently used hasSize(equalTo(x)). For example, assertThat(hasSize(equal_to(x))) vs. assertThat(hasSize(x))