use of org.graylog.events.notifications.types.HTTPEventNotificationConfig in project graylog2-server by Graylog2.
the class V20191129134600_CreateInitialUrlWhitelist method extractFromNotification.
private Optional<WhitelistEntry> extractFromNotification(NotificationDto notificationDto) {
final EventNotificationConfig config = notificationDto.config();
String url = "";
if (config instanceof HTTPEventNotificationConfig) {
url = ((HTTPEventNotificationConfig) config).url();
} else if (config instanceof LegacyAlarmCallbackEventNotificationConfig) {
url = Objects.toString(((LegacyAlarmCallbackEventNotificationConfig) config).configuration().get("url"), "");
}
if (StringUtils.isNotBlank(url)) {
return defaultIfNotMatching(LiteralWhitelistEntry.create(UUID.randomUUID().toString(), "\"" + notificationDto.title() + "\" alert notification", url), url);
} else {
return Optional.empty();
}
}
use of org.graylog.events.notifications.types.HTTPEventNotificationConfig in project graylog2-server by Graylog2.
the class NotificationDtoTest method testValidateHttpWithEmptyConfigParameters.
@Test
public void testValidateHttpWithEmptyConfigParameters() {
final HTTPEventNotificationConfig emptyConfig = HTTPEventNotificationConfig.Builder.create().url("").build();
final NotificationDto emptyNotification = getHttpNotification().toBuilder().config(emptyConfig).build();
final ValidationResult validationResult = emptyNotification.validate();
assertThat(validationResult.failed()).isTrue();
assertThat(validationResult.getErrors()).containsOnlyKeys("url");
}
Aggregations