use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestDateParser method test1.
@Test
public void test1() throws ProcessorException {
DateParser parse = new DateParser();
parse.setPattern("ISO_DATE_TIME");
parse.setField("field");
Assert.assertTrue(parse.configure(new Properties(Collections.emptyMap())));
Event event = Tools.getEvent();
event.put("field", DateTimeFormatter.ISO_DATE_TIME.format(ZonedDateTime.now()));
parse.process(event);
assertTrue("date not parsed", event.get("field") instanceof Date);
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestDateParser method testIncomplete.
@Test
public void testIncomplete() throws ProcessorException {
DateParser parse = new DateParser();
parse.setPattern("MMM dd HH:mm:ss");
parse.setTimezone("Z");
parse.setField("field");
Assert.assertTrue(parse.configure(new Properties(Collections.emptyMap())));
Event event = Tools.getEvent();
event.put("field", "Jul 26 16:40:22");
parse.process(event);
Date date = (Date) event.get("field");
OffsetDateTime t = OffsetDateTime.ofInstant(date.toInstant(), ZoneId.of("GMT"));
int year = OffsetDateTime.now().get(ChronoField.YEAR);
Assert.assertEquals("date not parsed", year, t.getLong(ChronoField.YEAR));
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestDateParser method testAgain.
@Test
public void testAgain() throws ProcessorException {
DateParser parse = new DateParser();
parse.setPattern("yyyy-MM-dd'T'HH:m:ss.SSSxx");
parse.setTimezone("CET");
parse.setField("field");
Assert.assertTrue(parse.configure(new Properties(Collections.emptyMap())));
Event event = Tools.getEvent();
event.put("field", "2016-08-04T18:57:37.238+0000");
parse.process(event);
Date date = (Date) event.get("field");
OffsetDateTime t = OffsetDateTime.ofInstant(date.toInstant(), ZoneId.of("GMT"));
Assert.assertEquals("date not parsed", 18, t.getLong(ChronoField.HOUR_OF_DAY));
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestEtl method test2.
@Test
public void test2() throws ProcessorException {
Etl etl = new Etl.Remove();
etl.setLvalue(new String[] { "a" });
boolean done = etl.configure(new Properties(Collections.emptyMap()));
Assert.assertTrue("configuration failed", done);
Event event = Tools.getEvent();
event.put("a", 0);
etl.process(event);
Assert.assertEquals("evaluation failed", null, event.applyAtPath((i, j, k) -> i.get(j), new String[] { "a" }, null, false));
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestEtl method test3.
@Test
public void test3() throws ProcessorException {
Etl.Rename etl = new Etl.Rename();
etl.setLvalue(new String[] { "b" });
etl.setSource(new String[] { "a" });
boolean done = etl.configure(new Properties(Collections.emptyMap()));
Assert.assertTrue("configuration failed", done);
Event event = Tools.getEvent();
event.put("a", 0);
etl.process(event);
Assert.assertEquals("evaluation failed", 0, event.applyAtPath((i, j, k) -> i.get(j), new String[] { "b" }, null, false));
}
Aggregations