use of com.yahoo.vespa.indexinglanguage.expressions.AttributeExpression in project vespa by vespa-engine.
the class ExpressionConverterTestCase method requireThatConversionExceptionCanBeThrown.
@Test
public void requireThatConversionExceptionCanBeThrown() {
final RuntimeException expectedCause = new RuntimeException();
try {
new ExpressionConverter() {
@Override
protected boolean shouldConvert(Expression exp) {
return exp instanceof AttributeExpression;
}
@Override
protected Expression doConvert(Expression exp) {
throw expectedCause;
}
}.convert(new StatementExpression(new AttributeExpression("foo")));
fail();
} catch (RuntimeException e) {
assertSame(expectedCause, e);
}
}
use of com.yahoo.vespa.indexinglanguage.expressions.AttributeExpression in project vespa by vespa-engine.
the class ExpressionConverterTestCase method requireThatCatConversionIgnoresNull.
@Test
public void requireThatCatConversionIgnoresNull() {
Expression exp = new ExpressionConverter() {
@Override
protected boolean shouldConvert(Expression exp) {
return exp instanceof AttributeExpression;
}
@Override
protected Expression doConvert(Expression exp) {
return null;
}
}.convert(new CatExpression(new AttributeExpression("foo"), new IndexExpression("bar")));
assertEquals(new CatExpression(new IndexExpression("bar")), exp);
}
use of com.yahoo.vespa.indexinglanguage.expressions.AttributeExpression in project vespa by vespa-engine.
the class ExpressionSearcherTestCase method requireThatExpressionsCanBeFound.
@Test
public void requireThatExpressionsCanBeFound() {
IndexExpression exp = new IndexExpression("foo");
assertFound(exp, new ArithmeticExpression(exp, ArithmeticExpression.Operator.ADD, new AttributeExpression("foo")));
assertFound(exp, new ArithmeticExpression(new AttributeExpression("foo"), ArithmeticExpression.Operator.ADD, exp));
assertFound(exp, new CatExpression(exp));
assertFound(exp, new CatExpression(new AttributeExpression("foo"), exp));
assertFound(exp, new ForEachExpression(exp));
assertFound(exp, new GuardExpression(exp));
assertFound(exp, new IfThenExpression(exp, IfThenExpression.Comparator.EQ, new AttributeExpression("foo"), new AttributeExpression("bar"), new AttributeExpression("baz")));
assertFound(exp, new IfThenExpression(new AttributeExpression("foo"), IfThenExpression.Comparator.EQ, exp, new AttributeExpression("bar"), new AttributeExpression("baz")));
assertFound(exp, new IfThenExpression(new AttributeExpression("foo"), IfThenExpression.Comparator.EQ, new AttributeExpression("bar"), exp, new AttributeExpression("baz")));
assertFound(exp, new IfThenExpression(new AttributeExpression("foo"), IfThenExpression.Comparator.EQ, new AttributeExpression("bar"), new AttributeExpression("baz"), exp));
assertFound(exp, new ParenthesisExpression(exp));
assertFound(exp, new ScriptExpression(new StatementExpression(exp)));
assertFound(exp, new ScriptExpression(new StatementExpression(new AttributeExpression("foo")), new StatementExpression(exp)));
assertFound(exp, new SelectInputExpression(Arrays.asList(new Pair<String, Expression>("foo", exp), new Pair<String, Expression>("bar", new AttributeExpression("bar")))));
assertFound(exp, new SelectInputExpression(Arrays.asList(new Pair<String, Expression>("foo", new AttributeExpression("bar")), new Pair<String, Expression>("bar", exp))));
assertFound(exp, new StatementExpression(exp));
assertFound(exp, new StatementExpression(new AttributeExpression("foo"), exp));
assertFound(exp, new SwitchExpression(Collections.singletonMap("foo", exp), new AttributeExpression("bar")));
assertFound(exp, new SwitchExpression(Collections.singletonMap("foo", new AttributeExpression("bar")), exp));
}
Aggregations