use of org.graylog2.plugin.inputs.Converter in project graylog2-server by Graylog2.
the class DateConverterTest method convertUsesEtcUTCIfTimeZoneSettingIsInvalid.
@Test
public void convertUsesEtcUTCIfTimeZoneSettingIsInvalid() throws Exception {
final Converter c = new DateConverter(config("YYYY-MM-dd HH:mm:ss", "TEST"));
final DateTime dateOnly = (DateTime) c.convert("2014-03-12 10:00:00");
assertThat(dateOnly.getZone()).isEqualTo(DateTimeZone.forID("Etc/UTC"));
}
use of org.graylog2.plugin.inputs.Converter in project graylog2-server by Graylog2.
the class DateConverterTest method issue2648.
/**
* Test case for <a href="https://github.com/Graylog2/graylog2-server/issues/2648">#2648</a>.
*/
@Test
public void issue2648() throws Exception {
final Converter utc = new DateConverter(config("YYYY-MM-dd HH:mm:ss", "UTC"));
final DateTime utcDate = (DateTime) utc.convert("2016-08-10 12:00:00");
assertThat(utcDate.getZone()).isEqualTo(DateTimeZone.UTC);
assertThat(utcDate.getZone().getOffsetFromLocal(0L)).isEqualTo(0);
final Converter cet = new DateConverter(config("YYYY-MM-dd HH:mm:ss", "CET"));
final DateTime cetDate = (DateTime) cet.convert("2016-08-10 12:00:00");
assertThat(cetDate.getZone()).isEqualTo(DateTimeZone.forID("CET"));
assertThat(cetDate.getZone().getOffsetFromLocal(0L)).isEqualTo((int) Duration.standardHours(1L).getMillis());
final Converter berlin = new DateConverter(config("YYYY-MM-dd HH:mm:ss", "Europe/Berlin"));
final DateTime berlinDate = (DateTime) berlin.convert("2016-08-10 12:00:00");
assertThat(berlinDate.getZone()).isEqualTo(DateTimeZone.forID("Europe/Berlin"));
assertThat(berlinDate.getZone().getOffsetFromLocal(0L)).isEqualTo((int) Duration.standardHours(1L).getMillis());
}
use of org.graylog2.plugin.inputs.Converter in project graylog2-server by Graylog2.
the class JsonExtractorTest method testRunWithFlattenedObjectAndDifferentKVSeparator.
@Test
public void testRunWithFlattenedObjectAndDifferentKVSeparator() throws Exception {
final JsonExtractor jsonExtractor = new JsonExtractor(new MetricRegistry(), "json", "title", 0L, Extractor.CursorStrategy.COPY, "source", "target", ImmutableMap.<String, Object>of("flatten", true, "kv_separator", ":"), "user", Collections.<Converter>emptyList(), Extractor.ConditionType.NONE, "");
final String value = "{\"object\": {\"text\": \"foobar\", \"number\": 1234.5678, \"bool\": true, \"nested\": {\"text\": \"foobar\"}}}";
final Extractor.Result[] results = jsonExtractor.run(value);
assertThat(results).contains(new Extractor.Result("text:foobar, number:1234.5678, bool:true, nested:{text=foobar}", "object", -1, -1));
}
use of org.graylog2.plugin.inputs.Converter in project graylog2-server by Graylog2.
the class FlexibleDateConverterTest method convertUsesEtcUTCIfTimeZoneSettingIsEmpty.
@Test
public void convertUsesEtcUTCIfTimeZoneSettingIsEmpty() throws Exception {
Converter c = new FlexibleDateConverter(ImmutableMap.<String, Object>of("time_zone", ""));
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 IPAnonymizerConverterTest method testConvert.
@Test
public void testConvert() throws Exception {
Converter hc = new IPAnonymizerConverter(new HashMap<String, Object>());
assertNull(hc.convert(null));
assertEquals("", hc.convert(""));
assertEquals("lol no IP in here", hc.convert("lol no IP in here"));
assertEquals("127.0.1", hc.convert("127.0.1"));
assertEquals("127.0.0.xxx", hc.convert("127.0.0.xxx"));
assertEquals("127.0.0.xxx", hc.convert("127.0.0.1"));
assertEquals("127.0.0.xxx foobar 192.168.1.xxx test", hc.convert("127.0.0.1 foobar 192.168.1.100 test"));
}
Aggregations