use of org.apache.metron.rest.model.AlertsUIUserSettings in project metron by apache.
the class AlertsUIServiceImplTest method saveShouldProperlySaveActiveProfile.
@Test
public void saveShouldProperlySaveActiveProfile() throws Exception {
AlertsUIUserSettings alertsUIUserSettings = new AlertsUIUserSettings();
alertsUIUserSettings.setTableColumns(Collections.singletonList("user1_field"));
alertsUIService.saveAlertsUIUserSettings(alertsUIUserSettings);
String expectedAlertUserSettings = _mapper.get().writeValueAsString(alertsUIUserSettings);
verify(userSettingsClient, times(1)).save(user1, AlertsUIServiceImpl.ALERT_USER_SETTING_TYPE, expectedAlertUserSettings);
verifyNoMoreInteractions(userSettingsClient);
}
use of org.apache.metron.rest.model.AlertsUIUserSettings in project metron by apache.
the class AlertsUIServiceImplTest method findAllShouldProperlyReturnActiveProfiles.
@Test
public void findAllShouldProperlyReturnActiveProfiles() throws Exception {
AlertsUIUserSettings alertsProfile1 = new AlertsUIUserSettings();
alertsProfile1.setUser(user1);
AlertsUIUserSettings alertsProfile2 = new AlertsUIUserSettings();
alertsProfile2.setUser(user1);
when(userSettingsClient.findAll(AlertsUIServiceImpl.ALERT_USER_SETTING_TYPE)).thenReturn(new HashMap<String, Optional<String>>() {
{
put(user1, Optional.of(user1AlertUserSettings));
put(user2, Optional.of(user2AlertUserSettings));
}
});
AlertsUIUserSettings expectedAlertsUIUserSettings1 = new AlertsUIUserSettings();
expectedAlertsUIUserSettings1.setTableColumns(Collections.singletonList("user1_field"));
AlertsUIUserSettings expectedAlertsUIUserSettings2 = new AlertsUIUserSettings();
expectedAlertsUIUserSettings2.setTableColumns(Collections.singletonList("user2_field"));
Map<String, AlertsUIUserSettings> actualAlertsProfiles = alertsUIService.findAllAlertsUIUserSettings();
assertEquals(2, actualAlertsProfiles.size());
assertEquals(expectedAlertsUIUserSettings1, actualAlertsProfiles.get(user1));
assertEquals(expectedAlertsUIUserSettings2, actualAlertsProfiles.get(user2));
verify(userSettingsClient, times(1)).findAll(AlertsUIServiceImpl.ALERT_USER_SETTING_TYPE);
verifyNoMoreInteractions(userSettingsClient);
}
use of org.apache.metron.rest.model.AlertsUIUserSettings in project metron by apache.
the class AlertsUIServiceImplTest method getShouldProperlyReturnActiveProfile.
@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);
}
use of org.apache.metron.rest.model.AlertsUIUserSettings in project metron by apache.
the class SearchServiceImplTest method searchShouldProperlySearchWithUserSettingsFacetFields.
@Test
public void searchShouldProperlySearchWithUserSettingsFacetFields() throws Exception {
AlertsUIUserSettings alertsUIUserSettings = new AlertsUIUserSettings();
alertsUIUserSettings.setFacetFields(Arrays.asList("source:type", "ip_dst_addr"));
when(alertsUIService.getAlertsUIUserSettings()).thenReturn(Optional.of(alertsUIUserSettings));
SearchRequest searchRequest = new SearchRequest();
searchRequest.setIndices(Arrays.asList("bro", "snort", "metaalert"));
searchRequest.setFacetFields(new ArrayList<>());
searchService.search(searchRequest);
SearchRequest expectedSearchRequest = new SearchRequest();
expectedSearchRequest.setIndices(Arrays.asList("bro", "snort", "metaalert"));
expectedSearchRequest.setFacetFields(Arrays.asList("source:type", "ip_dst_addr"));
verify(dao).search(eq(expectedSearchRequest));
}
Aggregations