LuceneStoreImpl implements Store { @Override public void eviction() throws Exception { StandardQueryParser queryParser = new StandardQueryParser(); queryParser.setAllowLeadingWildcard(true); queryParser.setPointsConfigMap(points); Query query = queryParser.parse("alertUUID:* AND NOT alertRule:*", ""); indexWriter.deleteDocuments(query); indexWriter.commit(); }  @Activate void activate(); @Deactivate void deactivate(); @Override String store(Event event); @Override void cleanup(); @Override void eviction(); @Override void flag(String queryString, String ruleName); @Override List<Alert> list(); @Override List<Alert> query(String queryString); @Override void delete(String queryString); static final String INDEX_DIRECTORY; static final String POINTS_DIRECTORY; }
@Test public void testEviction() throws Exception { HashMap<String, Object> data = new HashMap<>(); data.put("first", 1); Event event = new Event("collected", data); alertingService.store(event); data = new HashMap<>(); data.put("second", 2); data.put("alertRule", "test"); event = new Event("collected", data); alertingService.store(event); Assert.assertEquals(2, alertingService.list().size()); alertingService.eviction(); Assert.assertEquals(1, alertingService.list().size()); }