Search in sources :

Example 1 with EqualityExpression

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

the class PrecedenceTest method comparisonVsEqual.

@Test
public void comparisonVsEqual() {
    final Rule rule = parseRule("rule \"test\" when 1 > 2 == false then end");
    final LogicalExpression when = rule.when();
    assertThat(when).isInstanceOf(EqualityExpression.class);
    EqualityExpression topEqual = (EqualityExpression) when;
    assertThat(topEqual.left()).isInstanceOf(ComparisonExpression.class);
    assertThat(topEqual.right()).isInstanceOf(BooleanExpression.class);
}
Also used : LogicalExpression(org.graylog.plugins.pipelineprocessor.ast.expressions.LogicalExpression) Rule(org.graylog.plugins.pipelineprocessor.ast.Rule) EqualityExpression(org.graylog.plugins.pipelineprocessor.ast.expressions.EqualityExpression) BaseParserTest(org.graylog.plugins.pipelineprocessor.BaseParserTest) Test(org.junit.Test)

Example 2 with EqualityExpression

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

the class PrecedenceTest method parenGroup.

@Test
public void parenGroup() {
    final Rule rule = parseRule("rule \"test\" when true == (false == false) then end");
    final LogicalExpression when = rule.when();
    assertThat(when).isInstanceOf(EqualityExpression.class);
    EqualityExpression topEqual = (EqualityExpression) when;
    assertThat(topEqual.left()).isInstanceOf(BooleanExpression.class);
    assertThat(topEqual.right()).isInstanceOf(EqualityExpression.class);
    final BooleanExpression trueExpr = (BooleanExpression) topEqual.left();
    assertThat(trueExpr.evaluateBool(null)).isTrue();
    final EqualityExpression falseFalse = (EqualityExpression) topEqual.right();
    assertThat(falseFalse.evaluateBool(null)).isTrue();
}
Also used : LogicalExpression(org.graylog.plugins.pipelineprocessor.ast.expressions.LogicalExpression) BooleanExpression(org.graylog.plugins.pipelineprocessor.ast.expressions.BooleanExpression) Rule(org.graylog.plugins.pipelineprocessor.ast.Rule) EqualityExpression(org.graylog.plugins.pipelineprocessor.ast.expressions.EqualityExpression) 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 EqualityExpression (org.graylog.plugins.pipelineprocessor.ast.expressions.EqualityExpression)2 LogicalExpression (org.graylog.plugins.pipelineprocessor.ast.expressions.LogicalExpression)2 Test (org.junit.Test)2 BooleanExpression (org.graylog.plugins.pipelineprocessor.ast.expressions.BooleanExpression)1