@Test
public void testInvalidPayload() throws Exception {

  AsyncHandler<Response<ByteString>> outerHandler = Middlewares.json().apply(
      rc -> Response.forPayload(new NotSerializable())
  );
  CompletionStage<Response<ByteString>> completionStage = outerHandler.invoke(
      RequestContexts.create(mock(Request.class),
          mock(Client.class),
          Collections.emptyMap(),
          System.nanoTime(),
          RequestMetadataImpl.create(Instant.EPOCH,
              Optional.empty(), Optional.empty())));
  Response<ByteString> response = completionStage.toCompletableFuture().get();
  assertThat(response.payload().isPresent(), is(false));
  assertThat(response.status().family(), is(Status.Family.SERVER_ERROR));
}