Package io.wcm.caravan.testing.json
Class JsonFixture
- java.lang.Object
-
- io.wcm.caravan.testing.json.JsonFixture
-
@ProviderType public final class JsonFixture extends Object
A wrapper for JSON payload and JSON path operations which create a newJsonFixture
object.
-
-
Constructor Summary
Constructors Constructor Description JsonFixture(InputStream input)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonFixture
add(String path, Object value, com.jayway.jsonpath.Predicate... filters)
Adds the value to array at the given path.JsonFixture
delete(String path, com.jayway.jsonpath.Predicate... filters)
Deletes JSON nodes at the given path.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.JsonFixture
read(String path, com.jayway.jsonpath.Predicate... filters)
Extracts the JSON node elements at the given path.JsonFixture
set(String path, Object value, com.jayway.jsonpath.Predicate... filters)
Sets a new value at the given path.com.fasterxml.jackson.databind.JsonNode
toJsonNode()
String
toString()
-
-
-
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 pathvalue
- The value to addfilters
- 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 pathfilters
- 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 pathkey
- The JSON object keyvalue
- The new valuefilters
- 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 pathfilters
- 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 pathvalue
- The new valuefilters
- Optional JSON path filters- Returns:
- The new JSON fixture
-
toJsonNode
public com.fasterxml.jackson.databind.JsonNode toJsonNode()
- Returns:
- The JsonNode representation for the payload
-
-