类 JsonPathResultMatchers

java.lang.Object
cn.taketoday.test.web.servlet.result.JsonPathResultMatchers

public class JsonPathResultMatchers extends Object
Factory for assertions on the response content using JsonPath expressions.

An instance of this class is typically accessed via MockMvcResultMatchers.jsonPath(String, Object...).

从以下版本开始:
4.0
作者:
Rossen Stoyanchev, Craig Andrews, Sam Brannen, Brian Clozel
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
     
    private String
     
  • 构造器概要

    构造器
    限定符
    构造器
    说明
    protected
    JsonPathResultMatchers(String expression, Object... args)
    Protected constructor.
  • 方法概要

    修饰符和类型
    方法
    说明
    Evaluate the JSON path expression against the response content and assert that a non-null value does not exist at the given path.
    Evaluate the JSON path expression against the supplied content and assert that a value, including null values, does not exist at the given path.
    Evaluate the JSON path expression against the response content and assert that a non-null value, possibly an empty array or map, exists at the given path.
    private String
     
    Evaluate the JSON path expression against the response content and assert that a value, possibly null, exists.
    Evaluate the JSON path expression against the response content and assert that the result is an array.
    Evaluate the JSON path expression against the response content and assert that the result is a Boolean.
    Evaluate the JSON path expression against the response content and assert that an empty value exists at the given path.
    Evaluate the JSON path expression against the response content and assert that the result is a Map.
    Evaluate the JSON path expression against the response content and assert that a non-empty value exists at the given path.
    Evaluate the JSON path expression against the response content and assert that the result is a Number.
    Evaluate the JSON path expression against the response content and assert that the result is a String.
    prefix(String prefix)
    Configures the current JsonPathResultMatchers instance to verify that the JSON payload is prepended with the given prefix.
    value(Object expectedValue)
    Evaluate the JSON path expression against the response content and assert that the result is equal to the supplied value.
    value(org.hamcrest.Matcher<? super T> matcher)
    Evaluate the JSON path expression against the response content and assert the resulting value with the given Hamcrest Matcher.
    value(org.hamcrest.Matcher<? super T> matcher, 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.

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 字段详细资料

  • 构造器详细资料

  • 方法详细资料

    • prefix

      public JsonPathResultMatchers prefix(String prefix)
      Configures the current JsonPathResultMatchers instance to verify that the JSON payload is prepended with the given prefix.

      Use this method if the JSON payloads are prefixed to avoid Cross Site Script Inclusion (XSSI) attacks.

      参数:
      prefix - the string prefix prepended to the actual JSON payload
    • value

      public <T> ResultMatcher value(org.hamcrest.Matcher<? super T> matcher)
      Evaluate the JSON path expression against the response content and assert the resulting value with the given Hamcrest Matcher.
      另请参阅:
    • value

      public <T> ResultMatcher value(org.hamcrest.Matcher<? super T> matcher, 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.

      另请参阅:
    • value

      public ResultMatcher value(@Nullable Object expectedValue)
      Evaluate the JSON path expression against the response content and assert that the result is equal to the supplied value.
      另请参阅:
    • exists

      public ResultMatcher exists()
      Evaluate the JSON path expression against the response content and assert that a non-null value, possibly an empty array or map, 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 ResultMatcher doesNotExist()
      Evaluate the JSON path expression against the response content and assert that a non-null 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.

    • isEmpty

      public ResultMatcher isEmpty()
      Evaluate the JSON path expression against the response content and assert that an empty value exists at the given path.

      For the semantics of empty, consult the Javadoc for ObjectUtils.isEmpty(Object).

      另请参阅:
    • isNotEmpty

      public ResultMatcher isNotEmpty()
      Evaluate the JSON path expression against the response content and assert that a non-empty value exists at the given path.

      For the semantics of empty, consult the Javadoc for ObjectUtils.isEmpty(Object).

      另请参阅:
    • hasJsonPath

      public ResultMatcher 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.

      另请参阅:
    • doesNotHaveJsonPath

      public ResultMatcher 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.

      另请参阅:
    • isString

      public ResultMatcher isString()
      Evaluate the JSON path expression against the response content and assert that the result is a String.
    • isBoolean

      public ResultMatcher isBoolean()
      Evaluate the JSON path expression against the response content and assert that the result is a Boolean.
    • isNumber

      public ResultMatcher isNumber()
      Evaluate the JSON path expression against the response content and assert that the result is a Number.
    • isArray

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

      public ResultMatcher isMap()
      Evaluate the JSON path expression against the response content and assert that the result is a Map.
    • getContent

      private String getContent(MvcResult result) throws UnsupportedEncodingException
      抛出:
      UnsupportedEncodingException