public class JsonHelper extends Object
| Constructor and Description |
|---|
JsonHelper() |
| Modifier and Type | Method and Description |
|---|---|
static void |
configMapJsonKeyValues(io.restassured.response.Response response,
String keyValue)
map key value to config eg.features.features.id:1:<$id>
|
static String |
getJsonValue(io.restassured.response.Response response,
String path)
gets json value as list if applicable, or string if single item converts to
string separated by ","
|
static String |
getJsonValue(String json,
String path)
gets json value as list if applicable, or string if single item converts to
string separated by "," https://github.com/json-path/JsonPath
|
static String |
getJsonValueFromXml(String xml,
String path)
get json path value from xml string
|
static String |
getResponseValue(io.restassured.response.Response response) |
static boolean |
isJSONValid(String test,
boolean printError)
validates json string
|
static boolean |
isValidExpectation(String expectedJson) |
static String |
removeResponseIndicator(String expected)
remove response indicators
|
static void |
saveOutboundJsonParameters(io.restassured.response.Response response,
String outputParam)
replaces output parameter with response values eg.
|
static String |
validateByJsonBody(String expectedJson,
String response)
validates expected json string against json body from response
|
static List<String> |
validateByKeywords(String expectedJson,
io.restassured.response.Response response)
validates json response against hamcrest keywords
|
static List<String> |
validateJsonKeywords(List<KeyValue> keywords,
io.restassured.response.Response response)
validates the json maps against the keyword requirements examples:
"person.roles.name": hasItems("admin"), "person.lastName":
equalTo("Administrator"), "person.lastName": isNotEmpty, "person.roles.name":
contains("admin"), "person.roles.name": containsInAnyOrder(admin),
"person.roles": nodeSizeGreaterThan(0), "person.sites.": nodeSizeExact(0)
"person.roles.name": sequence("admin"),
|
static String |
validateResponseBody(String expected,
io.restassured.response.Response response)
validates response body this is validating the response body as text
|
static String |
XMLToJson(String xml)
convert xml string to json string
|
public static void saveOutboundJsonParameters(io.restassured.response.Response response,
String outputParam)
response - outputParam - public static void configMapJsonKeyValues(io.restassured.response.Response response,
String keyValue)
response - keyValue - public static String getJsonValue(io.restassured.response.Response response, String path)
response - path - public static String getJsonValue(String json, String path)
path - https://github.com/json-path/JsonPathpublic static String getJsonValueFromXml(String xml, String path)
xml - path - public static String XMLToJson(String xml)
xml - stringpublic static String getResponseValue(io.restassured.response.Response response)
public static List<String> validateJsonKeywords(List<KeyValue> keywords, io.restassured.response.Response response)
jsonMap - response - public static boolean isJSONValid(String test, boolean printError)
test - public static String validateByJsonBody(String expectedJson, String response)
expectedJson - actualJson - public static boolean isValidExpectation(String expectedJson)
public static List<String> validateByKeywords(String expectedJson, io.restassured.response.Response response)
expectedJson - response - public static String validateResponseBody(String expected, io.restassured.response.Response response)
expected - response - Copyright © 2019. All rights reserved.