public class RestAssuredResponseOptionsImpl<R extends ResponseOptions<R>> extends Object implements ExtractableResponse<R>
Modifier and Type | Field and Description |
---|---|
protected RestAssuredResponseOptionsGroovyImpl |
groovyResponse |
Constructor and Description |
---|
RestAssuredResponseOptionsImpl() |
Modifier and Type | Method and Description |
---|---|
R |
andReturn() |
<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.
|
byte[] |
asByteArray()
Get the body as a byte array.
|
InputStream |
asInputStream()
Get the body as an input stream.
|
String |
asPrettyString()
Get the body as a pretty formatted string.
|
String |
asString()
Get the body as a string.
|
String |
asString(boolean forcePlatformDefaultCharsetIfNoCharsetIsSpecifiedInResponse) |
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() |
RestAssuredConfig |
getConfig() |
Object |
getConnectionManager() |
Object |
getContent() |
String |
getContentType() |
String |
getCookie(String name) |
Map<String,String> |
getCookies() |
DecoderConfig |
getDecoderConfig() |
String |
getDefaultContentType() |
Cookie |
getDetailedCookie(String name) |
Cookies |
getDetailedCookies() |
Map |
getFilterContextProperties() |
RestAssuredResponseOptionsGroovyImpl |
getGroovyResponse() |
boolean |
getHasExpectations() |
String |
getHeader(String name) |
Headers |
getHeaders() |
LogRepository |
getLogRepository() |
Object |
getResponseHeaders() |
ResponseParserRegistrar |
getRpr() |
String |
getSessionId() |
Object |
getSessionIdName() |
int |
getStatusCode() |
String |
getStatusLine() |
long |
getTime() |
long |
getTimeIn(TimeUnit timeUnit) |
String |
header(String name)
Get a single header value associated with the given name.
|
Headers |
headers()
The response headers.
|
io.restassured.path.xml.XmlPath |
htmlPath()
Get an XmlPath view of the response body that uses
XmlPath.CompatibilityMode HTML . |
boolean |
isInputStream() |
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.
|
R |
peek() |
R |
prettyPeek() |
String |
prettyPrint() |
String |
print() |
R |
response() |
String |
sessionId()
Get the session id from the response.
|
void |
setConfig(RestAssuredConfig config) |
void |
setConnectionManager(Object connectionManager) |
void |
setContent(Object content) |
void |
setContentType(Object contentType) |
void |
setCookies(Cookies cookies) |
void |
setDecoderConfig(DecoderConfig decoderConfig) |
void |
setDefaultContentType(String defaultContentType) |
void |
setFilterContextProperties(Map filterContextProperties) |
void |
setGroovyResponse(RestAssuredResponseOptionsGroovyImpl groovyResponse) |
void |
setHasExpectations(boolean hasExpectations) |
void |
setLogRepository(LogRepository logRepository) |
void |
setResponseHeaders(Object responseHeaders) |
void |
setRpr(ResponseParserRegistrar rpr) |
void |
setSessionIdName(Object sessionIdName) |
void |
setStatusCode(Object statusCode) |
void |
setStatusLine(Object statusLine) |
int |
statusCode()
Get the status code of the response.
|
String |
statusLine()
Get the status line of the response.
|
R |
thenReturn() |
long |
time() |
long |
timeIn(TimeUnit timeUnit) |
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.
|
protected RestAssuredResponseOptionsGroovyImpl groovyResponse
public void setResponseHeaders(Object responseHeaders)
public void setCookies(Cookies cookies)
public void setContent(Object content)
public void setContentType(Object contentType)
public void setStatusLine(Object statusLine)
public void setStatusCode(Object statusCode)
public void setSessionIdName(Object sessionIdName)
public void setFilterContextProperties(Map filterContextProperties)
public void setConnectionManager(Object connectionManager)
public void setDefaultContentType(String defaultContentType)
public void setRpr(ResponseParserRegistrar rpr)
public void setDecoderConfig(DecoderConfig decoderConfig)
public void setHasExpectations(boolean hasExpectations)
public void setConfig(RestAssuredConfig config)
public ResponseParserRegistrar getRpr()
public RestAssuredConfig getConfig()
public ResponseBody body()
ExtractableResponse
body
in interface ExtractableResponse<R extends ResponseOptions<R>>
public Headers headers()
ExtractableResponse
headers
in interface ExtractableResponse<R extends ResponseOptions<R>>
public String header(String name)
ExtractableResponse
Headers.getList(String)
in order to get all values.header
in interface ExtractableResponse<R extends ResponseOptions<R>>
null
if value was not found.public Map<String,String> cookies()
ExtractableResponse
ExtractableResponse.detailedCookies()
.cookies
in interface ExtractableResponse<R extends ResponseOptions<R>>
public Cookies detailedCookies()
ExtractableResponse
detailedCookies
in interface ExtractableResponse<R extends ResponseOptions<R>>
public String cookie(String name)
ExtractableResponse
ExtractableResponse.detailedCookie(String)
.cookie
in interface ExtractableResponse<R extends ResponseOptions<R>>
null
if value was not found.public Cookie detailedCookie(String name)
ExtractableResponse
detailedCookie
in interface ExtractableResponse<R extends ResponseOptions<R>>
null
if value was not found.public String contentType()
ExtractableResponse
contentType
in interface ExtractableResponse<R extends ResponseOptions<R>>
null
if not found.public String statusLine()
ExtractableResponse
statusLine
in interface ExtractableResponse<R extends ResponseOptions<R>>
public String sessionId()
ExtractableResponse
SessionConfig
.sessionId
in interface ExtractableResponse<R extends ResponseOptions<R>>
null
if not defined.public int statusCode()
ExtractableResponse
statusCode
in interface ExtractableResponse<R extends ResponseOptions<R>>
public R response()
response
in interface ExtractableResponse<R extends ResponseOptions<R>>
public <T> T as(Class<T> cls)
ResponseBodyExtractionOptions
ResponseBodyExtractionOptions.as(Class, ObjectMapper)
.as
in interface ResponseBodyExtractionOptions
public <T> T as(Class<T> cls, ObjectMapperType mapperType)
ResponseBodyExtractionOptions
as
in interface ResponseBodyExtractionOptions
public <T> T as(Class<T> cls, ObjectMapper mapper)
ResponseBodyExtractionOptions
as
in interface ResponseBodyExtractionOptions
public <T> T as(io.restassured.common.mapper.TypeRef<T> typeRef)
ResponseBodyExtractionOptions
as
in interface ResponseBodyExtractionOptions
public <T> T as(Type cls)
ResponseBodyExtractionOptions
ResponseBodyExtractionOptions.as(Type, ObjectMapper)
.as
in interface ResponseBodyExtractionOptions
public <T> T as(Type cls, ObjectMapperType mapperType)
ResponseBodyExtractionOptions
as
in interface ResponseBodyExtractionOptions
public <T> T as(Type cls, ObjectMapper mapper)
ResponseBodyExtractionOptions
as
in interface ResponseBodyExtractionOptions
public io.restassured.path.json.JsonPath jsonPath()
ResponseBodyExtractionOptions
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");
jsonPath
in interface ResponseBodyExtractionOptions
public io.restassured.path.json.JsonPath jsonPath(io.restassured.path.json.config.JsonPathConfig config)
ResponseBodyExtractionOptions
jsonPath
in interface ResponseBodyExtractionOptions
config
- The configuration to useResponseBodyExtractionOptions.jsonPath()
public io.restassured.path.xml.XmlPath xmlPath()
ResponseBodyExtractionOptions
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 ResponseBodyExtractionOptions
public io.restassured.path.xml.XmlPath xmlPath(io.restassured.path.xml.config.XmlPathConfig config)
ResponseBodyExtractionOptions
xmlPath
in interface ResponseBodyExtractionOptions
config
- The configuration of the XmlPathResponseBodyExtractionOptions.xmlPath()
public io.restassured.path.xml.XmlPath xmlPath(io.restassured.path.xml.XmlPath.CompatibilityMode compatibilityMode)
ResponseBodyExtractionOptions
XmlPath.CompatibilityMode
.
This is mainly useful if you want to parse HTML documents.xmlPath
in interface ResponseBodyExtractionOptions
compatibilityMode
- The compatibility mode to useResponseBodyExtractionOptions.htmlPath()
,
ResponseBodyExtractionOptions.xmlPath()
public io.restassured.path.xml.XmlPath htmlPath()
ResponseBodyExtractionOptions
XmlPath.CompatibilityMode
HTML
.
This is mainly useful when parsing HTML documents.
Note that this is the same as calling ResponseBodyExtractionOptions.xmlPath(XmlPath.CompatibilityMode)
with CompatibilityMode
HTML
.
htmlPath
in interface ResponseBodyExtractionOptions
public <T> T path(String path, String... arguments)
ResponseBodyExtractionOptions
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.
path
in interface ResponseBodyExtractionOptions
T
- The return typepath
- The json- or xml patharguments
- Options argumentsResponseBodyExtractionOptions.jsonPath()
,
ResponseBodyExtractionOptions.xmlPath()
public String asString()
ResponseBodyData
asString
in interface ResponseBodyData
public String asString(boolean forcePlatformDefaultCharsetIfNoCharsetIsSpecifiedInResponse)
public String asPrettyString()
ResponseBodyData
asPrettyString
in interface ResponseBodyData
public byte[] asByteArray()
ResponseBodyData
asByteArray
in interface ResponseBodyData
public InputStream asInputStream()
ResponseBodyData
asInputStream
in interface ResponseBodyData
public boolean isInputStream()
public String print()
public String prettyPrint()
public R peek()
public R prettyPeek()
public R andReturn()
public R thenReturn()
public ResponseBody getBody()
public Headers getHeaders()
public Cookies getDetailedCookies()
public String getSessionId()
public String getContentType()
public String getStatusLine()
public int getStatusCode()
public Object getContent()
public boolean getHasExpectations()
public String getDefaultContentType()
public DecoderConfig getDecoderConfig()
public Object getSessionIdName()
public Object getConnectionManager()
public Object getResponseHeaders()
public LogRepository getLogRepository()
public void setLogRepository(LogRepository logRepository)
public RestAssuredResponseOptionsGroovyImpl getGroovyResponse()
public Map getFilterContextProperties()
public void setGroovyResponse(RestAssuredResponseOptionsGroovyImpl groovyResponse)
public long time()
time
in interface ExtractableResponse<R extends ResponseOptions<R>>
public long timeIn(TimeUnit timeUnit)
timeIn
in interface ExtractableResponse<R extends ResponseOptions<R>>
public long getTime()
public long getTimeIn(TimeUnit timeUnit)
Copyright © 2010–2020. All rights reserved.