@Test
public void testExtraHeaders() {

  Metadata emptyHeaders = new Metadata();
  final Map<String, List<String>> extraHeaders = new HashMap<>();
  extraHeaders.put(
      "header-key-1", ImmutableList.<String>of("header-value-11", "header-value-12"));
  extraHeaders.put("header-key-2", ImmutableList.<String>of("header-value-21"));
  MethodDescriptor<Color, Money> descriptor = FakeServiceGrpc.METHOD_RECOGNIZE;
  @SuppressWarnings("unchecked")
  ClientCall<Color, Money> mockClientCall = Mockito.mock(ClientCall.class);
  @SuppressWarnings("unchecked")
  ClientCall.Listener<Money> mockListener = Mockito.mock(ClientCall.Listener.class);
  @SuppressWarnings("unchecked")
  Channel mockChannel = Mockito.mock(ManagedChannel.class);
  Mockito.doAnswer(
          new Answer<Void>() {
            public Void answer(InvocationOnMock invocation) {
              Metadata clientCallHeaders = (Metadata) invocation.getArguments()[1];
              Metadata.Key<String> key1 =
                  Metadata.Key.of("header-key-1", Metadata.ASCII_STRING_MARSHALLER);
              Metadata.Key<String> key2 =
                  Metadata.Key.of("header-key-2", Metadata.ASCII_STRING_MARSHALLER);
              assertThat(clientCallHeaders.getAll(key1))
                  .containsExactly("header-value-11", "header-value-12");
              assertThat(clientCallHeaders.getAll(key2)).containsExactly("header-value-21");
              return null;
            }
          })
      .when(mockClientCall)
      .start(Mockito.<ClientCall.Listener<Money>>any(), Mockito.<Metadata>any());
  Mockito.when(mockChannel.newCall(Mockito.eq(descriptor), Mockito.<CallOptions>any()))
      .thenReturn(mockClientCall);
  GrpcCallContext context =
      GrpcCallContext.createDefault().withChannel(mockChannel).withExtraHeaders(extraHeaders);
  GrpcClientCalls.newCall(descriptor, context).start(mockListener, emptyHeaders);
}