use of org.apache.jena.sparql.expr.ExprVar in project jena by apache.
the class ExprFactoryTest method asListTest.
@Test
public void asListTest() {
ExprList lst = factory.asList("?foo", "http://example.com", Converters.quoted("hello"), 1, 5L, 3.14f, 6.28d, Var.alloc("bar"), null, factory.rand());
assertEquals(10, lst.size());
assertEquals(new ExprVar("foo"), lst.get(0));
// assertEquals( new ExprVar( "foo" ), lst.get(0));
assertEquals(new NodeValueString("hello"), lst.get(2));
assertEquals(1, lst.get(3).getConstant().asNode().getLiteralValue());
assertEquals(5, lst.get(4).getConstant().asNode().getLiteralValue());
assertEquals(3.14f, lst.get(5).getConstant().asNode().getLiteralValue());
assertEquals(6.28, lst.get(6).getConstant().asNode().getLiteralValue());
assertEquals(new ExprVar("bar"), lst.get(7));
assertEquals(Expr.NONE, lst.get(8));
assertEquals(new E_Random(), lst.get(9));
}
use of org.apache.jena.sparql.expr.ExprVar in project jena by apache.
the class ExprFactoryTest method asExprTest_var.
@Test
public void asExprTest_var() {
Expr e = factory.asExpr(Var.alloc("hello"));
assertTrue(e instanceof ExprVar);
ExprVar v = (ExprVar) e;
assertEquals("hello", v.asVar().getName());
}
use of org.apache.jena.sparql.expr.ExprVar in project jena by apache.
the class ExprFactoryTest method asExprTest_varString.
@Test
public void asExprTest_varString() {
Expr e = factory.asExpr("?foo");
assertTrue(e instanceof ExprVar);
ExprVar v = (ExprVar) e;
assertEquals("foo", v.asVar().getName());
}
use of org.apache.jena.sparql.expr.ExprVar in project jena by apache.
the class ExprFactoryTest method asVarTest_var.
@Test
public void asVarTest_var() {
Expr e = factory.asVar(Var.alloc("hello"));
assertTrue(e instanceof ExprVar);
ExprVar v = (ExprVar) e;
assertEquals("hello", v.asVar().getName());
}
use of org.apache.jena.sparql.expr.ExprVar in project jena by apache.
the class ConvertersTest method makeVarTest.
@Test
public void makeVarTest() {
Var v = Converters.makeVar(null);
assertEquals(Var.ANON, v);
v = Converters.makeVar("a");
assertEquals(Var.alloc("a"), v);
v = Converters.makeVar("?a");
assertEquals(Var.alloc("a"), v);
Node n = NodeFactory.createVariable("foo");
v = Converters.makeVar(n);
assertEquals(Var.alloc("foo"), v);
NodeFront nf = new NodeFront(n);
v = Converters.makeVar(nf);
assertEquals(Var.alloc("foo"), v);
v = Converters.makeVar(Node_RuleVariable.WILD);
assertNull(v);
ExprVar ev = new ExprVar("bar");
v = Converters.makeVar(ev);
assertEquals(Var.alloc("bar"), v);
ev = new ExprVar(n);
v = Converters.makeVar(ev);
assertEquals(Var.alloc("foo"), v);
ev = new ExprVar(Var.ANON);
v = Converters.makeVar(ev);
assertEquals(Var.ANON, v);
}
Aggregations