Search in sources :

Example 1 with NAryExpression

use of com.yahoo.bullet.query.expressions.NAryExpression in project bullet-core by yahoo.

the class NAryEvaluatorTest method testConstructor.

@Test
public void testConstructor() {
    NAryExpression expression = new NAryExpression(Arrays.asList(new ValueExpression(false), new ValueExpression(1), new ValueExpression(2)), Operation.IF);
    expression.setType(Type.INTEGER);
    NAryEvaluator evaluator = new NAryEvaluator(expression);
    Assert.assertTrue(evaluator.operands.get(0) instanceof ValueEvaluator);
    Assert.assertTrue(evaluator.operands.get(1) instanceof ValueEvaluator);
    Assert.assertTrue(evaluator.operands.get(2) instanceof ValueEvaluator);
    Assert.assertEquals(evaluator.op, N_ARY_OPERATORS.get(Operation.IF));
    Assert.assertEquals(evaluator.evaluate(RecordBox.get().getRecord()), new TypedObject(Type.INTEGER, 2));
}
Also used : TypedObject(com.yahoo.bullet.typesystem.TypedObject) ValueExpression(com.yahoo.bullet.query.expressions.ValueExpression) NAryExpression(com.yahoo.bullet.query.expressions.NAryExpression) Test(org.testng.annotations.Test)

Aggregations

NAryExpression (com.yahoo.bullet.query.expressions.NAryExpression)1 ValueExpression (com.yahoo.bullet.query.expressions.ValueExpression)1 TypedObject (com.yahoo.bullet.typesystem.TypedObject)1 Test (org.testng.annotations.Test)1