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