Class IsCollectionContainingMatcher<T>

  • Type Parameters:
    T -
    All Implemented Interfaces:
    org.hamcrest.Matcher<Iterable<T>>, org.hamcrest.SelfDescribing

    public class IsCollectionContainingMatcher<T>
    extends org.hamcrest.TypeSafeMatcher<Iterable<T>>
    Hamcrest's IsCollectionContaining matcher is broken in version 1.3 - it doesn't support expressions like
    assertThat(Arrays.asList("foo", "bar"), hasItem(startsWith("ba")))

    This is light-weight matcher analogous to hamcrest's one.

    • Constructor Detail

      • IsCollectionContainingMatcher

        public IsCollectionContainingMatcher​(org.hamcrest.Matcher<T> elementMatcher)
    • Method Detail

      • matchesSafely

        protected boolean matchesSafely​(Iterable<T> collection)
        Specified by:
        matchesSafely in class org.hamcrest.TypeSafeMatcher<Iterable<T>>
      • describeTo

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

        public static <T> org.hamcrest.Matcher<Iterable<T>> hasItem​(org.hamcrest.Matcher<T> itemMatcher)
      • hasItem

        public static <T> org.hamcrest.Matcher<Iterable<T>> hasItem​(T item)
      • hasItems

        public static <T> org.hamcrest.Matcher<Iterable<T>> hasItems​(org.hamcrest.Matcher<T>... itemMatchers)
      • hasItems

        public static <T> org.hamcrest.Matcher<Iterable<T>> hasItems​(T... items)