use of org.graylog2.plugin.rest.ValidationResult in project graylog2-server by Graylog2.
the class EventDefinitionDtoTest method testValidateWithInvalidConfig.
@Test
public void testValidateWithInvalidConfig() {
final AggregationEventProcessorConfig configMock = mock(AggregationEventProcessorConfig.class);
final ValidationResult mockedValidationResult = new ValidationResult();
mockedValidationResult.addError("foo", "bar");
when(configMock.validate()).thenReturn(mockedValidationResult);
final EventDefinitionDto invalidEventDefinition = testSubject.toBuilder().config(configMock).build();
final ValidationResult validationResult = invalidEventDefinition.validate();
assertThat(validationResult.failed()).isTrue();
assertThat(validationResult.getErrors()).containsOnlyKeys("foo");
}
use of org.graylog2.plugin.rest.ValidationResult in project graylog2-server by Graylog2.
the class EventDefinitionDtoTest method testValidEventDefinitionWithKeySpecInFieldSpec.
@Test
public void testValidEventDefinitionWithKeySpecInFieldSpec() {
final EventFieldSpec fieldSpecMock = mock(EventFieldSpec.class);
final EventDefinitionDto invalidEventDefinition = testSubject.toBuilder().fieldSpec(ImmutableMap.of("foo", fieldSpecMock, "bar", fieldSpecMock)).keySpec(ImmutableList.of("foo", "bar")).build();
final ValidationResult validationResult = invalidEventDefinition.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 EventDefinitionDtoTest method testValidateWithKeySpecNotInFieldSpec.
@Test
public void testValidateWithKeySpecNotInFieldSpec() {
final EventFieldSpec fieldSpecMock = mock(EventFieldSpec.class);
final EventDefinitionDto invalidEventDefinition = testSubject.toBuilder().fieldSpec(ImmutableMap.of("bar", fieldSpecMock, "baz", fieldSpecMock)).keySpec(ImmutableList.of("foo")).build();
final ValidationResult validationResult = invalidEventDefinition.validate();
assertThat(validationResult.failed()).isTrue();
assertThat(validationResult.getErrors()).containsOnlyKeys("key_spec");
}
use of org.graylog2.plugin.rest.ValidationResult in project graylog2-server by Graylog2.
the class EventDefinitionDtoTest method testValidEventDefinition.
@Test
public void testValidEventDefinition() {
final ValidationResult validationResult = testSubject.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 AggregationEventProcessorConfigTest method testValidConfiguration.
@Test
public void testValidConfiguration() {
final ValidationResult validationResult = getConfig().validate();
assertThat(validationResult.failed()).isFalse();
assertThat(validationResult.getErrors().size()).isEqualTo(0);
}
Aggregations