public interface HandlingResult
RequestFixture
Modifier and Type | Method and Description |
---|---|
<T extends Throwable> |
exception(Class<T> type)
The throwable thrown or given to
Context.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.
|
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 the
Response.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 the
Response.send() methods. |
<T> T |
rendered(Class<T> type)
The object that was rendered to the response.
|
@Nullable byte[] getBodyBytes()
This does not include file or rendered responses.
See getSentFile()
and rendered(Class)
.
null
if no response was sent.@Nullable String getBodyText()
This does not include file or rendered responses.
See getSentFile()
and rendered(Class)
.
null
if no response was sent.@Nullable Integer getClientError()
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.
null
.@Nullable <T extends Throwable> T exception(Class<T> type)
Context.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.
T
- The expected type of the exception captured.type
- The expected type of the exception captured.HandlerExceptionNotThrownException
Headers getHeaders()
Registry getRegistry()
Registry getRequestRegistry()
@Nullable Path getSentFile()
Response.sendFile(java.nio.file.Path)
methods.
This does not include files rendered with Context.render(Object)
.
Response.sendFile(java.nio.file.Path)
methods, or null
if none of these methods were calledStatus getStatus()
Indicates the state of the context's ResponseMetaData.getStatus()
after invoking the handler.
If the result is a sent response, this indicates the status of the response.
boolean isCalledNext()
boolean isSentResponse()
Response.send()
methods.Response.send()
methods was invoked@Nullable <T> T rendered(Class<T> type) throws AssertionError
The exact object that was given to Context.render(Object)
.
The value must be assignment compatible with given type token.
If it is not, an AssertionError
will be thrown.
T
- the expect type of the rendered objecttype
- the expect type of the rendered objectnull
if no object was renderedAssertionError
- if the rendered object cannot be cast to the given type