public interface ResponseBodyExtractionOptions extends ResponseBodyData
| Modifier and Type | Method and Description |
|---|---|
<T> T |
as(Class<T> cls)
Get the body and map it to a Java object.
|
<T> T |
as(Class<T> cls,
ObjectMapper mapper)
Get the body and map it to a Java object using a specific object mapper.
|
<T> T |
as(Class<T> cls,
ObjectMapperType mapperType)
Get the body and map it to a Java object using a specific object mapper type.
|
<T> T |
as(Type cls)
Get the body and map it to a Java type with specified type.
|
<T> T |
as(Type cls,
ObjectMapper mapper)
Get the body and map it to a Java type using a specific object mapper.
|
<T> T |
as(Type cls,
ObjectMapperType mapperType)
Get the body and map it to a Java type with specified type using a specific object mapper type.
|
<T> T |
as(io.restassured.common.mapper.TypeRef<T> typeRef)
Get the body as a container with a generic type.
|
io.restassured.path.xml.XmlPath |
htmlPath()
Get an XmlPath view of the response body that uses
XmlPath.CompatibilityMode HTML. |
io.restassured.path.json.JsonPath |
jsonPath()
Get a JsonPath view of the response body.
|
io.restassured.path.json.JsonPath |
jsonPath(io.restassured.path.json.config.JsonPathConfig config)
Get a JsonPath view of the response body using the specified configuration.
|
<T> T |
path(String path,
String... arguments)
Get a value from the response body using the JsonPath or XmlPath syntax.
|
io.restassured.path.xml.XmlPath |
xmlPath()
Get an XmlPath view of the response body.
|
io.restassured.path.xml.XmlPath |
xmlPath(io.restassured.path.xml.XmlPath.CompatibilityMode compatibilityMode)
Get an XmlPath view of the response body but also pass in a
XmlPath.CompatibilityMode. |
io.restassured.path.xml.XmlPath |
xmlPath(io.restassured.path.xml.config.XmlPathConfig config)
Get an XmlPath view of the response body with a given configuration.
|
asByteArray, asInputStream, asPrettyString, asString<T> T as(Class<T> cls)
as(Class, ObjectMapper).<T> T as(Class<T> cls, ObjectMapperType mapperType)
<T> T as(Class<T> cls, ObjectMapper mapper)
<T> T as(io.restassured.common.mapper.TypeRef<T> typeRef)
<T> T as(Type cls)
as(Type, ObjectMapper).<T> T as(Type cls, ObjectMapperType mapperType)
<T> T as(Type cls, ObjectMapper mapper)
io.restassured.path.json.JsonPath jsonPath()
Assume that the GET request (to http://localhost:8080/lotto) returns JSON as:
{
"lotto":{
"lottoId":5,
"winning-numbers":[2,45,34,23,7,5,3],
"winners":[{
"winnerId":23,
"numbers":[2,45,34,23,3,5]
},{
"winnerId":54,
"numbers":[52,3,12,11,18,22]
}]
}
}
You can the make the request and get the winner id's by using JsonPath:
ListwinnerIds = get("/lotto").jsonPath().getList("lotto.winnders.winnerId");
io.restassured.path.json.JsonPath jsonPath(io.restassured.path.json.config.JsonPathConfig config)
config - The configuration to usejsonPath()io.restassured.path.xml.XmlPath xmlPath()
Imagine that a POST request to http://localhost:8080/greetXML returns:
<greeting>
<firstName>John</firstName>
<lastName>Doe</lastName>
</greeting>
String firstName = get("/greetXML").xmlPath().getString("greeting.firstName");
io.restassured.path.xml.XmlPath xmlPath(io.restassured.path.xml.config.XmlPathConfig config)
config - The configuration of the XmlPathxmlPath()io.restassured.path.xml.XmlPath xmlPath(io.restassured.path.xml.XmlPath.CompatibilityMode compatibilityMode)
XmlPath.CompatibilityMode.
This is mainly useful if you want to parse HTML documents.compatibilityMode - The compatibility mode to usehtmlPath(),
xmlPath()io.restassured.path.xml.XmlPath htmlPath()
XmlPath.CompatibilityMode HTML.
This is mainly useful when parsing HTML documents.
Note that this is the same as calling xmlPath(XmlPath.CompatibilityMode) with CompatibilityMode HTML.
<T> T path(String path, String... arguments)
Note that you can also also supply arguments, for example:
String z = get("/x").path("x.y.%s", "z");
The path and arguments follows the standard formatting syntax of Java.
T - The return typepath - The json- or xml patharguments - Options argumentsjsonPath(),
xmlPath()Copyright © 2010–2020. All rights reserved.