use of org.codice.ddf.persistence.PersistenceException in project ddf by codice.
the class AlertListener method addAlertToStore.
private void addAlertToStore(Alert alert) {
PersistentItem item = new PersistentItem();
alert.getProperties().forEach((name, value) -> item.addProperty(name, value));
try {
persistentStore.add(CORE_NAME, item);
} catch (PersistenceException e) {
LOGGER.error("Failed to persist alert.");
}
}
use of org.codice.ddf.persistence.PersistenceException in project ddf by codice.
the class StoreCommandTest method testPersistenceException.
/**
* Check for listing command.
*/
@Test
public void testPersistenceException() throws PersistenceException {
// given
when(persistentStore.get(anyString(), any(), eq(0), anyInt())).thenThrow(new PersistenceException());
StoreListCommand command = new StoreListCommand();
command.persistentStore = persistentStore;
command.type = "preferences";
command.execute();
// then
assertThat(consoleOutput.getOutput(), containsString("Encountered an error when"));
}
use of org.codice.ddf.persistence.PersistenceException in project ddf by codice.
the class AdminAlertImplTest method testGetAlertsPersistentStoreError.
@Test
public void testGetAlertsPersistentStoreError() throws Exception {
when(persistentStore.get(eq("alerts"), any())).thenThrow(new PersistenceException("error"));
List<Map<String, Object>> alertList = adminAlert.getAlerts();
assertThat(alertList.size(), equalTo(1));
assertThat(alertList.get(0).get(Alert.SYSTEM_NOTICE_SOURCE_KEY), equalTo("unable_to_retrieve_alerts"));
}
Aggregations