@Test public void constructor_works_with_valid_args() { // given ExceptionHandlingHandler handler = new ExceptionHandlingHandler( mock(RiposteErrorHandler.class), mock(RiposteUnhandledErrorHandler.class), mock(DistributedTracingConfig.class) ); // expect assertThat(handler, notNullValue()); }
@Test(expected = IllegalArgumentException.class) public void constructor_throws_IllegalArgumentException_if_riposteUnhandledErrorHandler_is_null() { // expect new ExceptionHandlingHandler( mock(RiposteErrorHandler.class), null, mock(DistributedTracingConfig.class) ); }
@Test(expected = IllegalArgumentException.class) public void constructor_throws_IllegalArgumentException_if_distributedTracingConfig_is_null() { // expect new ExceptionHandlingHandler( mock(RiposteErrorHandler.class), mock(RiposteUnhandledErrorHandler.class), null ); }
@Test(expected = IllegalArgumentException.class) public void constructor_throws_IllegalArgumentException_if_riposteErrorHandler_is_null() { // expect new ExceptionHandlingHandler( null, mock(RiposteUnhandledErrorHandler.class), mock(DistributedTracingConfig.class) ); }
@Before public void beforeMethod() { riposteErrorHandlerMock = mock(RiposteErrorHandler.class); riposteUnhandledErrorHandlerMock = mock(RiposteUnhandledErrorHandler.class); distributedTracingConfigMock = mock(DistributedTracingConfig.class); serverSpanNamingAndTaggingStrategyMock = mock(ServerSpanNamingAndTaggingStrategy.class); doReturn(serverSpanNamingAndTaggingStrategyMock).when(distributedTracingConfigMock).getServerSpanNamingAndTaggingStrategy(); handler = new ExceptionHandlingHandler(riposteErrorHandlerMock, riposteUnhandledErrorHandlerMock, distributedTracingConfigMock ); channelMock = mock(Channel.class); ctxMock = mock(ChannelHandlerContext.class); stateAttributeMock = mock(Attribute.class); proxyRouterStateAttributeMock = mock(Attribute.class); state = new HttpProcessingState(); proxyRouterStateSpy = spy(new ProxyRouterProcessingState()); doReturn(channelMock).when(ctxMock).channel(); doReturn(stateAttributeMock).when(channelMock).attr(ChannelAttributes.HTTP_PROCESSING_STATE_ATTRIBUTE_KEY); doReturn(state).when(stateAttributeMock).get(); doReturn(proxyRouterStateAttributeMock).when(channelMock) .attr(ChannelAttributes.PROXY_ROUTER_PROCESSING_STATE_ATTRIBUTE_KEY); doReturn(proxyRouterStateSpy).when(proxyRouterStateAttributeMock).get(); }
new ExceptionHandlingHandler(riposteErrorHandler, riposteUnhandledErrorHandler, distributedTracingConfig); p.addLast(EXCEPTION_HANDLING_HANDLER_NAME, exceptionHandlingHandler);
new ExceptionHandlingHandler(riposteErrorHandler, riposteUnhandledErrorHandler, distributedTracingConfig); p.addLast(EXCEPTION_HANDLING_HANDLER_NAME, exceptionHandlingHandler);