@Test
public void clientIsCalledWhenBatchItemIsAdded() {

    // given
    Builder builder = createTestObjectFactoryBuilder();
    ClientObjectFactory<TransportClient, BulkRequest> config = spy(builder.build());
    Settings settings = Settings.builder().build();
    TransportClient client = spy(new PreBuiltTransportClient(settings));
    client.addTransportAddress(new TransportAddress(new InetSocketAddress(9999)));
    when(config.createClient()).thenReturn(client);
    FailoverPolicy failoverPolicy = spy(new NoopFailoverPolicy());
    BulkProcessorFactory bulkProcessorFactory = new BulkProcessorFactory();
    BatchEmitter batchEmitter = bulkProcessorFactory.createInstance(
                    1,
                    100,
                    config,
                    failoverPolicy);
    String payload1 = "test1";
    ActionRequest testRequest = createTestRequest(payload1);
    // when
    batchEmitter.add(testRequest);
    // then
    ArgumentCaptor<BulkRequest> captor = ArgumentCaptor.forClass(BulkRequest.class);
    verify(client, times(1)).bulk(captor.capture(), Mockito.any());
    assertEquals(payload1, new BulkRequestIntrospector().items(captor.getValue()).iterator().next());
}