@Test
public void testAnnotationRecordListMapper() throws IOException {

    mapper = ElasticSearchAnnotationService.getAnnotationObjectMapper(new AnnotationRecordList.IndexSerializer());
    Annotation record1 = new Annotation("unittest", "id123", "unittest", "scope1", "metric1", 1557801635504L);
    AnnotationRecordList recordList = new AnnotationRecordList(Arrays.asList(record1), AnnotationRecordList.HashAlgorithm.fromString("MD5"));
    String serialized = mapper.writeValueAsString(recordList);
    String[] lines = serialized.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\":\"id123\",\"type\":\"unittest\",\"fields\":\"{}\",\"tags\":\"{}\",\"sid\":\"f9c22bcbd813474ec99f7011ae50b080\",\"ts\":\"1557801635504\"}";
    assertEquals(expectedSerializedAnnotation, lines[1]);
}