Search in sources :

Example 6 with ErrorResponseInfo

use of com.nike.riposte.server.error.handler.ErrorResponseInfo in project riposte by Nike-Inc.

the class ExceptionHandlingHandlerTest method setupResponseInfoBasedOnErrorResponseInfo_sets_response_content_and_httpStatusCode_and_ignores_extra_headers_if_extra_headers_is_null.

@Test
public void setupResponseInfoBasedOnErrorResponseInfo_sets_response_content_and_httpStatusCode_and_ignores_extra_headers_if_extra_headers_is_null() {
    // given
    ResponseInfo<ErrorResponseBody> responseInfo = new FullResponseInfo<>();
    ErrorResponseBody errorResponseBodyMock = mock(ErrorResponseBody.class);
    int httpStatusCode = 42;
    ErrorResponseInfo errorInfoMock = mock(ErrorResponseInfo.class);
    doReturn(errorResponseBodyMock).when(errorInfoMock).getErrorResponseBody();
    doReturn(httpStatusCode).when(errorInfoMock).getErrorHttpStatusCode();
    doReturn(null).when(errorInfoMock).getExtraHeadersToAddToResponse();
    // when
    handler.setupResponseInfoBasedOnErrorResponseInfo(responseInfo, errorInfoMock);
    // then
    assertThat(responseInfo.getContentForFullResponse(), is(errorResponseBodyMock));
    assertThat(responseInfo.getHttpStatusCode(), is(httpStatusCode));
    assertThat(responseInfo.getHeaders().entries().size(), is(0));
}
Also used : ErrorResponseInfo(com.nike.riposte.server.error.handler.ErrorResponseInfo) ErrorResponseBody(com.nike.riposte.server.error.handler.ErrorResponseBody) FullResponseInfo(com.nike.riposte.server.http.impl.FullResponseInfo) Test(org.junit.Test)

Aggregations

ErrorResponseBody (com.nike.riposte.server.error.handler.ErrorResponseBody)6 ErrorResponseInfo (com.nike.riposte.server.error.handler.ErrorResponseInfo)6 FullResponseInfo (com.nike.riposte.server.http.impl.FullResponseInfo)6 Test (org.junit.Test)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 IncompleteHttpCallTimeoutException (com.nike.riposte.server.error.exception.IncompleteHttpCallTimeoutException)3 TooManyOpenChannelsException (com.nike.riposte.server.error.exception.TooManyOpenChannelsException)3 HttpProcessingState (com.nike.riposte.server.http.HttpProcessingState)3 ResponseInfo (com.nike.riposte.server.http.ResponseInfo)3 RiposteErrorHandler (com.nike.riposte.server.error.handler.RiposteErrorHandler)2 ChannelAttributes (com.nike.riposte.server.channelpipeline.ChannelAttributes)1 UnexpectedMajorErrorHandlingError (com.nike.riposte.server.error.exception.UnexpectedMajorErrorHandlingError)1 RiposteUnhandledErrorHandler (com.nike.riposte.server.error.handler.RiposteUnhandledErrorHandler)1 PipelineContinuationBehavior (com.nike.riposte.server.handler.base.PipelineContinuationBehavior)1 DO_NOT_FIRE_CONTINUE_EVENT (com.nike.riposte.server.handler.base.PipelineContinuationBehavior.DO_NOT_FIRE_CONTINUE_EVENT)1 RequestInfo (com.nike.riposte.server.http.RequestInfo)1 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)1 DataProviderRunner (com.tngtech.java.junit.dataprovider.DataProviderRunner)1 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)1 Channel (io.netty.channel.Channel)1