Search in sources :

Example 1 with RequestInfoForLogging

use of com.nike.backstopper.handler.RequestInfoForLogging in project riposte by Nike-Inc.

the class RiposteUnhandledExceptionHandlerTest method handleErrorFromNettyInterfaceWrapsRequestInfoWithAdapterBeforeContinuing.

@Test
public void handleErrorFromNettyInterfaceWrapsRequestInfoWithAdapterBeforeContinuing() {
    com.nike.backstopper.handler.ErrorResponseInfo<ErrorResponseBody> backstopperResponse = new ErrorResponseInfo<>(42, mock(ErrorResponseBody.class), Collections.emptyMap());
    doReturn(backstopperResponse).when(adapterSpy).handleException(any(Throwable.class), any(RequestInfoForLogging.class));
    RequestInfo requestInfoMock = mock(RequestInfo.class);
    adapterSpy.handleError(new Exception(), requestInfoMock);
    ArgumentCaptor<RequestInfoForLogging> requestInfoForLoggingArgumentCaptor = ArgumentCaptor.forClass(RequestInfoForLogging.class);
    verify(adapterSpy).handleException(any(Throwable.class), requestInfoForLoggingArgumentCaptor.capture());
    RequestInfoForLogging passedArg = requestInfoForLoggingArgumentCaptor.getValue();
    assertThat(passedArg, instanceOf(RequestInfoForLoggingRiposteAdapter.class));
    RequestInfo embeddedRequestInfoInWrapper = (RequestInfo) Whitebox.getInternalState(passedArg, "request");
    assertThat(embeddedRequestInfoInWrapper, sameInstance(requestInfoMock));
}
Also used : ErrorResponseInfo(com.nike.backstopper.handler.ErrorResponseInfo) RequestInfoForLogging(com.nike.backstopper.handler.RequestInfoForLogging) ErrorResponseBody(com.nike.riposte.server.error.handler.ErrorResponseBody) RequestInfo(com.nike.riposte.server.http.RequestInfo) Test(org.junit.Test)

Example 2 with RequestInfoForLogging

use of com.nike.backstopper.handler.RequestInfoForLogging in project riposte by Nike-Inc.

the class RiposteApiExceptionHandlerTest method maybeHandleErrorFromNettyInterfaceWrapsRequestInfoWithAdapterBeforeContinuing.

@Test
public void maybeHandleErrorFromNettyInterfaceWrapsRequestInfoWithAdapterBeforeContinuing() throws UnexpectedMajorExceptionHandlingError, UnexpectedMajorErrorHandlingError {
    doReturn(null).when(adapterSpy).maybeHandleException(any(Throwable.class), any(RequestInfoForLogging.class));
    RequestInfo requestInfoMock = mock(RequestInfo.class);
    adapterSpy.maybeHandleError(new Exception(), requestInfoMock);
    ArgumentCaptor<RequestInfoForLogging> requestInfoForLoggingArgumentCaptor = ArgumentCaptor.forClass(RequestInfoForLogging.class);
    verify(adapterSpy).maybeHandleException(any(Throwable.class), requestInfoForLoggingArgumentCaptor.capture());
    RequestInfoForLogging passedArg = requestInfoForLoggingArgumentCaptor.getValue();
    assertThat(passedArg, instanceOf(RequestInfoForLoggingRiposteAdapter.class));
    RequestInfo embeddedRequestInfoInWrapper = (RequestInfo) Whitebox.getInternalState(passedArg, "request");
    assertThat(embeddedRequestInfoInWrapper, sameInstance(requestInfoMock));
}
Also used : RequestInfoForLogging(com.nike.backstopper.handler.RequestInfoForLogging) RequestInfo(com.nike.riposte.server.http.RequestInfo) Test(org.junit.Test)

Aggregations

RequestInfoForLogging (com.nike.backstopper.handler.RequestInfoForLogging)2 RequestInfo (com.nike.riposte.server.http.RequestInfo)2 Test (org.junit.Test)2 ErrorResponseInfo (com.nike.backstopper.handler.ErrorResponseInfo)1 ErrorResponseBody (com.nike.riposte.server.error.handler.ErrorResponseBody)1