|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ResponseBody
| Method Summary | ||
|---|---|---|
|
as(Class<T> cls)
Get the body and map it to a Java object. |
|
|
as(Class<T> cls,
ObjectMapper mapper)
Get the body and map it to a Java object using a specific object mapper. |
|
byte[] |
asByteArray()
Get the body as a byte array. |
|
InputStream |
asInputStream()
Get the body as an input stream. |
|
String |
asString()
Get the body as a string. |
|
JsonPath |
jsonPath()
Get a JsonPath view of the response body. |
|
|
path(String path)
Get a value from the response body using the JsonPath or XmlPath syntax. |
|
String |
print()
Print the response body and return it as string. |
|
XmlPath |
xmlPath()
Get an XmlPath view of the response body. |
|
| Method Detail |
|---|
String print()
String asString()
byte[] asByteArray()
InputStream asInputStream()
<T> T as(Class<T> cls)
as(Class, com.jayway.restassured.mapper.ObjectMapper).
<T> T as(Class<T> cls,
ObjectMapper mapper)
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");
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");
<T> T path(String path)
T - The return typepath - The json- or xml path
jsonPath(),
xmlPath()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||