use of com.hortonworks.streamline.streams.layout.component.rule.expression.BinaryExpression in project streamline by hortonworks.
the class GroovyExpressionTest method testMap.
@Test
public void testMap() throws Exception {
Condition condition = new Condition();
condition.setExpression(new BinaryExpression(Operator.LESS_THAN, new MapFieldExpression(getVariable("map"), "foo"), getVariable("b")));
GroovyExpression expr = new GroovyExpression(condition);
Assert.assertEquals("map['foo'] < b", expr.asString());
}
use of com.hortonworks.streamline.streams.layout.component.rule.expression.BinaryExpression in project streamline by hortonworks.
the class GroovyExpressionTest method testNested.
@Test
public void testNested() throws Exception {
Condition condition = new Condition();
condition.setExpression(new BinaryExpression(Operator.LESS_THAN, new ArrayFieldExpression(new MapFieldExpression(getVariable("map"), "foo"), 100), getVariable("b")));
GroovyExpression expr = new GroovyExpression(condition);
Assert.assertEquals("map['foo'][100] < b", expr.asString());
}
use of com.hortonworks.streamline.streams.layout.component.rule.expression.BinaryExpression in project streamline by hortonworks.
the class GroovyExpressionTest method testArray.
@Test
public void testArray() throws Exception {
Condition condition = new Condition();
condition.setExpression(new BinaryExpression(Operator.LESS_THAN, new ArrayFieldExpression(getVariable("arr"), 100), getVariable("b")));
GroovyExpression expr = new GroovyExpression(condition);
Assert.assertEquals("arr[100] < b", expr.asString());
}
use of com.hortonworks.streamline.streams.layout.component.rule.expression.BinaryExpression in project streamline by hortonworks.
the class GroovyExpressionTest method testOrString.
@Test
public void testOrString() throws Exception {
Condition condition = new Condition();
Expression left = new BinaryExpression(Operator.LESS_THAN, getVariable("a"), getVariable("b"));
Expression right = new BinaryExpression(Operator.GREATER_THAN, getVariable("c"), getVariable("d"));
condition.setExpression(new BinaryExpression(Operator.OR, left, right));
GroovyExpression expr = new GroovyExpression(condition);
Assert.assertEquals("a < b || c > d", expr.asString());
}
use of com.hortonworks.streamline.streams.layout.component.rule.expression.BinaryExpression in project streamline by hortonworks.
the class GroovyExpressionTest method testAndAsString.
@Test
public void testAndAsString() throws Exception {
Condition condition = new Condition();
Expression left = new BinaryExpression(Operator.OR, getVariable("a"), getVariable("b"));
Expression right = new BinaryExpression(Operator.OR, getVariable("c"), getVariable("d"));
condition.setExpression(new BinaryExpression(Operator.AND, left, right));
GroovyExpression expr = new GroovyExpression(condition);
Assert.assertEquals("(a || b) && (c || d)", expr.asString());
}
Aggregations