Search in sources :

Example 6 with StringExpression

use of org.graylog.plugins.pipelineprocessor.ast.expressions.StringExpression in project graylog2-server by Graylog2.

the class CEFParserFunctionTest method evaluate_returns_null_for_empty_CEF_string.

@Test
public void evaluate_returns_null_for_empty_CEF_string() throws Exception {
    final Map<String, Expression> arguments = Collections.singletonMap(CEFParserFunction.VALUE, new StringExpression(new CommonToken(0), ""));
    final FunctionArgs functionArgs = new FunctionArgs(function, arguments);
    final Message message = new Message("__dummy", "__dummy", DateTime.parse("2010-07-30T16:03:25Z"));
    final EvaluationContext evaluationContext = new EvaluationContext(message);
    final CEFParserResult result = function.evaluate(functionArgs, evaluationContext);
    assertNull(result);
}
Also used : Message(org.graylog2.plugin.Message) BooleanExpression(org.graylog.plugins.pipelineprocessor.ast.expressions.BooleanExpression) StringExpression(org.graylog.plugins.pipelineprocessor.ast.expressions.StringExpression) Expression(org.graylog.plugins.pipelineprocessor.ast.expressions.Expression) StringExpression(org.graylog.plugins.pipelineprocessor.ast.expressions.StringExpression) FunctionArgs(org.graylog.plugins.pipelineprocessor.ast.functions.FunctionArgs) EvaluationContext(org.graylog.plugins.pipelineprocessor.EvaluationContext) CommonToken(org.antlr.v4.runtime.CommonToken) Test(org.junit.Test)

Aggregations

CommonToken (org.antlr.v4.runtime.CommonToken)6 EvaluationContext (org.graylog.plugins.pipelineprocessor.EvaluationContext)6 BooleanExpression (org.graylog.plugins.pipelineprocessor.ast.expressions.BooleanExpression)6 Expression (org.graylog.plugins.pipelineprocessor.ast.expressions.Expression)6 StringExpression (org.graylog.plugins.pipelineprocessor.ast.expressions.StringExpression)6 FunctionArgs (org.graylog.plugins.pipelineprocessor.ast.functions.FunctionArgs)6 Message (org.graylog2.plugin.Message)6 Test (org.junit.Test)6 MetricRegistry (com.codahale.metrics.MetricRegistry)1