|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jayway.restassured.internal.RestAssuredResponseImpl
public class RestAssuredResponseImpl
| Constructor Summary | |
|---|---|
RestAssuredResponseImpl()
|
|
| Method Summary | ||
|---|---|---|
Response |
andReturn()
Syntactic sugar, simply returns the same response instance. |
|
|
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. |
|
ResponseBody |
body()
Returns the response body |
|
String |
contentType()
Get the content type of the response |
|
String |
cookie(String name)
Get a single cookie value associated with the given name. |
|
Map<String,String> |
cookies()
The response cookies as simple name/value pair. |
|
Cookie |
detailedCookie(String name)
Get a single cookie including all attributes associated with the given name. |
|
Cookies |
detailedCookies()
The response cookies with all the attributes. |
|
ResponseBody |
getBody()
Returns the response body |
|
Object |
getConnectionManager()
|
|
Object |
getContent()
|
|
String |
getContentType()
Get the content type of the response |
|
String |
getCookie(String name)
Get a single cookie value associated with the given name. |
|
Map<String,String> |
getCookies()
The response cookies as simple name/value pair. |
|
String |
getDefaultCharset()
|
|
String |
getDefaultContentType()
|
|
Cookie |
getDetailedCookie(String name)
Get a single cookie including all attributes associated with the given name. |
|
Cookies |
getDetailedCookies()
The response cookies with all the attributes. |
|
boolean |
getHasExpectations()
|
|
String |
getHeader(String name)
Get a single header value associated with the given name. |
|
Headers |
getHeaders()
The response headers. |
|
groovy.lang.MetaClass |
getMetaClass()
|
|
Object |
getProperty(String property)
|
|
Object |
getResponseHeaders()
|
|
ResponseParserRegistrar |
getRpr()
|
|
String |
getSessionId()
Get the session id from the response. |
|
Object |
getSessionIdName()
|
|
int |
getStatusCode()
Get the status code of the response. |
|
String |
getStatusLine()
Get the status line of the response. |
|
String |
header(String name)
Get a single header value associated with the given name. |
|
Headers |
headers()
The response headers. |
|
Object |
invokeMethod(String method,
Object arguments)
|
|
boolean |
isHasExpectations()
|
|
JsonPath |
jsonPath()
Get a JsonPath view of the response body. |
|
Object |
parseContentType(Object httpResponse)
|
|
Object |
parseCookies()
|
|
Object |
parseHeaders(Object httpResponse)
|
|
void |
parseResponse(Object httpResponse,
Object content,
Object hasBodyAssertions,
ResponseParserRegistrar responseParserRegistrar)
|
|
Object |
parseStatus(Object httpResponse)
|
|
|
path(String path)
Get a value from the response body using the JsonPath or XmlPath syntax. |
|
String |
prettyPrint()
Pretty-print the response body if possible and return it as string. |
|
String |
print()
Print the response body and return it as string. |
|
String |
sessionId()
Get the session id from the response. |
|
void |
setConnectionManager(Object value)
|
|
void |
setContent(Object value)
|
|
void |
setContentType(Object value)
|
|
void |
setCookies(Cookies value)
|
|
void |
setDefaultCharset(String value)
|
|
void |
setDefaultContentType(String value)
|
|
void |
setHasExpectations(boolean value)
|
|
void |
setMetaClass(groovy.lang.MetaClass mc)
|
|
void |
setProperty(String property,
Object value)
|
|
void |
setResponseHeaders(Object value)
|
|
void |
setRpr(ResponseParserRegistrar value)
|
|
void |
setSessionIdName(Object value)
|
|
void |
setStatusCode(Object value)
|
|
void |
setStatusLine(Object value)
|
|
int |
statusCode()
Get the status code of the response. |
|
String |
statusLine()
Get the status line of the response. |
|
Response |
thenReturn()
Syntactic sugar, simply returns the same response instance. |
|
Object |
toString(groovy.lang.Writable node)
|
|
XmlPath |
xmlPath()
Get an XmlPath view of the response body. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RestAssuredResponseImpl()
| Method Detail |
|---|
public groovy.lang.MetaClass getMetaClass()
getMetaClass in interface groovy.lang.GroovyObjectpublic void setMetaClass(groovy.lang.MetaClass mc)
setMetaClass in interface groovy.lang.GroovyObject
public Object invokeMethod(String method,
Object arguments)
invokeMethod in interface groovy.lang.GroovyObjectpublic Object getProperty(String property)
getProperty in interface groovy.lang.GroovyObject
public void setProperty(String property,
Object value)
setProperty in interface groovy.lang.GroovyObjectpublic Object getResponseHeaders()
public void setResponseHeaders(Object value)
public void setCookies(Cookies value)
public Object getContent()
public void setContent(Object value)
public void setContentType(Object value)
public void setStatusLine(Object value)
public void setStatusCode(Object value)
public Object getSessionIdName()
public void setSessionIdName(Object value)
public Object getConnectionManager()
public void setConnectionManager(Object value)
public String getDefaultContentType()
public void setDefaultContentType(String value)
public ResponseParserRegistrar getRpr()
public void setRpr(ResponseParserRegistrar value)
public String getDefaultCharset()
public void setDefaultCharset(String value)
public boolean getHasExpectations()
public boolean isHasExpectations()
public void setHasExpectations(boolean value)
public void parseResponse(Object httpResponse,
Object content,
Object hasBodyAssertions,
ResponseParserRegistrar responseParserRegistrar)
public Object parseStatus(Object httpResponse)
public Object parseContentType(Object httpResponse)
public Object parseCookies()
public Object parseHeaders(Object httpResponse)
public Object toString(groovy.lang.Writable node)
public String print()
ResponseBody
print in interface ResponseBodypublic String prettyPrint()
ResponseBody
prettyPrint in interface ResponseBodypublic String asString()
ResponseBody
asString in interface ResponseBodypublic InputStream asInputStream()
ResponseBody
asInputStream in interface ResponseBodypublic byte[] asByteArray()
ResponseBody
asByteArray in interface ResponseBodypublic <T> T as(Class<T> cls)
ResponseBodyResponseBody.as(Class, com.jayway.restassured.mapper.ObjectMapper).
as in interface ResponseBody
public <T> T as(Class<T> cls,
ObjectMapper mapper)
ResponseBody
as in interface ResponseBodypublic Cookies detailedCookies()
Response
detailedCookies in interface Responsepublic Cookies getDetailedCookies()
Response
getDetailedCookies in interface Responsepublic Cookie detailedCookie(String name)
Response
detailedCookie in interface Responsenull if value was not found.public Cookie getDetailedCookie(String name)
Response
getDetailedCookie in interface Responsenull if value was not found.public Response andReturn()
Response
andReturn in interface Responsepublic ResponseBody body()
Response
body in interface Responsepublic Response thenReturn()
Response
thenReturn in interface Responsepublic ResponseBody getBody()
Response
getBody in interface Responsepublic Headers headers()
Response
headers in interface Responsepublic Headers getHeaders()
Response
getHeaders in interface Responsepublic String header(String name)
ResponseHeaders.getList(String) in order to get all values.
header in interface Responsenull if value was not found.public String getHeader(String name)
ResponseHeaders.getList(String) in order to get all values..
getHeader in interface Responsenull if value was not found.public Map<String,String> cookies()
ResponseResponse.detailedCookies().
cookies in interface Responsepublic Map<String,String> getCookies()
ResponseResponse.getDetailedCookies().
getCookies in interface Responsepublic String cookie(String name)
ResponseResponse.detailedCookie(String).
cookie in interface Responsenull if value was not found.public String getCookie(String name)
ResponseResponse.getDetailedCookie(String).
getCookie in interface Responsenull if value was not found.public String contentType()
Response
contentType in interface Responsenull if not found.public String getContentType()
Response
getContentType in interface Responsenull if not found.public String statusLine()
Response
statusLine in interface Responsepublic int statusCode()
Response
statusCode in interface Responsepublic String getStatusLine()
Response
getStatusLine in interface Responsepublic String sessionId()
ResponseSessionConfig.
sessionId in interface Responsenull if not defined.public String getSessionId()
ResponseSessionConfig.
getSessionId in interface Responsenull if not defined.public int getStatusCode()
Response
getStatusCode in interface Responsepublic JsonPath jsonPath()
ResponseBodyAssume 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");
jsonPath in interface ResponseBodypublic XmlPath xmlPath()
ResponseBody
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");
xmlPath in interface ResponseBodypublic <T> T path(String path)
ResponseBody
path in interface ResponseBodyT - The return typepath - The json- or xml path
ResponseBody.jsonPath(),
ResponseBody.xmlPath()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||