use of org.graylog2.plugin.inputs.Converter in project graylog2-server by Graylog2.
the class FlexibleDateConverterTest method convertUsesEtcUTCIfTimeZoneSettingIsNotAString.
@Test
public void convertUsesEtcUTCIfTimeZoneSettingIsNotAString() throws Exception {
Converter c = new FlexibleDateConverter(ImmutableMap.<String, Object>of("time_zone", 42));
final DateTime dateOnly = (DateTime) c.convert("2014-3-12");
assertThat(dateOnly.getZone()).isEqualTo(DateTimeZone.forID("Etc/UTC"));
}
use of org.graylog2.plugin.inputs.Converter in project graylog2-server by Graylog2.
the class FlexibleDateConverterTest method convertUsesEtcUTCIfTimeZoneSettingIsInvalid.
@Test
public void convertUsesEtcUTCIfTimeZoneSettingIsInvalid() throws Exception {
Converter c = new FlexibleDateConverter(ImmutableMap.<String, Object>of("time_zone", "TEST"));
final DateTime dateOnly = (DateTime) c.convert("2014-3-12");
assertThat(dateOnly.getZone()).isEqualTo(DateTimeZone.forID("Etc/UTC"));
}
use of org.graylog2.plugin.inputs.Converter in project graylog2-server by Graylog2.
the class HashConverterTest method testConvert.
@Test
public void testConvert() throws Exception {
Converter hc = new HashConverter(new HashMap<String, Object>());
assertNull(hc.convert(null));
assertEquals("", hc.convert(""));
assertEquals("c029b5a72ae255853d7151a9e28c6260", hc.convert("graylog2"));
}
use of org.graylog2.plugin.inputs.Converter in project graylog2-server by Graylog2.
the class LowercaseConverterTest method testConvert.
@Test
public void testConvert() throws Exception {
Converter c = new LowercaseConverter(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 NumericConverterTest method testConvert.
@Test
public void testConvert() throws Exception {
Converter hc = new NumericConverter(new HashMap<String, Object>());
assertNull(hc.convert(null));
assertEquals("", hc.convert(""));
assertEquals("lol no number", hc.convert("lol no number"));
assertEquals(9001, hc.convert("9001"));
assertEquals(2147483648L, hc.convert("2147483648"));
assertEquals(10.4D, hc.convert("10.4"));
assertEquals(Integer.class, hc.convert("4").getClass());
}
Aggregations