Search in sources :

Example 1 with AndExpression

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

the class PrecedenceTest method andVsEquality.

@Test
public void andVsEquality() {
    final Rule rule = parseRule("rule \"test\" when true == false && true then end");
    final LogicalExpression when = rule.when();
    assertThat(when).isInstanceOf(AndExpression.class);
    AndExpression andExpr = (AndExpression) when;
    assertThat(andExpr.left()).isInstanceOf(EqualityExpression.class);
    assertThat(andExpr.right()).isInstanceOf(BooleanExpression.class);
}
Also used : LogicalExpression(org.graylog.plugins.pipelineprocessor.ast.expressions.LogicalExpression) AndExpression(org.graylog.plugins.pipelineprocessor.ast.expressions.AndExpression) Rule(org.graylog.plugins.pipelineprocessor.ast.Rule) BaseParserTest(org.graylog.plugins.pipelineprocessor.BaseParserTest) Test(org.junit.Test)

Example 2 with AndExpression

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

the class PrecedenceTest method notVsAndOr.

@Test
public void notVsAndOr() {
    final Rule rule = parseRule("rule \"test\" when !true && false then end");
    final LogicalExpression when = rule.when();
    assertThat(when).isInstanceOf(AndExpression.class);
    AndExpression and = (AndExpression) when;
    assertThat(and.left()).isInstanceOf(NotExpression.class);
    assertThat(and.right()).isInstanceOf(BooleanExpression.class);
}
Also used : LogicalExpression(org.graylog.plugins.pipelineprocessor.ast.expressions.LogicalExpression) AndExpression(org.graylog.plugins.pipelineprocessor.ast.expressions.AndExpression) Rule(org.graylog.plugins.pipelineprocessor.ast.Rule) BaseParserTest(org.graylog.plugins.pipelineprocessor.BaseParserTest) Test(org.junit.Test)

Aggregations

BaseParserTest (org.graylog.plugins.pipelineprocessor.BaseParserTest)2 Rule (org.graylog.plugins.pipelineprocessor.ast.Rule)2 AndExpression (org.graylog.plugins.pipelineprocessor.ast.expressions.AndExpression)2 LogicalExpression (org.graylog.plugins.pipelineprocessor.ast.expressions.LogicalExpression)2 Test (org.junit.Test)2