LogbookServerHandler extends ChannelDuplexHandler { @Override public void write( final ChannelHandlerContext context, final Object message, final ChannelPromise promise) { runIf(message, HttpResponse.class, httpResponse -> { this.response = new Response(LOCAL, httpResponse); this.responseStage = requestStage.process(response); }); runIf(message, HttpContent.class, response::buffer); runIf(message, LastHttpContent.class, content -> sequence.set(1, throwingRunnable(responseStage::write))); context.write(message, promise); }  @Override void channelRead(
            final ChannelHandlerContext context,
            final Object message); @Override void write(
            final ChannelHandlerContext context,
            final Object message,
            final ChannelPromise promise);  }
@Test void shouldNotLogRequestIfInactive() throws IOException { when(writer.isActive()).thenReturn(false); sendAndReceive(); verify(writer, never()).write(any(Precorrelation.class), any()); }
@Test void shouldNotLogResponseIfInactive() throws IOException { when(writer.isActive()).thenReturn(false); sendAndReceive(); verify(writer, never()).write(any(Correlation.class), any()); }