Java Code Examples for com.nike.backstopper.handler.ApiExceptionHandlerUtils#DEFAULT_IMPL

The following examples show how to use com.nike.backstopper.handler.ApiExceptionHandlerUtils#DEFAULT_IMPL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JaxRsApiExceptionHandlerTest.java    From backstopper with Apache License 2.0 6 votes vote down vote up
@Before
public void beforeMethod() {
    HttpServletRequest mockRequest = mock(HttpServletRequest.class);
    when(mockRequest.getRequestURI()).thenReturn("/fake/path");
    when(mockRequest.getMethod()).thenReturn("GET");
    when(mockRequest.getQueryString()).thenReturn("queryString");

    listenerList = new JaxRsApiExceptionHandlerListenerList(testProjectApiErrors, ApiExceptionHandlerUtils.DEFAULT_IMPL);

    unhandledSpy = spy(new JaxRsUnhandledExceptionHandler(testProjectApiErrors, ApiExceptionHandlerUtils.DEFAULT_IMPL));

    handlerSpy = spy(new JaxRsApiExceptionHandler(
        testProjectApiErrors,
        listenerList,
        ApiExceptionHandlerUtils.DEFAULT_IMPL, unhandledSpy));
    Whitebox.setInternalState(handlerSpy, "request", mockRequest);
    Whitebox.setInternalState(handlerSpy, "response", mock(HttpServletResponse.class));
}
 
Example 2
Source File: SpringApiExceptionHandlerTest.java    From backstopper with Apache License 2.0 5 votes vote down vote up
@Before
public void beforeMethod() {
    projectApiErrorsMock = mock(ProjectApiErrors.class);
    listenerList = new ApiExceptionHandlerListenerList(Collections.<ApiExceptionHandlerListener>emptyList());
    generalUtils = ApiExceptionHandlerUtils.DEFAULT_IMPL;
    springUtils = SpringApiExceptionHandlerUtils.DEFAULT_IMPL;
    handlerSpy = spy(new SpringApiExceptionHandler(projectApiErrorsMock, listenerList, generalUtils, springUtils));
}
 
Example 3
Source File: SpringUnhandledExceptionHandlerTest.java    From backstopper with Apache License 2.0 5 votes vote down vote up
@Before
public void beforeMethod() {
    springUtilsSpy = spy(SpringApiExceptionHandlerUtils.DEFAULT_IMPL);
    generalUtils = ApiExceptionHandlerUtils.DEFAULT_IMPL;
    testProjectApiErrors = ProjectApiErrorsForTesting.withProjectSpecificData(null, null);
    handlerSpy = spy(new SpringUnhandledExceptionHandler(testProjectApiErrors, generalUtils, springUtilsSpy));
}
 
Example 4
Source File: SpringWebfluxApiExceptionHandlerTest.java    From backstopper with Apache License 2.0 5 votes vote down vote up
@Before
public void beforeMethod() {
    projectApiErrorsMock = mock(ProjectApiErrors.class);
    listenerList = new SpringWebFluxApiExceptionHandlerListenerList(
        Arrays.asList(mock(ApiExceptionHandlerListener.class), mock(ApiExceptionHandlerListener.class))
    );
    generalUtils = ApiExceptionHandlerUtils.DEFAULT_IMPL;
    springUtilsMock = mock(SpringWebfluxApiExceptionHandlerUtils.class);
    viewResolversProviderMock = mock(ObjectProvider.class);
    serverCodecConfigurerMock = mock(ServerCodecConfigurer.class);
    messageReaders = Arrays.asList(mock(HttpMessageReader.class), mock(HttpMessageReader.class));
    messageWriters = Arrays.asList(mock(HttpMessageWriter.class), mock(HttpMessageWriter.class));
    viewResolvers = Arrays.asList(mock(ViewResolver.class), mock(ViewResolver.class));
    serverWebExchangeMock = mock(ServerWebExchange.class);
    serverHttpRequestMock = mock(ServerHttpRequest.class);
    serverHttpResponseMock = mock(ServerHttpResponse.class);
    serverHttpResponseHeadersMock = mock(HttpHeaders.class);
    uri = URI.create("http://localhost:8080/foo/bar?someQuery=someValue");
    exMock = mock(Throwable.class);

    doAnswer(invocation -> viewResolvers.stream()).when(viewResolversProviderMock).orderedStream();
    doReturn(messageReaders).when(serverCodecConfigurerMock).getReaders();
    doReturn(messageWriters).when(serverCodecConfigurerMock).getWriters();

    doReturn(serverHttpRequestMock).when(serverWebExchangeMock).getRequest();
    doReturn(uri).when(serverHttpRequestMock).getURI();

    doReturn(serverHttpResponseMock).when(serverWebExchangeMock).getResponse();
    doReturn(serverHttpResponseHeadersMock).when(serverHttpResponseMock).getHeaders();

    handlerSpy = spy(new SpringWebfluxApiExceptionHandler(
        projectApiErrorsMock, listenerList, generalUtils, springUtilsMock, viewResolversProviderMock,
        serverCodecConfigurerMock
    ));
}
 
