DefaultLogbook implements Logbook { @Override public RequestWritingStage process(final HttpRequest originalRequest) throws IOException { return process(originalRequest, strategy); }  @Override RequestWritingStage process(final HttpRequest originalRequest); @Override RequestWritingStage process(final HttpRequest originalRequest, final Strategy strategy);  }
@Test void shouldNotWriteIfSinkInactive() throws IOException { when(sink.isActive()).thenReturn(false); unit.process(request).write().process(response).write(); verify(sink, never()).write(any(), any()); verify(sink, never()).write(any(), any(), any()); verify(sink, never()).writeBoth(any(), any(), any()); }
@Test void shouldNotWriteIfPredicateTestsFalse() throws IOException { when(predicate.test(any())).thenReturn(false); unit.process(request).write().process(response).write(); verify(sink, never()).write(any(), any()); verify(sink, never()).write(any(), any(), any()); verify(sink, never()).writeBoth(any(), any(), any()); }
@Test void shouldNeverRetrieveBodyIfInactiveWriter() throws IOException { when(sink.isActive()).thenReturn(false); unit.process(request).write(); verify(request, never()).withBody(); }
@Test void shouldFilterRequest() throws IOException { unit.process(request).write(); final ArgumentCaptor<HttpRequest> captor = ArgumentCaptor.forClass(HttpRequest.class); verify(sink).write(any(), captor.capture()); final HttpRequest request = captor.getValue(); assertThat(request, instanceOf(FilteredHttpRequest.class)); }
@Test void shouldFilterResponse() throws IOException { unit.process(request).write().process(response).write(); final ArgumentCaptor<HttpResponse> captor = ArgumentCaptor.forClass(HttpResponse.class); verify(sink).write(any(), any(), captor.capture()); final HttpResponse response = captor.getValue(); assertThat(response, instanceOf(FilteredHttpResponse.class)); }