Class Matchers


  • public final class Matchers
    extends Object
    • Method Detail

      • containsOnlyInOrder

        public static <T> org.hamcrest.Matcher<Collection<T>> containsOnlyInOrder​(org.hamcrest.Matcher<? extends T>... matchers)
        Creates a matcher that matches if the examined collection matches the specified matchers in order

        For example:

        assertThat(Arrays.asList("foo", "bar"), containsOnlyInOrder(startsWith("f"), endsWith("ar")))
      • containsOnlyInOrder

        public static <T> org.hamcrest.Matcher<Collection<T>> containsOnlyInOrder​(T... items)
        Creates a matcher that matches if the examined collection matches the specified items in order

        For example:

        assertThat(Arrays.asList("foo", "bar"), containsOnlyInOrder("foo", "bar"))
      • containsOnly

        public static <T> org.hamcrest.Matcher<Collection<T>> containsOnly​(org.hamcrest.Matcher<? extends T>... matchers)
        Creates a matcher that matches if the examined collection matches the specified items in any order

        For example:

        assertThat(Arrays.asList("bar", "foo"), containsOnly(startsWith("f"), endsWith("ar")))
      • containsOnly

        public static <T> org.hamcrest.Matcher<Collection<T>> containsOnly​(T... items)
        Creates a matcher that matches if the examined collection matches the specified items in any order

        For example:

        assertThat(Arrays.asList("bar", "foo"), containsOnly("foo", "bar"))