use of loghub.Event in project LogHub by fbacchella.
the class TestEtl method test1.
@Test
public void test1() throws ProcessorException {
Etl.Assign etl = new Etl.Assign();
etl.setLvalue(new String[] { "a", "b" });
etl.setExpression("event.c + 1");
boolean done = etl.configure(new Properties(Collections.emptyMap()));
Assert.assertTrue("configuration failed", done);
Event event = Tools.getEvent();
event.put("c", 0);
event.process(etl);
Assert.assertEquals("evaluation failed", 1, event.applyAtPath((i, j, k) -> i.get(j), new String[] { "a", "b" }, null, false));
}
use of loghub.Event in project LogHub by fbacchella.
the class TestEtl method test5.
@Test
public void test5() throws ProcessorException, InterruptedException, ConfigException, IOException {
Properties conf = Tools.loadConf("etl.conf");
for (Pipeline pipe : conf.pipelines) {
Assert.assertTrue("configuration failed", pipe.configure(conf));
}
Event sent = Tools.getEvent();
sent.put("a", "a");
Tools.runProcessing(sent, conf.namedPipeLine.get("main"), conf);
Assert.assertEquals("conversion not expected", "a", sent.get("a"));
}
use of loghub.Event in project LogHub by fbacchella.
the class TestEtl method test7.
@Test
public void test7() throws ProcessorException, InterruptedException, ConfigException, IOException {
Properties conf = Tools.loadConf("etl.conf");
for (Pipeline pipe : conf.pipelines) {
Assert.assertTrue("configuration failed", pipe.configure(conf));
}
Event sent = Tools.getEvent();
Map<String, Object> b = new HashMap<>(1);
b.put("c", 1);
sent.put("b", b);
Tools.runProcessing(sent, conf.namedPipeLine.get("third"), conf);
Assert.assertEquals("conversion not expected", 1, sent.get("a"));
}
use of loghub.Event in project LogHub by fbacchella.
the class TestEtl method test8.
@Test
public void test8() throws ProcessorException, InterruptedException, ConfigException, IOException {
Properties conf = Tools.loadConf("etl.conf");
for (Pipeline pipe : conf.pipelines) {
Assert.assertTrue("configuration failed", pipe.configure(conf));
}
Event sent = Tools.getEvent();
sent.setTimestamp(new Date(1));
Tools.runProcessing(sent, conf.namedPipeLine.get("timestamp"), conf);
Assert.assertEquals(new Date(0), sent.getTimestamp());
Assert.assertEquals(new Date(1), sent.get("reception_time"));
}
use of loghub.Event in project LogHub by fbacchella.
the class TestEtl method test4.
@Test
public void test4() throws ProcessorException {
Etl.Assign etl = new Etl.Assign();
etl.setLvalue(new String[] { "a" });
etl.setExpression("formatters.a.format(event)");
Map<String, String> formats = Collections.singletonMap("a", "${@timestamp%t<GMT>H}");
Map<String, Object> properties = new HashMap<>();
properties.put("__FORMATTERS", formats);
boolean done = etl.configure(new Properties(properties));
Assert.assertTrue("configuration failed", done);
Event event = Tools.getEvent();
event.setTimestamp(new Date(3600 * 1000));
event.process(etl);
Assert.assertEquals("evaluation failed", "01", event.get("a"));
}
Aggregations