### Question:
MongoExceptionHandler extends ChannelInboundHandlerAdapter { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { log.error("exception for client {}", ctx.channel().id(), cause); ctx.channel().close(); }  @Override void exceptionCaught(ChannelHandlerContext ctx, Throwable cause);  }### Answer:
@Test void exceptionCaught() { ChannelHandlerContext mockChannelHandlerContext = mock(ChannelHandlerContext.class); Channel mockChannel = mock(Channel.class); ChannelFuture mockChannelFuture = mock(ChannelFuture.class); when(mockChannel.id()).thenReturn(new MockChannelId("channel1")); when(mockChannel.close()).thenReturn(mockChannelFuture); when(mockChannelHandlerContext.channel()).thenReturn(mockChannel); MongoExceptionHandler mongoExceptionHandler = new MongoExceptionHandler(); mongoExceptionHandler.exceptionCaught(mockChannelHandlerContext, new RuntimeException("testing")); verify(mockChannel, times(1)).id(); verify(mockChannel, times(1)).close(); }