use of org.apache.metron.stellar.dsl.Context in project metron by apache.
the class KafkaFunctionsIntegrationTest method run.
/**
* Runs a Stellar expression.
* @param expr The expression to run.
*/
private Object run(String expr) {
// make the global properties available to the function
Context context = new Context.Builder().with(Context.Capabilities.GLOBAL_CONFIG, () -> global).build();
FunctionResolver functionResolver = new SimpleFunctionResolver().withClass(KafkaFunctions.KafkaGet.class).withClass(KafkaFunctions.KafkaPut.class).withClass(KafkaFunctions.KafkaProps.class).withClass(KafkaFunctions.KafkaTail.class);
StellarProcessor processor = new StellarProcessor();
return processor.parse(expr, new DefaultVariableResolver(x -> variables.get(x), x -> variables.containsKey(x)), functionResolver, context);
}
use of org.apache.metron.stellar.dsl.Context in project metron by apache.
the class GeoEnrichmentFunctionsTest method run.
public Object run(String rule, Map<String, Object> variables) throws Exception {
StellarProcessor processor = new StellarProcessor();
Assert.assertTrue(rule + " not valid.", processor.validate(rule, context));
return processor.parse(rule, new DefaultVariableResolver(x -> variables.get(x), x -> variables.containsKey(x)), StellarFunctions.FUNCTION_RESOLVER(), context);
}
use of org.apache.metron.stellar.dsl.Context in project metron by apache.
the class SimpleHBaseEnrichmentFunctionsTest method run.
public Object run(String rule, Map<String, Object> variables) throws Exception {
StellarProcessor processor = new StellarProcessor();
Assert.assertTrue(rule + " not valid.", processor.validate(rule, context));
return processor.parse(rule, new DefaultVariableResolver(x -> variables.get(x), x -> variables.containsKey(x)), StellarFunctions.FUNCTION_RESOLVER(), context);
}
use of org.apache.metron.stellar.dsl.Context in project metron by apache.
the class MathFunctionsTest method run.
public static Object run(String rule, Map<String, Object> variables) {
Context context = Context.EMPTY_CONTEXT();
StellarProcessor processor = new StellarProcessor();
Assert.assertTrue(rule + " not valid.", processor.validate(rule, context));
return processor.parse(rule, new DefaultVariableResolver(v -> variables.get(v), v -> variables.containsKey(v)), StellarFunctions.FUNCTION_RESOLVER(), context);
}
use of org.apache.metron.stellar.dsl.Context in project metron by apache.
the class ShellFunctionsTest method testMap2Table.
@Test
public void testMap2Table() {
Map<String, Object> variables = ImmutableMap.of("map_field", ImmutableMap.of("field1", "val1", "field2", "val2"));
Context context = Context.EMPTY_CONTEXT();
Object out = run("SHELL_MAP2TABLE(map_field)", variables, context);
Assert.assertEquals(expectedMap2Table, out);
}
Aggregations