JsonPathExpectationsHelper (Spring Framework 3.2.1.RELEASE API)
Date: 2013-01-24

org.springframework.test.util

## Class JsonPathExpectationsHelper

- java.lang.Object
- - org.springframework.test.util.JsonPathExpectationsHelper

-     public class JsonPathExpectationsHelper
      extends Object

  A helper class for applying assertions via JSONPath expressions.
  Since:
    3.2
  Author:
    Rossen Stoyanchev

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `JsonPathExpectationsHelper(String expression, Object... args)` Class constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> void` | `assertValue(String content, org.hamcrest.Matcher<T> matcher)` Evaluate the JSONPath and assert the resulting value with the given `Matcher`.
    `void` | `assertValue(String responseContent, Object expectedValue)` Apply the JSONPath and assert the resulting value.
    `void` | `assertValueIsArray(String responseContent)` Apply the JSONPath and assert the resulting value is an array.
    `void` | `doesNotExist(String content)` Evaluate the JSON path and assert it doesn't point to any content.
    `void` | `exists(String content)` Evaluate the JSON path and assert the resulting content exists.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### JsonPathExpectationsHelper

          public JsonPathExpectationsHelper(String expression,
                                    Object... args)

      Class constructor.
      Parameters:
        `expression` - the JSONPath expression
        `args` - arguments to parameterize the JSONPath expression with using the formatting specifiers defined in `String.format(String, Object...)`

  - ### Method Detail

    - #### assertValue

          public <T> void assertValue(String content,
                             org.hamcrest.Matcher<T> matcher)
                           throws ParseException

      Evaluate the JSONPath and assert the resulting value with the given `Matcher`.
      Parameters:
        `content` - the response content
        `matcher` - the matcher to assert on the resulting json path
      Throws:
        `ParseException`

    - #### assertValue

          public void assertValue(String responseContent,
                         Object expectedValue)
                           throws ParseException

      Apply the JSONPath and assert the resulting value.
      Throws:
        `ParseException`

    - #### assertValueIsArray

          public void assertValueIsArray(String responseContent)
                                  throws ParseException

      Apply the JSONPath and assert the resulting value is an array.
      Throws:
        `ParseException`

    - #### exists

          public void exists(String content)
                      throws ParseException

      Evaluate the JSON path and assert the resulting content exists.
      Throws:
        `ParseException`

    - #### doesNotExist

          public void doesNotExist(String content)
                            throws ParseException

      Evaluate the JSON path and assert it doesn't point to any content.
      Throws:
        `ParseException`