### Question:
JestHttpObjectFactory implements ClientObjectFactory<JestClient, Bulk> { @Override public JestClient createClient() { if (client == null) { HttpClientConfig.Builder builder = new HttpClientConfig.Builder(serverUris) .maxTotalConnection(maxTotalConnections) .defaultMaxTotalConnectionPerRoute(defaultMaxTotalConnectionsPerRoute) .connTimeout(connTimeout) .readTimeout(readTimeout) .discoveryEnabled(discoveryEnabled) .multiThreaded(true); if (this.auth != null) { auth.configure(builder); } WrappedHttpClientConfig.Builder wrappedHttpClientConfigBuilder = new WrappedHttpClientConfig.Builder(builder.build()) .ioThreadCount(ioThreadCount); client = getClientProvider(wrappedHttpClientConfigBuilder).createClient(); } return client; } protected  JestHttpObjectFactory(Builder builder); @Override Collection<String> getServerList(); @Override JestClient createClient(); @Override Function<Bulk, Boolean> createBatchListener(FailoverPolicy failoverPolicy); @Override Function<Bulk, Boolean> createFailureHandler(FailoverPolicy failover); @Override BatchOperations<Bulk> createBatchOperations(); @Override void execute(IndexTemplate indexTemplate); @Override void addOperation(Operation operation); @PluginBuilderFactory static Builder newBuilder(); @Override void start(); @Override void stop(); @Override boolean isStarted(); @Override boolean isStopped();  }### Answer:
@Test public void clientIsInitializedOnlyOnce() { JestHttpObjectFactory factory = spy(createTestObjectFactoryBuilder().build()); JestClient client1 = factory.createClient(); JestClient client2 = factory.createClient(); assertEquals(client1, client2); }
@Test public void authIsAppliedIfConfigured() { Auth auth = mock(Auth.class); JestHttpObjectFactory factory = createTestObjectFactoryBuilder() .withAuth(auth) .build(); factory.createClient(); verify(auth).configure(any()); }