### Question:
NullResponseFilter implements Filter { @Override public Promise<Response, NeverThrowsException> filter(final Context context, final Request request, final Handler next) { return next.handle(context, request) .thenOnResult(new ResultHandler<Response>() { @Override public void handleResult(Response response) { if (response == null) { logger.debug(format("No response available for the request '%s' (id: %s)", request.getUri().toASCIIString(), context.getId())); } } }); } NullResponseFilter(Logger logger); @Override Promise<Response, NeverThrowsException> filter(final Context context,
                                                          final Request request,
                                                          final Handler next);  }### Answer:
@Test public void shouldLogAMessageWhenResponseIsNull() throws Exception { next = new ResponseHandler((Response) null); new NullResponseFilter(logger).filter(context, request, next); verify(logger).debug(logMessage.capture()); assertThat(logMessage.getValue()).contains(EXAMPLE_URI, context.getId()); }
@Test public void shouldLogAMessageWhenResponseIsNullAndContextContainsATransactionId() throws Exception { context = new TransactionIdContext(new RootContext(), TransactionId.valueOf(json(object(field("value", FAKE_TRANSACTION_ID), field("subTransactionIdCounter", 1))))); next = new ResponseHandler((Response) null); new NullResponseFilter(logger).filter(context, request, next); verify(logger).debug(logMessage.capture()); assertThat(logMessage.getValue()).contains(EXAMPLE_URI, FAKE_TRANSACTION_ID); }
@Test public void shouldNotLogAMessageWhenResponseIsNotNull() throws Exception { next = new ResponseHandler(new Response(OK)); new NullResponseFilter(logger).filter(context, request, next); verifyZeroInteractions(logger); }