use of org.graylog2.plugin.database.ValidationException in project graylog2-server by Graylog2.
the class GrokPatternFacadeTest method delete.
@Test
public void delete() throws ValidationException {
final GrokPattern grokPattern = grokPatternService.save(GrokPattern.create("Test1", "[a-z]+"));
grokPatternService.save(GrokPattern.create("Test2", "[a-z]+"));
assertThat(grokPatternService.loadAll()).hasSize(2);
facade.delete(grokPattern);
assertThat(grokPatternService.loadAll()).hasSize(1);
}
use of org.graylog2.plugin.database.ValidationException in project graylog2-server by Graylog2.
the class GrokPatternFacadeTest method findExistingFailsWithDivergingPatterns.
@Test
public void findExistingFailsWithDivergingPatterns() throws ValidationException {
grokPatternService.save(GrokPattern.create("Test", "[a-z]+"));
final Entity grokPatternEntity = EntityV1.builder().id(ModelId.of("1")).type(ModelTypes.GROK_PATTERN_V1).data(objectMapper.convertValue(GrokPatternEntity.create("Test", "BOOM"), JsonNode.class)).build();
assertThatThrownBy(() -> facade.findExisting(grokPatternEntity, Collections.emptyMap())).isInstanceOf(DivergingEntityConfigurationException.class).hasMessage("Expected Grok pattern for name \"Test\": <BOOM>; actual Grok pattern: <[a-z]+>");
}
use of org.graylog2.plugin.database.ValidationException in project graylog2-server by Graylog2.
the class V20191121145100_FixDefaultGrokPatternsTest method patternWasModified.
@Test
public void patternWasModified() throws ValidationException {
final GrokPattern pattern = GrokPattern.builder().name(PATTERN_NAME).pattern("modified").build();
when(grokPatternService.loadByName(PATTERN_NAME)).thenReturn(Optional.of(pattern));
migration.upgrade();
verify(grokPatternService, never()).update(any(GrokPattern.class));
verify(configService).write(MigrationCompleted.create(Collections.singleton(PATTERN_NAME)));
}
use of org.graylog2.plugin.database.ValidationException in project graylog2-server by Graylog2.
the class InputFacade method addExtractor.
private Extractor addExtractor(final Input input, final String title, final int order, final Extractor.CursorStrategy cursorStrategy, final Extractor.Type type, final String sourceField, final String targetField, final Map<String, Object> configuration, final List<Converter> converters, final Extractor.ConditionType conditionType, final String conditionValue, final String username) throws ValidationException, org.graylog2.ConfigurationException, ExtractorFactory.NoSuchExtractorException, Extractor.ReservedFieldException {
final String extractorId = UUID.randomUUID().toString();
final Extractor extractor = extractorFactory.factory(extractorId, title, order, cursorStrategy, type, sourceField, targetField, configuration, username, converters, conditionType, conditionValue);
inputService.addExtractor(input, extractor);
return extractor;
}
use of org.graylog2.plugin.database.ValidationException in project graylog2-server by Graylog2.
the class InputFacade method createExtractors.
private List<Extractor> createExtractors(final Input input, final List<ExtractorEntity> extractorEntities, final String username, final Map<String, ValueReference> parameters) throws Extractor.ReservedFieldException, org.graylog2.ConfigurationException, ExtractorFactory.NoSuchExtractorException, ValidationException {
final ImmutableList.Builder<Extractor> result = ImmutableList.builder();
for (ExtractorEntity extractorEntity : extractorEntities) {
final List<Converter> converters = createConverters(extractorEntity.converters(), parameters);
final Extractor extractor = addExtractor(input, extractorEntity.title().asString(parameters), extractorEntity.order().asInteger(parameters), extractorEntity.cursorStrategy().asEnum(parameters, Extractor.CursorStrategy.class), extractorEntity.type().asEnum(parameters, Extractor.Type.class), extractorEntity.sourceField().asString(parameters), extractorEntity.targetField().asString(parameters), toValueMap(extractorEntity.configuration(), parameters), converters, extractorEntity.conditionType().asEnum(parameters, Extractor.ConditionType.class), extractorEntity.conditionValue().asString(parameters), username);
result.add(extractor);
}
return result.build();
}
Aggregations