Search in sources :

Example 16 with EvaluationContext

use of org.graylog.plugins.pipelineprocessor.EvaluationContext in project graylog2-server by Graylog2.

the class FunctionsSnippetsTest method keyValueFailure.

@Test
public void keyValueFailure() {
    final Rule rule = parser.parseRule(ruleForTest(), true);
    final EvaluationContext context = contextForRuleEval(rule, new Message("", "", Tools.nowUTC()));
    assertThat(context.hasEvaluationErrors()).isTrue();
}
Also used : CreateMessage(org.graylog.plugins.pipelineprocessor.functions.messages.CreateMessage) CloneMessage(org.graylog.plugins.pipelineprocessor.functions.messages.CloneMessage) DropMessage(org.graylog.plugins.pipelineprocessor.functions.messages.DropMessage) Message(org.graylog2.plugin.Message) MockitoRule(org.mockito.junit.MockitoRule) Rule(org.graylog.plugins.pipelineprocessor.ast.Rule) EvaluationContext(org.graylog.plugins.pipelineprocessor.EvaluationContext) BaseParserTest(org.graylog.plugins.pipelineprocessor.BaseParserTest) Test(org.junit.Test)

Example 17 with EvaluationContext

use of org.graylog.plugins.pipelineprocessor.EvaluationContext in project graylog2-server by Graylog2.

the class FunctionsSnippetsTest method comparisons.

@Test
public void comparisons() {
    final Rule rule = parser.parseRule(ruleForTest(), false);
    final EvaluationContext context = contextForRuleEval(rule, new Message("", "", Tools.nowUTC()));
    assertThat(context.hasEvaluationErrors()).isFalse();
    assertThat(evaluateRule(rule)).isNotNull();
    assertThat(actionsTriggered.get()).isTrue();
}
Also used : CreateMessage(org.graylog.plugins.pipelineprocessor.functions.messages.CreateMessage) CloneMessage(org.graylog.plugins.pipelineprocessor.functions.messages.CloneMessage) DropMessage(org.graylog.plugins.pipelineprocessor.functions.messages.DropMessage) Message(org.graylog2.plugin.Message) MockitoRule(org.mockito.junit.MockitoRule) Rule(org.graylog.plugins.pipelineprocessor.ast.Rule) EvaluationContext(org.graylog.plugins.pipelineprocessor.EvaluationContext) BaseParserTest(org.graylog.plugins.pipelineprocessor.BaseParserTest) Test(org.junit.Test)

Aggregations

EvaluationContext (org.graylog.plugins.pipelineprocessor.EvaluationContext)17 Message (org.graylog2.plugin.Message)15 Test (org.junit.Test)15 Rule (org.graylog.plugins.pipelineprocessor.ast.Rule)9 BaseParserTest (org.graylog.plugins.pipelineprocessor.BaseParserTest)8 FunctionArgs (org.graylog.plugins.pipelineprocessor.ast.functions.FunctionArgs)8 CloneMessage (org.graylog.plugins.pipelineprocessor.functions.messages.CloneMessage)8 CreateMessage (org.graylog.plugins.pipelineprocessor.functions.messages.CreateMessage)8 DropMessage (org.graylog.plugins.pipelineprocessor.functions.messages.DropMessage)8 MockitoRule (org.mockito.junit.MockitoRule)8 CommonToken (org.antlr.v4.runtime.CommonToken)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 RemoveFromStream (org.graylog.plugins.pipelineprocessor.functions.messages.RemoveFromStream)2 RouteToStream (org.graylog.plugins.pipelineprocessor.functions.messages.RouteToStream)2 Stream (org.graylog2.plugin.streams.Stream)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 ImmutableList (com.google.common.collect.ImmutableList)1 Ints (com.google.common.primitives.Ints)1