@Test
public void appenderUsesProvidedIndexNameFormatter() {

    // given
    BatchDelivery<String> batchDelivery = mock(BatchDelivery.class);
    IndexNameFormatter indexNameFormatter = mock(IndexNameFormatter.class);
    when(indexNameFormatter.format(any(LogEvent.class))).thenReturn("formattedIndexName");
    ElasticsearchAppender.Builder builder = ElasticsearchAppenderTest.createTestElasticsearchAppenderBuilder();
    builder.withBatchDelivery(batchDelivery);
    builder.withMessageOnly(false);
    builder.withIndexNameFormatter(indexNameFormatter);
    LogEvent logEvent = createTestLogEvent();
    ElasticsearchAppender appender = builder.build();
    // when
    appender.append(logEvent);
    // then
    verify(batchDelivery, times(1)).add(eq("formattedIndexName"), any(ItemSource.class));
}