Interface HandlingResult
-
public interface HandlingResult
Represents the result of testing one or more handlers.- See Also:
RequestFixture
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T extends Throwable>
Texception(Class<T> type)
The throwable thrown or given toContext.error(Throwable)
, unless a custom error handler is in use.byte[]
getBodyBytes()
The response body, as bytes.String
getBodyText()
The response body, interpreted as a utf8 string.Integer
getClientError()
The client error raised if any, unless a custom client error handler is in use.Set<io.netty.handler.codec.http.cookie.Cookie>
getCookies()
The cookies to be set as part of the response.Headers
getHeaders()
The final response headers.Registry
getRegistry()
The final state of the context registry.Registry
getRequestRegistry()
The final state of the request registry.Path
getSentFile()
Indicates whether the result of invoking the handler was that it invoked one of theResponse.sendFile(java.nio.file.Path)
methods.Status
getStatus()
The response status information.boolean
isCalledNext()
Indicates whether the result of invoking the handler was that it delegated to a downstream handler.boolean
isSentResponse()
Indicates the the handler(s) invoked one of theResponse.send()
methods.<T> T
rendered(Class<T> type)
The object that was rendered to the response.
-
-
-
Method Detail
-
getBodyBytes
@Nullable byte[] getBodyBytes()
The response body, as bytes.This does not include file or rendered responses. See
getSentFile()
andrendered(Class)
.- Returns:
- the response body, as bytes, or
null
if no response was sent.
-
getBodyText
@Nullable String getBodyText()
The response body, interpreted as a utf8 string.This does not include file or rendered responses. See
getSentFile()
andrendered(Class)
.- Returns:
- the response body, interpreted as a utf8 string, or
null
if no response was sent.
-
getCookies
@Nullable Set<io.netty.handler.codec.http.cookie.Cookie> getCookies()
The cookies to be set as part of the response.Cookies are set during request processing via the
Response.cookie(String, String)
method, or via directly modifyingResponse.getCookies()
.- Returns:
- the cookies to be set as part of the response
- Since:
- 1.3
-
getClientError
@Nullable Integer getClientError()
The client error raised if any, unless a custom client error handler is in use.If no client error was “raised”, will be
null
.If a custom client error handler is used (either by specification in the request fixture or insertion by an upstream handler), this will always be
null
. In such a case, this result effectively indicates what the custom client error handler did as its implementation.- Returns:
- the client error code, or
null
.
-
exception
<T extends Throwable> T exception(Class<T> type)
The throwable thrown or given toContext.error(Throwable)
, unless a custom error handler is in use.If no throwable was “raised”, a new
HandlerExceptionNotThrownException
is raised.If a custom error handler is used (either by specification in the request fixture or insertion by an upstream handler), this will always raise a new
HandlerExceptionNotThrownException
In such a case, this result effectively indicates what the custom error handler did as its implementation.- Type Parameters:
T
- The expected type of the exception captured.- Parameters:
type
- The expected type of the exception captured.- Returns:
- the “unhandled” throwable that occurred, or raise
HandlerExceptionNotThrownException
-
getHeaders
Headers getHeaders()
The final response headers.- Returns:
- the final response headers
-
getRegistry
Registry getRegistry()
The final state of the context registry.- Returns:
- the final state of the context registry
-
getRequestRegistry
Registry getRequestRegistry()
The final state of the request registry.- Returns:
- the final state of the reqest registry
-
getSentFile
@Nullable Path getSentFile()
Indicates whether the result of invoking the handler was that it invoked one of theResponse.sendFile(java.nio.file.Path)
methods.This does not include files rendered with
Context.render(Object)
.- Returns:
- the file given to one of the
Response.sendFile(java.nio.file.Path)
methods, ornull
if none of these methods were called
-
getStatus
Status getStatus()
The response status information.Indicates the state of the context's
Response.getStatus()
after invoking the handler. If the result is a sent response, this indicates the status of the response.- Returns:
- the response status
-
isCalledNext
boolean isCalledNext()
Indicates whether the result of invoking the handler was that it delegated to a downstream handler.- Returns:
- whether the handler delegated to a downstream handler
-
isSentResponse
boolean isSentResponse()
Indicates the the handler(s) invoked one of theResponse.send()
methods.- Returns:
- whether one of the
Response.send()
methods was invoked
-
rendered
@Nullable <T> T rendered(Class<T> type) throws AssertionError
The object that was rendered to the response.The exact object that was given to
Context.render(Object)
. The value must be assignment compatible with given type token. If it is not, anAssertionError
will be thrown.- Type Parameters:
T
- the expect type of the rendered object- Parameters:
type
- the expect type of the rendered object- Returns:
- the rendered object, or
null
if no object was rendered - Throws:
AssertionError
- if the rendered object cannot be cast to the given type
-
-