Interface HandlingResult


  • public interface HandlingResult
    Represents the result of testing one or more handlers.
    See Also:
    RequestFixture
    • Method Detail

      • getBodyBytes

        @Nullable
        byte[] getBodyBytes()
        The response body, as bytes.

        This does not include file or rendered responses. See getSentFile() and rendered(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() and rendered(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 modifying Response.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 to 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.

        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
      • 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 the Response.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, an AssertionError 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