use of org.codice.ddf.system.alerts.SystemNotice in project ddf by codice.
the class SolrAppenderTest method testHandleEventSizeBatching.
@Test
public void testHandleEventSizeBatching() throws Exception {
SystemNotice notice = new SystemNotice();
Event event = new Event("decanter/collect", notice.getProperties());
solrAppender.setBatchSize(1);
solrAppender.handleEvent(event);
verify(persistentStore, never()).add(eq("decanter"), any(Collection.class));
solrAppender.handleEvent(event);
verify(persistentStore).add(eq("decanter"), any(Collection.class));
}
use of org.codice.ddf.system.alerts.SystemNotice in project ddf by codice.
the class CrlGenerator method postErrorEvent.
/**
* Posts and error message to the Admin Console.
*
* @param errorMessage - The reason for the error.
*/
private void postErrorEvent(String errorMessage) {
String title = "Unable to download the Certificate Revocation List (CRL) from " + crlLocationUrl;
Set<String> details = new HashSet<>();
details.add("The provided CRL could not be downloaded. Please check the provided URL and/or the contents of the given CRL.");
details.add(errorMessage);
details.add("To recover, resolve the issue and save the configuration.");
eventAdmin.postEvent(new Event(SystemNotice.SYSTEM_NOTICE_BASE_TOPIC + "crl", new SystemNotice(this.getClass().getName(), NoticePriority.CRITICAL, title, details).getProperties()));
securityLogger.audit(title);
securityLogger.audit(errorMessage);
}
use of org.codice.ddf.system.alerts.SystemNotice in project ddf by codice.
the class AlertListenerTest method testHandleEventExistingAlert.
@Test
public void testHandleEventExistingAlert() throws Exception {
SystemNotice notice = new SystemNotice("test-source", NoticePriority.IMPORTANT, "title", new HashSet());
Map<String, Object> props = notice.getProperties();
props.put("event.topics", "decanter/alert/test");
Alert alert = new Alert(props);
ArgumentCaptor<PersistentItem> captor = ArgumentCaptor.forClass(PersistentItem.class);
Event event = new Event("decanter/alert/test", alert.getProperties());
when(persistentStore.get(any(), any())).thenReturn(Collections.singletonList(toSolr(alert)));
alertListener.handleEvent(event);
verify(persistentStore).add(eq("alerts"), captor.capture());
PersistentItem item = captor.getValue();
assertThat(item.getLongProperty(Alert.ALERT_COUNT), equalTo(2L));
}
use of org.codice.ddf.system.alerts.SystemNotice in project ddf by codice.
the class AlertListenerTest method testHandleEventDismissNoDismissedBy.
@Test
public void testHandleEventDismissNoDismissedBy() throws Exception {
SystemNotice alert = new SystemNotice("test-source", NoticePriority.IMPORTANT, "title", new HashSet());
ArgumentCaptor<PersistentItem> captor = ArgumentCaptor.forClass(PersistentItem.class);
Map<String, String> dismissEvent = new HashMap<>();
dismissEvent.put(Alert.SYSTEM_NOTICE_ID_KEY, alert.getId());
Event event = new Event(Alert.ALERT_DISMISS_TOPIC, dismissEvent);
when(persistentStore.get(any(), any())).thenReturn(Collections.singletonList(toSolr(alert)));
alertListener.handleEvent(event);
verify(persistentStore, never()).add(any(), any(PersistentItem.class));
}
use of org.codice.ddf.system.alerts.SystemNotice in project ddf by codice.
the class AlertListenerTest method testHandleEventFirstAlert.
@Test
public void testHandleEventFirstAlert() throws Exception {
SystemNotice notice = new SystemNotice("test-source", NoticePriority.IMPORTANT, "title", new HashSet());
Map<String, Object> props = notice.getProperties();
props.put("event.topics", "decanter/alert/test");
Alert alert = new Alert(props);
ArgumentCaptor<Event> captor = ArgumentCaptor.forClass(Event.class);
Event event = new Event("decanter/alert/test", notice.getProperties());
when(persistentStore.get(any(), any())).thenReturn(new ArrayList<>());
alertListener.handleEvent(event);
verify(persistentStore).add(eq("alerts"), any(PersistentItem.class));
}
Aggregations