@Test
public void bulkIndexPayload() {

    TestDoc testDoc1 = new TestDoc("id1", "Accepted", Instant.now().getEpochSecond());
    TestDoc testDoc2 = new TestDoc("id2", "Running", Instant.now().getEpochSecond());
    TestDoc testDoc3 = new TestDoc("id3", "Stopped", Instant.now().getEpochSecond());
    List<TestDoc> testDocs = Arrays.asList(testDoc1, testDoc2, testDoc3);
    DefaultEsWebClientFactory defaultEsWebClientFactory = new DefaultEsWebClientFactory(getClientConfiguration());
    DefaultEsClient<TestDoc> esClient = new DefaultEsClient<>(defaultEsWebClientFactory);
    final String bulkIndexPayload = esClient.buildBulkIndexPayload(testDocs, "titustasks", "default");
    assertThat(bulkIndexPayload).isNotNull();
    assertThat(bulkIndexPayload).isNotEmpty();
    final String[] payloadLines = bulkIndexPayload.split("\n");
    assertThat(payloadLines.length).isEqualTo(testDocs.size() * 2);
    String line1 = "{\"index\":{\"_index\":\"titustasks\",\"_type\":\"default\",\"_id\":\"id1\"}}";
    String line2 = "{\"index\":{\"_index\":\"titustasks\",\"_type\":\"default\",\"_id\":\"id2\"}}";
    String line3 = "{\"index\":{\"_index\":\"titustasks\",\"_type\":\"default\",\"_id\":\"id3\"}}";
    assertThat(payloadLines[0]).isEqualTo(line1);
    assertThat(payloadLines[2]).isEqualTo(line2);
    assertThat(payloadLines[4]).isEqualTo(line3);
}