@Test
public void testPutAnnotationsUsingAnnotationIndex() throws IOException {

    ElasticSearchAnnotationService spyService = _initializeSpyService(esAnnotationService, createSucessReply, true);
    List<Annotation> annotations = new ArrayList<>();
    Annotation record1 = new Annotation("unittest", "id456", "unittest", "scope1", "metric1", 1557800720441L);
    annotations.add(record1);
    spyService.putAnnotations(annotations);
    ArgumentCaptor<String> requestCaptorUrl = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> requestCaptorBody = ArgumentCaptor.forClass(String.class);
    verifyStatic(ElasticSearchUtils.class, times(1));
    ElasticSearchUtils.performESRequest(eq(restClient), requestCaptorUrl.capture(), requestCaptorBody.capture());
    String expectedURL = "_bulk";
    assertEquals(expectedURL, requestCaptorUrl.getValue());
    String[] lines = requestCaptorBody.getValue().split("\\r?\\n");
    String expectedIndexName = "argus-annotation-2019-05";
    JsonNode root = mapper.readTree(lines[0]);
    String actualIndexName = root.get("index").get("_index").asText();
    assertEquals(expectedIndexName, actualIndexName);
    String expectedSerializedAnnotation =
            "{\"metric\":\"metric1\",\"scope\":\"scope1\",\"source\":\"unittest\",\"id\":\"id456\",\"type\":\"unittest\",\"fields\":\"{}\",\"tags\":\"{}\",\"sid\":\"f9c22bcbd813474ec99f7011ae50b080\",\"ts\":\"1557800720441\"}";
    assertEquals(expectedSerializedAnnotation, lines[1]);
}