use of loghub.ProcessorException 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.ProcessorException 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));
}
use of loghub.ProcessorException 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.ProcessorException in project LogHub by fbacchella.
the class Groovy method process.
@Override
public boolean process(Event event) throws ProcessorException {
Binding groovyBinding = new Binding();
groovyBinding.setVariable("event", event);
groovyScript.setBinding(groovyBinding);
try {
return Boolean.TRUE.equals(groovyScript.run());
} catch (Exception e) {
throw event.buildException("groovy script failed", e);
}
}
Aggregations