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));
}
Aggregations