use of org.graylog2.plugin.rest.ValidationResult in project graylog2-server by Graylog2.
the class AggregationEventProcessorConfigTest method testValidateWithIncompleteAggregationOptions.
@Test
public void testValidateWithIncompleteAggregationOptions() {
AggregationEventProcessorConfig invalidConfig = getConfig().toBuilder().groupBy(ImmutableList.of("foo")).build();
ValidationResult validationResult = invalidConfig.validate();
assertThat(validationResult.failed()).isTrue();
assertThat(validationResult.getErrors()).containsOnlyKeys("series", "conditions");
invalidConfig = getConfig().toBuilder().series(ImmutableList.of(this.getSeries())).build();
validationResult = invalidConfig.validate();
assertThat(validationResult.failed()).isTrue();
assertThat(validationResult.getErrors()).containsOnlyKeys("conditions");
invalidConfig = getConfig().toBuilder().conditions(this.getConditions()).build();
validationResult = invalidConfig.validate();
assertThat(validationResult.failed()).isTrue();
assertThat(validationResult.getErrors()).containsOnlyKeys("series");
}
use of org.graylog2.plugin.rest.ValidationResult in project graylog2-server by Graylog2.
the class AggregationEventProcessorConfigTest method testValidateWithInvalidTimeRange.
@Test
public void testValidateWithInvalidTimeRange() {
final AggregationEventProcessorConfig invalidConfig1 = getConfig().toBuilder().searchWithinMs(-1).build();
final ValidationResult validationResult1 = invalidConfig1.validate();
assertThat(validationResult1.failed()).isTrue();
assertThat(validationResult1.getErrors()).containsOnlyKeys("search_within_ms");
final AggregationEventProcessorConfig invalidConfig2 = invalidConfig1.toBuilder().searchWithinMs(0).build();
final ValidationResult validationResult2 = invalidConfig2.validate();
assertThat(validationResult2.failed()).isTrue();
assertThat(validationResult2.getErrors()).containsOnlyKeys("search_within_ms");
}
use of org.graylog2.plugin.rest.ValidationResult in project graylog2-server by Graylog2.
the class NotificationDtoTest method testValidLegacyNotification.
@Test
public void testValidLegacyNotification() {
final NotificationDto validNotification = getLegacyNotification();
final ValidationResult validationResult = validNotification.validate();
assertThat(validationResult.failed()).isFalse();
assertThat(validationResult.getErrors().size()).isEqualTo(0);
}
use of org.graylog2.plugin.rest.ValidationResult in project graylog2-server by Graylog2.
the class NotificationDtoTest method testValidEmailNotification.
@Test
public void testValidEmailNotification() {
final NotificationDto validNotification = getEmailNotification();
final ValidationResult validationResult = validNotification.validate();
assertThat(validationResult.failed()).isFalse();
assertThat(validationResult.getErrors().size()).isEqualTo(0);
}
use of org.graylog2.plugin.rest.ValidationResult in project graylog2-server by Graylog2.
the class NotificationDtoTest method testValidateWithEmptyConfig.
@Test
public void testValidateWithEmptyConfig() {
final NotificationDto invalidNotification = NotificationDto.builder().title("Foo").description("").config(new EventNotificationConfig.FallbackNotificationConfig()).build();
final ValidationResult validationResult = invalidNotification.validate();
assertThat(validationResult.failed()).isTrue();
assertThat(validationResult.getErrors()).containsOnlyKeys("config");
}
Aggregations