Example 5
Source File: SpringWebfluxUnhandledExceptionHandlerTest.java    From backstopper with Apache License 2.0 5 votes vote down vote up
@Before
public void beforeMethod() {
    generalUtils = ApiExceptionHandlerUtils.DEFAULT_IMPL;
    testProjectApiErrors = ProjectApiErrorsForTesting.withProjectSpecificData(null, null);
    springUtilsMock = mock(SpringWebfluxApiExceptionHandlerUtils.class);
    viewResolversProviderMock = mock(ObjectProvider.class);
    serverCodecConfigurerMock = mock(ServerCodecConfigurer.class);
    messageReaders = Arrays.asList(mock(HttpMessageReader.class), mock(HttpMessageReader.class));
    messageWriters = Arrays.asList(mock(HttpMessageWriter.class), mock(HttpMessageWriter.class));
    viewResolvers = Arrays.asList(mock(ViewResolver.class), mock(ViewResolver.class));
    serverWebExchangeMock = mock(ServerWebExchange.class);
    serverHttpRequestMock = mock(ServerHttpRequest.class);
    serverHttpResponseMock = mock(ServerHttpResponse.class);
    serverHttpResponseHeadersMock = mock(HttpHeaders.class);
    uri = URI.create("http://localhost:8080/foo/bar?someQuery=someValue");
    exMock = mock(Throwable.class);

    doAnswer(invocation -> viewResolvers.stream()).when(viewResolversProviderMock).orderedStream();
    doReturn(messageReaders).when(serverCodecConfigurerMock).getReaders();
    doReturn(messageWriters).when(serverCodecConfigurerMock).getWriters();

    doReturn(serverHttpRequestMock).when(serverWebExchangeMock).getRequest();
    doReturn(uri).when(serverHttpRequestMock).getURI();

    doReturn(serverHttpResponseMock).when(serverWebExchangeMock).getResponse();
    doReturn(serverHttpResponseHeadersMock).when(serverHttpResponseMock).getHeaders();

    handlerSpy = spy(new SpringWebfluxUnhandledExceptionHandler(
        testProjectApiErrors, generalUtils, springUtilsMock, viewResolversProviderMock, serverCodecConfigurerMock
    ));
}
 
Example 6
Source File: Jersey1SampleConfigHelper.java    From backstopper with Apache License 2.0 5 votes vote down vote up
public static Jersey1ApiExceptionHandler generateJerseyApiExceptionHandler() {
    ApiExceptionHandlerUtils utils = ApiExceptionHandlerUtils.DEFAULT_IMPL;
    Jersey1BackstopperConfigHelper.ApiExceptionHandlerListenerList
        listeners = new Jersey1BackstopperConfigHelper.ApiExceptionHandlerListenerList(
        Jersey1BackstopperConfigHelper.defaultApiExceptionHandlerListeners(projectApiErrors, utils)
    );
    Jersey1UnhandledExceptionHandler unhandledExceptionHandler =
        new Jersey1UnhandledExceptionHandler(projectApiErrors, utils);

    return new Jersey1ApiExceptionHandler(
        projectApiErrors, listeners, utils, unhandledExceptionHandler
    );
}
 
Example 7
Source File: JaxRsUnhandledExceptionHandlerTest.java    From backstopper with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void doBeforeClass() {
    handler = new JaxRsUnhandledExceptionHandler(testProjectApiErrors, ApiExceptionHandlerUtils.DEFAULT_IMPL);
}
 
Example 8
Source File: Jersey1UnhandledExceptionHandlerTest.java    From backstopper with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void doBeforeClass() {
    handler = new Jersey1UnhandledExceptionHandler(testProjectApiErrors, ApiExceptionHandlerUtils.DEFAULT_IMPL);
}