### Question:
AbstractManagedChannelImplBuilder extends ManagedChannelBuilder<T> { @Override public final T loadBalancerFactory(LoadBalancer.Factory loadBalancerFactory) { Preconditions.checkState(directServerAddress == null, "directServerAddress is set (%s), which forbids the use of LoadBalancer.Factory", directServerAddress); this.loadBalancerFactory = loadBalancerFactory; return thisT(); } protected  AbstractManagedChannelImplBuilder(String target); protected  AbstractManagedChannelImplBuilder(SocketAddress directServerAddress, String authority); static ManagedChannelBuilder<?> forAddress(String name, int port); static ManagedChannelBuilder<?> forTarget(String target); @Override T maxInboundMessageSize(int max); @Override final T directExecutor(); @Override final T executor(Executor executor); @Override final T intercept(List<ClientInterceptor> interceptors); @Override final T intercept(ClientInterceptor... interceptors); @Override final T nameResolverFactory(NameResolver.Factory resolverFactory); @Override final T loadBalancerFactory(LoadBalancer.Factory loadBalancerFactory); @Override final T enableFullStreamDecompression(); @Override final T decompressorRegistry(DecompressorRegistry registry); @Override final T compressorRegistry(CompressorRegistry registry); @Override final T userAgent(@Nullable String userAgent); @Override final T overrideAuthority(String authority); @Override final T idleTimeout(long value, TimeUnit unit); @Override final T maxRetryAttempts(int maxRetryAttempts); @Override final T maxHedgedAttempts(int maxHedgedAttempts); @Override final T retryBufferSize(long bytes); @Override final T perRpcBufferLimit(long bytes); @Override final T disableRetry(); @Override final T enableRetry(); @Override final T setBinaryLog(BinaryLog binlog); @Override T maxTraceEvents(int maxTraceEvents); @Override ManagedChannel build();  }### Answer:
@Test public void loadBalancerFactory_normal() { LoadBalancer.Factory loadBalancerFactory = mock(LoadBalancer.Factory.class); assertEquals(builder, builder.loadBalancerFactory(loadBalancerFactory)); assertEquals(loadBalancerFactory, builder.loadBalancerFactory); }
@Test public void loadBalancerFactory_null() { LoadBalancer.Factory defaultValue = builder.loadBalancerFactory; builder.loadBalancerFactory(mock(LoadBalancer.Factory.class)); assertEquals(builder, builder.loadBalancerFactory(null)); assertEquals(defaultValue, builder.loadBalancerFactory); }
@Test(expected = IllegalStateException.class) public void loadBalancerFactory_notAllowedWithDirectAddress() { directAddressBuilder.loadBalancerFactory(mock(LoadBalancer.Factory.class)); }