org.springframework.test.web.client.match

Class JsonPathRequestMatchers

  • java.lang.Object
    • org.springframework.test.web.client.match.JsonPathRequestMatchers
    • Constructor Summary

      Constructors 
      Modifier Constructor and Description
      protected JsonPathRequestMatchers(java.lang.String expression, java.lang.Object... args)
      Protected constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      RequestMatcher doesNotExist()
      Evaluate the JSON path expression against the request content and assert that a value does not exist at the given path.
      RequestMatcher doesNotHaveJsonPath()
      Evaluate the JSON path expression against the supplied content and assert that a value, including null values, does not exist at the given path.
      RequestMatcher exists()
      Evaluate the JSON path expression against the request content and assert that a non-null value exists at the given path.
      RequestMatcher hasJsonPath()
      Evaluate the JSON path expression against the response content and assert that a value, possibly null, exists.
      RequestMatcher isArray()
      Evaluate the JSON path expression against the request content and assert that the result is an array.
      RequestMatcher isBoolean()
      Evaluate the JSON path expression against the request content and assert that the result is a Boolean.
      RequestMatcher isEmpty()
      Evaluate the JSON path expression against the request content and assert that an empty value exists at the given path.
      RequestMatcher isMap()
      Evaluate the JSON path expression against the request content and assert that the result is a Map.
      RequestMatcher isNotEmpty()
      Evaluate the JSON path expression against the request content and assert that a non-empty value exists at the given path.
      RequestMatcher isNumber()
      Evaluate the JSON path expression against the request content and assert that the result is a Number.
      RequestMatcher isString()
      Evaluate the JSON path expression against the request content and assert that the result is a String.
      <T> RequestMatcher value(org.hamcrest.Matcher<T> matcher)
      Evaluate the JSON path expression against the request content and assert the resulting value with the given Hamcrest Matcher.
      <T> RequestMatcher value(org.hamcrest.Matcher<T> matcher, java.lang.Class<T> targetType)
      An overloaded variant of value(Matcher) that also accepts a target type for the resulting value that the matcher can work reliably against.
      RequestMatcher value(java.lang.Object expectedValue)
      Evaluate the JSON path expression against the request content and assert that the result is equal to the supplied value.
      • Methods inherited from class java.lang.Object

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

      • value

        public <T> RequestMatcher value(org.hamcrest.Matcher<T> matcher)
        Evaluate the JSON path expression against the request content and assert the resulting value with the given Hamcrest Matcher.
      • value

        public <T> RequestMatcher value(org.hamcrest.Matcher<T> matcher,
                                        java.lang.Class<T> targetType)
        An overloaded variant of value(Matcher) that also accepts a target type for the resulting value that the matcher can work reliably against.

        This can be useful for matching numbers reliably — for example, to coerce an integer into a double.

        Since:
        4.3.3
      • value

        public RequestMatcher value(java.lang.Object expectedValue)
        Evaluate the JSON path expression against the request content and assert that the result is equal to the supplied value.
      • exists

        public RequestMatcher exists()
        Evaluate the JSON path expression against the request content and assert that a non-null value exists at the given path.

        If the JSON path expression is not definite, this method asserts that the value at the given path is not empty.

      • doesNotExist

        public RequestMatcher doesNotExist()
        Evaluate the JSON path expression against the request content and assert that a value does not exist at the given path.

        If the JSON path expression is not definite, this method asserts that the value at the given path is empty.

      • hasJsonPath

        public RequestMatcher hasJsonPath()
        Evaluate the JSON path expression against the response content and assert that a value, possibly null, exists.

        If the JSON path expression is not definite, this method asserts that the list of values at the given path is not empty.

        Since:
        5.0.3
        See Also:
        exists(), isNotEmpty()
      • doesNotHaveJsonPath

        public RequestMatcher doesNotHaveJsonPath()
        Evaluate the JSON path expression against the supplied content and assert that a value, including null values, does not exist at the given path.

        If the JSON path expression is not definite, this method asserts that the list of values at the given path is empty.

        Since:
        5.0.3
        See Also:
        doesNotExist(), isEmpty()
      • isString

        public RequestMatcher isString()
        Evaluate the JSON path expression against the request content and assert that the result is a String.
        Since:
        4.2.1
      • isBoolean

        public RequestMatcher isBoolean()
        Evaluate the JSON path expression against the request content and assert that the result is a Boolean.
        Since:
        4.2.1
      • isNumber

        public RequestMatcher isNumber()
        Evaluate the JSON path expression against the request content and assert that the result is a Number.
        Since:
        4.2.1
      • isArray

        public RequestMatcher isArray()
        Evaluate the JSON path expression against the request content and assert that the result is an array.
      • isMap

        public RequestMatcher isMap()
        Evaluate the JSON path expression against the request content and assert that the result is a Map.
        Since:
        4.2.1