use of org.apache.jena.sparql.expr.E_Multiply in project jena by apache.
the class TestUserDefinedFunctionFactory method test_user_defined_function_factory_add_03.
@Test
public void test_user_defined_function_factory_add_03() throws ParseException {
Expr e = new E_Multiply(new ExprVar("x"), new ExprVar("x"));
//Instead of registering the pre-built expression register using a string for the expression
UserDefinedFunctionFactory.getFactory().add("http://example/square", "?x * ?x", new ArrayList<>(e.getVarsMentioned()));
Assert.assertTrue(UserDefinedFunctionFactory.getFactory().isRegistered("http://example/square"));
Assert.assertEquals(e, UserDefinedFunctionFactory.getFactory().get("http://example/square").getBaseExpr());
}
use of org.apache.jena.sparql.expr.E_Multiply in project jena by apache.
the class TestUserDefinedFunctionFactory method test_user_defined_function_factory_add_02.
@Test
public void test_user_defined_function_factory_add_02() {
Expr e1 = new E_Multiply(new ExprVar("x"), new ExprVar("x"));
Expr e2 = new E_Multiply(new ExprVar("y"), new ExprVar("y"));
UserDefinedFunctionFactory.getFactory().add("http://example/square", e1, new ArrayList<>(e1.getVarsMentioned()));
Assert.assertTrue(UserDefinedFunctionFactory.getFactory().isRegistered("http://example/square"));
Assert.assertEquals(e1, UserDefinedFunctionFactory.getFactory().get("http://example/square").getBaseExpr());
UserDefinedFunctionFactory.getFactory().add("http://example/square", e2, new ArrayList<>(e2.getVarsMentioned()));
Assert.assertTrue(UserDefinedFunctionFactory.getFactory().isRegistered("http://example/square"));
Assert.assertEquals(e2, UserDefinedFunctionFactory.getFactory().get("http://example/square").getBaseExpr());
}
use of org.apache.jena.sparql.expr.E_Multiply in project jena by apache.
the class TestUserDefinedFunctionFactory method test_user_defined_function_factory_add_01.
@Test
public void test_user_defined_function_factory_add_01() {
Expr e = new E_Multiply(new ExprVar("x"), new ExprVar("x"));
UserDefinedFunctionFactory.getFactory().add("http://example/square", e, new ArrayList<>(e.getVarsMentioned()));
Assert.assertTrue(UserDefinedFunctionFactory.getFactory().isRegistered("http://example/square"));
Assert.assertEquals(e, UserDefinedFunctionFactory.getFactory().get("http://example/square").getBaseExpr());
}
use of org.apache.jena.sparql.expr.E_Multiply in project jena by apache.
the class TestUserFunctionsInSparql method setup.
@BeforeClass
public static void setup() {
UserDefinedFunctionFactory.getFactory().clear();
//Define a square function
Expr square = new E_Multiply(new ExprVar("x"), new ExprVar("x"));
UserDefinedFunctionFactory.getFactory().add("http://example/square", square, new ArrayList<>(square.getVarsMentioned()));
}
Aggregations