@Test
public void one_bulk_insert_on_transport_client_when_bulk_action_threshold_is_reached() {

    // Configure the BulkProcessor to use:
    BulkProcessorConfiguration configuration = new BulkProcessorConfiguration(new BulkProcessingOptionsBuilder().build(), bulkProcessorListener);
    // And create a fake index builder:
    IndexRequestBuilder indexRequestBuilder = new IndexRequestBuilder(client, IndexAction.INSTANCE);
    // The mapping to use:
    IElasticSearchMapping localWeatherDataMapper = new LocalWeatherDataMapper();
    // Index to insert to:
    String indexName = "weather_data";
    // Initialize it with the default settings:
    when(client.settings())
            .thenReturn(Settings.builder().build());
    when(client.prepareIndex())
            .thenReturn(indexRequestBuilder);
    // Create the Test subject:
    ElasticSearchClient<LocalWeatherData> elasticSearchClient = new ElasticSearchClient<>(client, indexName, localWeatherDataMapper, configuration);
    // Create more entities, than Bulk insertion threshold:
    Stream<LocalWeatherData> entitiesStream = getData(configuration.getBulkProcessingOptions().getBulkActions() + 1).stream();
    // Index the Data:
    elasticSearchClient.index(entitiesStream);
    // Verify, that the TransportClient bulk insert has been called:
    verify(client, times(1)).bulk(anyObject(), anyObject());
    verify(bulkProcessorListener, times(1)).beforeBulk(anyLong(), anyObject());
}