// Path: grpc-mate-java/elasticsearch-service/src/main/java/io/datanerd/es/server/ServiceInterceptor.java
// @Singleton
// public class ServiceInterceptor implements ServerInterceptor {
//   //ref https://github.com/grpc/grpc-java/blob/master/examples/src/main/java/io/grpc/examples/header/HeaderServerInterceptor.java
//   private static Logger log = LoggerFactory.getLogger(ServiceInterceptor.class); //NOPMD
//   static final Metadata.Key<String> CUSTOM_HEADER_KEY =
//       Metadata.Key.of("custom_server_header_key", Metadata.ASCII_STRING_MARSHALLER);
// 
//   @Override
//   public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, Metadata headers,
//                                                                ServerCallHandler<ReqT, RespT> next) {
// 
//     log.info("receive headers - {}", headers);
//     String methodName = call.getMethodDescriptor().getFullMethodName();
// 
//     return next.startCall(new ForwardingServerCall.SimpleForwardingServerCall<ReqT, RespT>(call) {
//       @Override
//       public void sendHeaders(Metadata headers) {
//         headers.put(CUSTOM_HEADER_KEY, methodName);
//         super.sendHeaders(headers);
//       }
//     }, headers);
//   }
// }


import com.google.inject.Guice;
import com.google.inject.Injector;
import com.github.javafaker.Faker;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import io.datanerd.es.server.ServiceInterceptor;
import io.datanerd.generated.es.EchoRequest;
import io.datanerd.generated.es.EchoResponse;
import io.datanerd.generated.es.EchoServiceGrpc;
import io.grpc.Channel;
import io.grpc.ClientInterceptors;
import io.grpc.ServerInterceptors;
import io.grpc.testing.GrpcServerRule;
import static org.assertj.core.api.Assertions.assertThat;
package io.datanerd.es.service;






public class EchoServiceTest {

  private Faker faker;
  private EchoServiceGrpc.EchoServiceBlockingStub stub;

  @Rule
  public GrpcServerRule grpcServerRule = new GrpcServerRule();

  @Before
  public void setUp() throws Exception {
    faker = new Faker();
    Injector injector = Guice.createInjector();
    EchoService echoService = injector.getInstance(EchoService.class);
// Path: grpc-mate-java/elasticsearch-service/src/main/java/io/datanerd/es/server/ServiceInterceptor.java
// @Singleton
// public class ServiceInterceptor implements ServerInterceptor {
//   //ref https://github.com/grpc/grpc-java/blob/master/examples/src/main/java/io/grpc/examples/header/HeaderServerInterceptor.java
//   private static Logger log = LoggerFactory.getLogger(ServiceInterceptor.class); //NOPMD
//   static final Metadata.Key<String> CUSTOM_HEADER_KEY =
//       Metadata.Key.of("custom_server_header_key", Metadata.ASCII_STRING_MARSHALLER);
// 
//   @Override
//   public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, Metadata headers,
//                                                                ServerCallHandler<ReqT, RespT> next) {
// 
//     log.info("receive headers - {}", headers);
//     String methodName = call.getMethodDescriptor().getFullMethodName();
// 
//     return next.startCall(new ForwardingServerCall.SimpleForwardingServerCall<ReqT, RespT>(call) {
//       @Override
//       public void sendHeaders(Metadata headers) {
//         headers.put(CUSTOM_HEADER_KEY, methodName);
//         super.sendHeaders(headers);
//       }
//     }, headers);
//   }
// }


// Path: grpc-mate-java/elasticsearch-service/src/test/java/io/datanerd/es/service/EchoServiceTest.java
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.github.javafaker.Faker;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import io.datanerd.es.server.ServiceInterceptor;
import io.datanerd.generated.es.EchoRequest;
import io.datanerd.generated.es.EchoResponse;
import io.datanerd.generated.es.EchoServiceGrpc;
import io.grpc.Channel;
import io.grpc.ClientInterceptors;
import io.grpc.ServerInterceptors;
import io.grpc.testing.GrpcServerRule;
import static org.assertj.core.api.Assertions.assertThat;

package io.datanerd.es.service;






public class EchoServiceTest {

  private Faker faker;
  private EchoServiceGrpc.EchoServiceBlockingStub stub;

  @Rule
  public GrpcServerRule grpcServerRule = new GrpcServerRule();

  @Before
  public void setUp() throws Exception {
    faker = new Faker();
    Injector injector = Guice.createInjector();
    EchoService echoService = injector.getInstance(EchoService.class);
    ServiceInterceptor serviceInterceptor = injector.getInstance(ServiceInterceptor.class);