use of org.graylog2.inputs.extractors.RegexReplaceExtractor in project graylog2-server by Graylog2.
the class RegexReplaceExtractorTest method testReplacementWithTooManyPlaceholders.
@Test(expected = RuntimeException.class)
public void testReplacementWithTooManyPlaceholders() throws Exception {
final Message message = new Message("Foobar 123", "source", Tools.nowUTC());
final RegexReplaceExtractor extractor = new RegexReplaceExtractor(metricRegistry, "id", "title", 0L, Extractor.CursorStrategy.COPY, "message", "message", ImmutableMap.<String, Object>of("regex", "Foobar (\\d+)", "replacement", "$1 $2"), "user", Collections.<Converter>emptyList(), Extractor.ConditionType.NONE, null);
extractor.runExtractor(message);
}
use of org.graylog2.inputs.extractors.RegexReplaceExtractor in project graylog2-server by Graylog2.
the class RegexReplaceExtractorTest method testReplacementWithCustomReplacement.
@Test
public void testReplacementWithCustomReplacement() throws Exception {
final Message message = new Message("Foobar 123", "source", Tools.nowUTC());
final RegexReplaceExtractor extractor = new RegexReplaceExtractor(metricRegistry, "id", "title", 0L, Extractor.CursorStrategy.COPY, "message", "message", ImmutableMap.<String, Object>of("regex", "(Foobar) (\\d+)", "replacement", "$2/$1"), "user", Collections.<Converter>emptyList(), Extractor.ConditionType.NONE, null);
extractor.runExtractor(message);
assertThat(message.getMessage()).isEqualTo("123/Foobar");
}
Aggregations