### Question:
ElasticSearchClientFactory { public ElasticSearchClient getClient(String clientType, String[] hostNames, String clusterName, ElasticSearchEventSerializer serializer, ElasticSearchIndexRequestBuilderFactory indexBuilder) throws NoSuchClientTypeException { if (clientType.equalsIgnoreCase(TransportClient) && serializer != null) { return new ElasticSearchTransportClient(hostNames, clusterName, serializer); } else if (clientType.equalsIgnoreCase(TransportClient) && indexBuilder != null) { return new ElasticSearchTransportClient(hostNames, clusterName, indexBuilder); } else if (clientType.equalsIgnoreCase(RestClient) && serializer != null) { return new ElasticSearchRestClient(hostNames, serializer); } throw new NoSuchClientTypeException(); }  ElasticSearchClient getClient(String clientType, String[] hostNames,
      String clusterName, ElasticSearchEventSerializer serializer,
      ElasticSearchIndexRequestBuilderFactory indexBuilder); ElasticSearchClient getLocalClient(String clientType, ElasticSearchEventSerializer serializer,
          ElasticSearchIndexRequestBuilderFactory indexBuilder); static final String TransportClient; static final String RestClient; }### Answer:
@Test public void shouldReturnTransportClient() throws Exception { String[] hostNames = { "127.0.0.1" }; Object o = factory.getClient(ElasticSearchClientFactory.TransportClient, hostNames, "test", serializer, null); assertThat(o, instanceOf(ElasticSearchTransportClient.class)); }
@Test public void shouldReturnRestClient() throws NoSuchClientTypeException { String[] hostNames = { "127.0.0.1" }; Object o = factory.getClient(ElasticSearchClientFactory.RestClient, hostNames, "test", serializer, null); assertThat(o, instanceOf(ElasticSearchRestClient.class)); }
@Test(expected=com.stratio.ingestion.sink.elasticsearch.client.NoSuchClientTypeException.class) public void shouldThrowNoSuchClientTypeException() throws NoSuchClientTypeException { String[] hostNames = {"127.0.0.1"}; factory.getClient("not_existing_client", hostNames, "test", null, null); }