### Question:
HttpPipelineHandler extends SimpleChannelInboundHandler<LiveHttpRequest> { @VisibleForTesting State state() { return this.stateMachine.currentState(); } private  HttpPipelineHandler(Builder builder, RequestTracker tracker); @Override void channelActive(ChannelHandlerContext ctx); @Override void channelInactive(ChannelHandlerContext ctx); @Override void exceptionCaught(ChannelHandlerContext ctx, Throwable cause);  }### Answer:
@Test public void responseObservableEmitsErrorInWaitingForResponseState() throws Exception { setupHandlerTo(WAITING_FOR_RESPONSE); responseObservable.onError(new RuntimeException("Request Send Error")); assertThat(responseUnsubscribed.get(), is(true)); writerFuture.complete(null); verify(statsCollector).onComplete(request.id(), 500); assertThat(handler.state(), is(TERMINATED)); }
@Test public void responseObservableEmitsErrorInSendingResponseState() throws Exception { setupHandlerTo(SENDING_RESPONSE); responseObservable.onError(new RuntimeException("Spurious error occurred")); assertThat(handler.state(), is(SENDING_RESPONSE)); verify(errorListener).proxyingFailure(any(LiveHttpRequest.class), any(LiveHttpResponse.class), any(Throwable.class)); }
@Test public void responseWriteFailsInSendingResponseState() throws Exception { RuntimeException cause = new RuntimeException("Response write failed"); setupHandlerTo(SENDING_RESPONSE); writerFuture.completeExceptionally(cause); assertThat(responseUnsubscribed.get(), is(true)); verify(statsCollector).onTerminate(request.id()); verify(errorListener).proxyWriteFailure(any(LiveHttpRequest.class), eq(response(OK).build()), any(RuntimeException.class)); assertThat(handler.state(), is(TERMINATED)); }