AlertsUIServiceImpl implements AlertsUIService { @Override public Optional<AlertsUIUserSettings> getAlertsUIUserSettings() throws RestException { try { Optional<String> alertUserSettings = userSettingsClient.findOne(SecurityUtils.getCurrentUser(), ALERT_USER_SETTING_TYPE); if (alertUserSettings.isPresent()) { return Optional.of(_mapper.get().readValue(alertUserSettings.get(), AlertsUIUserSettings.class)); } else { return Optional.empty(); } } catch (IOException e) { throw new RestException(e); } } @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 getShouldProperlyReturnActiveProfile() throws Exception { when(userSettingsClient.findOne(user1, AlertsUIServiceImpl.ALERT_USER_SETTING_TYPE)).thenReturn(Optional.of(user1AlertUserSettings)); AlertsUIUserSettings expectedAlertsUIUserSettings = new AlertsUIUserSettings(); expectedAlertsUIUserSettings.setTableColumns(Collections.singletonList("user1_field")); assertEquals(expectedAlertsUIUserSettings, alertsUIService.getAlertsUIUserSettings().get()); verify(userSettingsClient, times(1)).findOne(user1, AlertsUIServiceImpl.ALERT_USER_SETTING_TYPE); verifyNoMoreInteractions(userSettingsClient); }