AlertsUIServiceImpl implements AlertsUIService { @Override public boolean deleteAlertsUIUserSettings(String user) { boolean success = true; try { userSettingsClient.delete(user, ALERT_USER_SETTING_TYPE); } catch (IOException e) { success = false; } return success; } @Autowired  AlertsUIServiceImpl(final KafkaService kafkaService,
                             final Environment environment,
                             final UserSettingsClient userSettingsClient); @Override void escalateAlerts(List<Map<String, Object>> alerts); @Override Optional<AlertsUIUserSettings> getAlertsUIUserSettings(); @Override Map<String, AlertsUIUserSettings> findAllAlertsUIUserSettings(); @Override void saveAlertsUIUserSettings(AlertsUIUserSettings alertsUIUserSettings); @Override boolean deleteAlertsUIUserSettings(String user); void setClock(Clock clock); static final String ALERT_USER_SETTING_TYPE; static ThreadLocal<ObjectMapper> _mapper; }
@Test public void deleteShouldProperlyDeleteActiveProfile() throws Exception { assertTrue(alertsUIService.deleteAlertsUIUserSettings(user1)); doThrow(new IOException()).when(userSettingsClient).delete(user1, AlertsUIServiceImpl.ALERT_USER_SETTING_TYPE); assertFalse(alertsUIService.deleteAlertsUIUserSettings(user1)); verify(userSettingsClient, times(2)).delete(user1, AlertsUIServiceImpl.ALERT_USER_SETTING_TYPE); verifyNoMoreInteractions(userSettingsClient); }