### Question:
HCHttp implements ClientObjectFactory<HttpClient, BatchRequest> { @Override public HttpClient createClient() { if (client == null) { HttpClientFactory.Builder builder = createHttpClientFactoryBuilder(); if (this.auth != null) { auth.configure(builder); } client = getClientProvider(builder).createClient(); } return client; } HCHttp(Builder builder); @Override Function<BatchRequest, Boolean> createFailureHandler(FailoverPolicy failover); @Override BatchOperations<BatchRequest> createBatchOperations(); @Override Collection<String> getServerList(); @Override HttpClient createClient(); @Override Function<BatchRequest, Boolean> createBatchListener(FailoverPolicy failoverPolicy); @Override void execute(IndexTemplate indexTemplate); @Override void addOperation(Operation operation); @PluginBuilderFactory static HCHttp.Builder newBuilder(); @Override void start(); @Override void stop(); @Override boolean isStarted(); @Override boolean isStopped(); static final String PLUGIN_NAME; }### Answer:
@Test public void clientIsInitializedOnlyOnce() { HCHttp factory = spy(createDefaultHttpObjectFactoryBuilder().build()); HttpClient client1 = factory.createClient(); HttpClient client2 = factory.createClient(); assertEquals(client1, client2); }
@Test public void authIsAppliedIfConfigured() { Auth auth = mock(Auth.class); HCHttp factory = createDefaultHttpObjectFactoryBuilder() .withAuth(auth) .build(); factory.createClient(); verify(auth).configure(any()); }