JSONUtils { public static String getElasticSearchAddDocument(Map<String, String> values) { StringBuilder builder = new StringBuilder(); builder.append("{"); boolean first = true; for (Map.Entry<String, String> pair : values.entrySet()) { if (!first) { builder.append(","); } JSONUtils.addElasticSearchField(builder, pair); first = false; } builder.append("}"); return builder.toString(); } private  JSONUtils(); static String getElasticSearchAddDocument(Map<String, String> values); static String getElasticSearchBulkHeader(SimpleDataEvent event, String index, String type);  }
@Test public void testGetElasticSearchAddDocument() throws Exception { Map<String, String> pairs = new HashMap<String, String>(); pairs.put("aaa", "val_aaa"); pairs.put("bb", "val_bb"); assertEquals("{\"aaa\":\"val_aaa\",\"bb\":\"val_bb\"}", JSONUtils.getElasticSearchAddDocument(pairs)); }