use of org.graylog2.plugin.inputs.Converter in project graylog2-server by Graylog2.
the class SyslogPriLevelConverterTest method testConvert.
@Test
public void testConvert() throws Exception {
Converter hc = new SyslogPriLevelConverter(new HashMap<String, Object>());
assertNull(hc.convert(null));
assertEquals("", hc.convert(""));
assertEquals("lol no number", hc.convert("lol no number"));
// info
assertEquals(6, hc.convert("14"));
// warning
assertEquals(4, hc.convert("12"));
// debug
assertEquals(7, hc.convert("7"));
// debug
assertEquals(7, hc.convert("87"));
// notice
assertEquals(5, hc.convert("5"));
}
use of org.graylog2.plugin.inputs.Converter in project graylog2-server by Graylog2.
the class TokenizerConverterTest method testConvert.
@Test
public void testConvert() throws Exception {
Converter hc = new TokenizerConverter(new HashMap<String, Object>());
assertNull(hc.convert(null));
assertEquals("", hc.convert(""));
}
use of org.graylog2.plugin.inputs.Converter in project graylog2-server by Graylog2.
the class UppercaseConverterTest method testConvert.
@Test
public void testConvert() throws Exception {
Converter c = new UppercaseConverter(new HashMap<String, Object>());
assertNull(c.convert(null));
assertEquals("", c.convert(""));
assertEquals("FOOBAR", c.convert("foobar"));
assertEquals("FOO BAR", c.convert("foo BAR"));
assertEquals("FOOBAR", c.convert("FooBar"));
assertEquals("FOOBAR ", c.convert("foobar "));
assertEquals(" FOOBAR", c.convert(" foobar"));
assertEquals("FOOBAR", c.convert("FOOBAR"));
}
use of org.graylog2.plugin.inputs.Converter in project graylog2-server by Graylog2.
the class RegexReplaceExtractorTest method testReplacementWithReplaceAll.
@Test
public void testReplacementWithReplaceAll() throws Exception {
final Message message = new Message("Foobar 123 Foobaz 456", "source", Tools.nowUTC());
final RegexReplaceExtractor extractor = new RegexReplaceExtractor(metricRegistry, "id", "title", 0L, Extractor.CursorStrategy.COPY, "message", "message", ImmutableMap.<String, Object>of("regex", "(\\w+) (\\d+)", "replacement", "$2/$1", "replace_all", true), "user", Collections.<Converter>emptyList(), Extractor.ConditionType.NONE, null);
extractor.runExtractor(message);
assertThat(message.getMessage()).isEqualTo("123/Foobar 456/Foobaz");
}
use of org.graylog2.plugin.inputs.Converter in project graylog2-server by Graylog2.
the class RegexReplaceExtractorTest method testReplacementWithNoMatchAndDefaultReplacement.
@Test
public void testReplacementWithNoMatchAndDefaultReplacement() throws Exception {
final Message message = new Message("Test", "source", Tools.nowUTC());
final RegexReplaceExtractor extractor = new RegexReplaceExtractor(metricRegistry, "id", "title", 0L, Extractor.CursorStrategy.COPY, "message", "message", ImmutableMap.<String, Object>of("regex", "NO-MATCH"), "user", Collections.<Converter>emptyList(), Extractor.ConditionType.NONE, null);
extractor.runExtractor(message);
assertThat(message.getMessage()).isEqualTo("Test");
}
Aggregations