类 JsonPathResultMatchers

    • 方法详细资料

      • 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
        从以下版本开始:
        4.3
      • value

        public <T> ResultMatcher value​(Matcher<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.

        从以下版本开始:
        4.3.15
        另请参阅:
        value(Matcher), value(Object)
      • 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.

      • 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.

        从以下版本开始:
        5.0.3
        另请参阅:
        exists(), isNotEmpty()
      • 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.

        从以下版本开始:
        5.0.3
        另请参阅:
        doesNotExist(), isEmpty()
      • isString

        public ResultMatcher isString()
        Evaluate the JSON path expression against the response content and assert that the result is a String.
        从以下版本开始:
        4.2.1
      • isBoolean

        public ResultMatcher isBoolean()
        Evaluate the JSON path expression against the response content and assert that the result is a Boolean.
        从以下版本开始:
        4.2.1
      • isNumber

        public ResultMatcher isNumber()
        Evaluate the JSON path expression against the response content and assert that the result is a Number.
        从以下版本开始:
        4.2.1
      • 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.
        从以下版本开始:
        4.2.1