Class FieldMatcher

  • All Implemented Interfaces:
    BodyMatcher

    public class FieldMatcher
    extends java.lang.Object
    implements BodyMatcher
    Matches simple form fields
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map<java.lang.String,​java.lang.String> formParams  
    • Constructor Summary

      Constructors 
      Constructor Description
      FieldMatcher​(java.util.Map<java.lang.String,​java.lang.String> formParams)
      Creates a FieldMatcher expecting a map of keys and values
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.lang.String description​(boolean pass, java.util.List<java.lang.String> missing)  
      private static <K,​V>
      java.util.Map<K,​V>
      mapOf​(java.lang.Object... keyValues)  
      MatchStatus matches​(java.util.List<java.lang.String> body)
      indicates if the Matcher succeeded in matching the body
      static FieldMatcher of​(java.lang.String... keyValuePairs)
      Creates a FieldMatcher expecting a map of keys and values use like: FieldMatcher.of("fruit", "orange", "quantity" "42")
      • Methods inherited from class java.lang.Object

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

      • formParams

        private final java.util.Map<java.lang.String,​java.lang.String> formParams
    • Constructor Detail

      • FieldMatcher

        public FieldMatcher​(java.util.Map<java.lang.String,​java.lang.String> formParams)
        Creates a FieldMatcher expecting a map of keys and values
        Parameters:
        formParams - the map of field params
    • Method Detail

      • of

        public static FieldMatcher of​(java.lang.String... keyValuePairs)
        Creates a FieldMatcher expecting a map of keys and values use like: FieldMatcher.of("fruit", "orange", "quantity" "42")
        Parameters:
        keyValuePairs - an array of key-value pairs to expect
        Returns:
        a new FieldMatcher
      • matches

        public MatchStatus matches​(java.util.List<java.lang.String> body)
                            throws java.lang.AssertionError
        Description copied from interface: BodyMatcher
        indicates if the Matcher succeeded in matching the body
        Specified by:
        matches in interface BodyMatcher
        Parameters:
        body - the list of body parts
        Returns:
        MatchStatus indicating if the Matcher succeeded in matching the body
        Throws:
        java.lang.AssertionError
      • description

        private java.lang.String description​(boolean pass,
                                             java.util.List<java.lang.String> missing)
      • mapOf

        private static <K,​V> java.util.Map<K,​V> mapOf​(java.lang.Object... keyValues)