### Question:
CaptureHandler implements Handler { @Override public Promise<Response, NeverThrowsException> handle(final Context context, final Request request) { if (points.contains(REQUEST)) { capture.capture(context, request, REQUEST); } return delegate.handle(context, request) .thenOnResult(new ResultHandler<Response>() { @Override public void handleResult(final Response response) { if (points.contains(RESPONSE)) { capture.capture(context, response, RESPONSE); } } }); } CaptureHandler(final Handler delegate,
                          final MessageCapture capture,
                          final Set<CapturePoint> points); @Override Promise<Response, NeverThrowsException> handle(final Context context, final Request request);  }### Answer:
@Test(dataProvider = "capturePointSets") public void shouldCaptureAllMessages(List<CapturePoint> points) throws Exception { CaptureHandler handler = new CaptureHandler(delegate, capture, new TreeSet<>(points)); Context context = new RootContext(); handler.handle(context, null).get(); for (CapturePoint capturePoint : points) { switch (capturePoint) { case REQUEST: verify(capture).capture(context, (Request) null, capturePoint); break; case RESPONSE: verify(capture).capture(context, response, capturePoint); break; } } verifyNoMoreInteractions(capture); }