Class JsonFixture


  • @ProviderType
    public final class JsonFixture
    extends Object
    A wrapper for JSON payload and JSON path operations which create a new JsonFixture object.
    • Constructor Detail

      • JsonFixture

        public JsonFixture​(InputStream input)
        Parameters:
        input - The payload input stream
    • Method Detail

      • add

        public JsonFixture add​(String path,
                               Object value,
                               com.jayway.jsonpath.Predicate... filters)
        Adds the value to array at the given path.
        Parameters:
        path - The JSON path
        value - The value to add
        filters - Optional JSON path filters
        Returns:
        The new JSON fixture
      • delete

        public JsonFixture delete​(String path,
                                  com.jayway.jsonpath.Predicate... filters)
        Deletes JSON nodes at the given path.
        Parameters:
        path - The JSON path
        filters - Optional JSON path filters
        Returns:
        The new JSON fixture
      • put

        public JsonFixture put​(String path,
                               String key,
                               Object value,
                               com.jayway.jsonpath.Predicate... filters)
        Adds or updates the value for a given key on the given path.
        Parameters:
        path - The JSON path
        key - The JSON object key
        value - The new value
        filters - Optional JSON path filters
        Returns:
        The new JSON fixture
      • read

        public JsonFixture read​(String path,
                                com.jayway.jsonpath.Predicate... filters)
        Extracts the JSON node elements at the given path.
        Parameters:
        path - The JSON path
        filters - Optional JSON path filters
        Returns:
        The new JSON fixture
      • set

        public JsonFixture set​(String path,
                               Object value,
                               com.jayway.jsonpath.Predicate... filters)
        Sets a new value at the given path.
        Parameters:
        path - The JSON path
        value - The new value
        filters - Optional JSON path filters
        Returns:
        The new JSON fixture
      • toJsonNode

        public com.fasterxml.jackson.databind.JsonNode toJsonNode()
        Returns:
        The JsonNode representation for the payload