Middlewares { public static Middleware<AsyncHandler<?>, AsyncHandler<Response<?>>> replyContentType( String contentType) { return inner -> inner .map(Middlewares::ensureResponse) .map(response -> response.withHeader(CONTENT_TYPE, contentType)); } private  Middlewares(); static AsyncHandler<Response<ByteString>> autoSerialize(AsyncHandler<T> inner); static AsyncHandler<Response<ByteString>> httpPayloadSemantics(
      AsyncHandler<Response<ByteString>> inner); static Middleware<AsyncHandler<?>, AsyncHandler<Response<?>>> replyContentType(
      String contentType); static Middleware<AsyncHandler<?>, AsyncHandler<Response<ByteString>>> serialize(
      Serializer serializer); static Middleware<AsyncHandler<?>, AsyncHandler<Response<ByteString>>> apolloDefaults();  }
@Test public void contentTypeShouldAddToNonResponse() throws Exception { serializationFuture.complete("hi"); String contentType = getResult(Middlewares.replyContentType("text/plain") .apply(serializationDelegate())) .header("Content-Type").get(); assertThat(contentType, equalTo("text/plain")); }
@Test public void contentTypeShouldAddToResponse() throws Exception { serializationFuture.complete(Response.forPayload("hi")); String contentType = getResult(Middlewares.replyContentType("text/plain").apply(serializationDelegate())) .header("Content-Type").get(); assertThat(contentType, equalTo("text/plain")); }