IspnAlertsServiceImpl implements AlertsService { @Override public void addNote(String tenantId, String alertId, String user, String text) throws Exception { if (isEmpty(tenantId)) { throw new IllegalArgumentException("TenantId must be not null"); } if (isEmpty(alertId)) { throw new IllegalArgumentException("AlertId must be not null"); } if (isEmpty(user) || isEmpty(text)) { throw new IllegalArgumentException("user or text must be not null"); } Alert alert = getAlert(tenantId, alertId, false); if (alert == null) { return; } alert.addNote(user, text); backend.put(pk(alert), new IspnEvent(alert)); }  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 addNote() throws Exception { int numTenants = 1; int numTriggers = 1; int numAlerts = 5; createTestAlerts(numTenants, numTriggers, numAlerts); AlertsCriteria criteria = new AlertsCriteria(); criteria.setStatus(Alert.Status.OPEN); List<Alert> openAlerts = alerts.getAlerts("tenant0", criteria, null); assertEquals(1, openAlerts.size()); String alertId = openAlerts.iterator().next().getAlertId(); alerts.addNote("tenant0", alertId, "xyz1", "Note1"); Alert alert = alerts.getAlert("tenant0", alertId, false); assertEquals(1, alert.getNotes().size()); alerts.addNote("tenant0", alertId, "xyz2", "Note2"); alerts.addNote("tenant0", alertId, "xyz3", "Note3"); alert = alerts.getAlert("tenant0", alertId, false); assertEquals(3, alert.getNotes().size()); deleteTestAlerts(numTenants); }