IspnAlertsServiceImpl implements AlertsService { @Override public void addEvents(Collection<Event> events) throws Exception { if (null == events || events.isEmpty()) { return; } persistEvents(events); sendEvents(events); }  void init(); void setAlertsEngine(AlertsEngine alertsEngine); void setDefinitionsService(DefinitionsService definitionsService); void setActionsService(ActionsService actionsService); void setIncomingDataManager(IncomingDataManager incomingDataManager); void setProperties(PropertiesService properties); @Override void ackAlerts(String tenantId, Collection<String> alertIds, String ackBy, String ackNotes); @Override void addAlerts(Collection<Alert> alerts); @Override void addAlertTags(String tenantId, Collection<String> alertIds, Map<String, String> tags); @Override void addEvents(Collection<Event> events); @Override void addEventTags(String tenantId, Collection<String> eventIds, Map<String, String> tags); @Override void persistEvents(Collection<Event> events); @Override void addNote(String tenantId, String alertId, String user, String text); @Override int deleteAlerts(String tenantId, AlertsCriteria criteria); @Override int deleteEvents(String tenantId, EventsCriteria criteria); @Override Alert getAlert(String tenantId, String alertId, boolean thin); @Override Page<Alert> getAlerts(String tenantId, AlertsCriteria criteria, Pager pager); @Override Page<Alert> getAlerts(Set<String> tenantIds, AlertsCriteria criteria, Pager pager); @Override Event getEvent(String tenantId, String eventId, boolean thin); @Override Page<Event> getEvents(String tenantId, EventsCriteria criteria, Pager pager); @Override Page<Event> getEvents(Set<String> tenantIds, EventsCriteria criteria, Pager pager); @Override void removeAlertTags(String tenantId, Collection<String> alertIds, Collection<String> tags); @Override void removeEventTags(String tenantId, Collection<String> eventIds, Collection<String> tags); @Override void resolveAlerts(String tenantId, Collection<String> alertIds, String resolvedBy, String resolvedNotes, List<Set<ConditionEval>> resolvedEvalSets); @Override void resolveAlertsForTrigger(String tenantId, String triggerId, String resolvedBy, String resolvedNotes, List<Set<ConditionEval>> resolvedEvalSets); @Override void sendData(Collection<Data> data); @Override void sendData(Collection<Data> data, boolean ignoreFiltering); @Override void sendEvents(Collection<Event> events); @Override void sendEvents(Collection<Event> events, boolean ignoreFiltering);  }
@Test public void addEvents() throws Exception { int numTenants = 2; int numTriggers = 5; int numEvents = 100; createTestEvents(numTenants, numTriggers, numEvents); Set<String> tenantIds = new HashSet<>(); tenantIds.add("tenant0"); tenantIds.add("tenant1"); assertEquals(2 * 5 * 100, alerts.getEvents(tenantIds, null, null).size()); tenantIds.remove("tenant0"); assertEquals(1 * 5 * 100, alerts.getEvents(tenantIds, null, null).size()); List<Event> testEvents = alerts.getEvents(tenantIds, null, null); tenantIds.clear(); Set<String> eventIds = new HashSet<>(); for (int i = 0; i < 3; i++) { Event eventX = testEvents.get(i); tenantIds.add(eventX.getTenantId()); eventIds.add(eventX.getId()); } EventsCriteria criteria = new EventsCriteria(); criteria.setEventIds(eventIds); assertEquals(3, alerts.getEvents(tenantIds, criteria, null).size()); deleteTestEvents(numTenants); }