### Question:
GoogleDefaultProtocolNegotiator implements ProtocolNegotiator { @Override public Handler newHandler(GrpcHttp2ConnectionHandler grpcHandler) { if (grpcHandler.getEagAttributes().get(GrpcAttributes.ATTR_LB_ADDR_AUTHORITY) != null || grpcHandler.getEagAttributes().get(GrpcAttributes.ATTR_LB_PROVIDED_BACKEND) != null) { return altsProtocolNegotiator.newHandler(grpcHandler); } else { return tlsProtocolNegotiator.newHandler(grpcHandler); } } GoogleDefaultProtocolNegotiator(TsiHandshakerFactory altsFactory, SslContext sslContext); @VisibleForTesting  GoogleDefaultProtocolNegotiator(
      ProtocolNegotiator altsProtocolNegotiator, ProtocolNegotiator tlsProtocolNegotiator); @Override Handler newHandler(GrpcHttp2ConnectionHandler grpcHandler); @Override void close();  }### Answer:
@Test public void altsHandler() { Attributes eagAttributes = Attributes.newBuilder().set(GrpcAttributes.ATTR_LB_PROVIDED_BACKEND, true).build(); GrpcHttp2ConnectionHandler mockHandler = mock(GrpcHttp2ConnectionHandler.class); when(mockHandler.getEagAttributes()).thenReturn(eagAttributes); Handler handler = googleProtocolNegotiator.newHandler(mockHandler); verify(altsProtocolNegotiator, times(1)).newHandler(mockHandler); verify(tlsProtocolNegotiator, never()).newHandler(mockHandler); }
@Test public void tlsHandler() { Attributes eagAttributes = Attributes.EMPTY; GrpcHttp2ConnectionHandler mockHandler = mock(GrpcHttp2ConnectionHandler.class); when(mockHandler.getEagAttributes()).thenReturn(eagAttributes); Handler handler = googleProtocolNegotiator.newHandler(mockHandler); verify(altsProtocolNegotiator, never()).newHandler(mockHandler); verify(tlsProtocolNegotiator, times(1)).newHandler(mockHandler); }