@Test
public void testQuery() throws Exception {

    HashMap<String, Object> data = new HashMap<>();
    data.put("threadCount", 200);
    data.put("alertTimestamp", System.currentTimeMillis());
    data.put("mydouble", 2.5);
    data.put("content", "this is a raw text");
    Event event = new Event("collected", data);
    alertingService.store(event);
    data = new HashMap<>();
    data.put("other", "value");
    data.put("alertTimestamp", System.currentTimeMillis());
    event = new Event("collected", data);
    alertingService.store(event);
    List<Alert> found = alertingService.query("content:this* AND threadCount:[0 TO 200]");
    Assert.assertEquals(1, found.size());
    Assert.assertEquals(200, found.get(0).get("threadCount"));
    Assert.assertEquals("this is a raw text", found.get(0).get("content"));
    Assert.assertEquals(2.5, found.get(0).get("mydouble"));
    long past = System.currentTimeMillis() - 60 * 1000;
    data = new HashMap<>();
    data.put("scope", "out");
    data.put("alertTimestamp", System.currentTimeMillis() - 2 * 60 * 60 * 1000);
    event = new Event("collected", data);
    alertingService.store(event);
    found = alertingService.query("alertTimestamp:[" + past + " TO *]");
    Assert.assertEquals(2, found.size());
    data = new HashMap<>();
    data.put("period", "test");
    data.put("alertTimestamp", System.currentTimeMillis() - 5 * 60 * 1000);
    event = new Event("collected", data);
    alertingService.store(event);
    found = alertingService.query("period:test");
    Assert.assertEquals(1, found.size());
}