Class ExtraMatchers


  • public class ExtraMatchers
    extends java.lang.Object
    Extra Matchers for the Junit Hamcrest users out there.
    • Constructor Summary

      Constructors 
      Constructor Description
      ExtraMatchers()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> org.hamcrest.Matcher<java.lang.Iterable<? super T>> ordered​(java.util.List<T> itemMatchers)
      Creates a matcher for Iterables that matches when consecutive passes over the examined Iterable yield at least one item that is matched by the corresponding matcher from the specified itemMatchers.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ExtraMatchers

        public ExtraMatchers()
    • Method Detail

      • ordered

        public static <T> org.hamcrest.Matcher<java.lang.Iterable<? super T>> ordered​(java.util.List<T> itemMatchers)
        Creates a matcher for Iterables that matches when consecutive passes over the examined Iterable yield at least one item that is matched by the corresponding matcher from the specified itemMatchers. Whilst matching, each traversal of the examined Iterable will stop as soon as a matching item is found.

        For example:

         assertThat(Arrays.asList("foo","bar","baz"),hasItems(endsWith("z"),endsWith("o")))
         
        Type Parameters:
        T - the type
        Parameters:
        itemMatchers - the matchers to apply to items provided by the examined Iterable
        Returns:
        the matcher