UserDefinedFunctionFactory.getFactory().setPreserveDependencies(false);
}
@Test
public void test_function_non_expansion_01() {
Expr square = new E_Multiply(new ExprVar("x"), new ExprVar("x"));
UserDefinedFunctionFactory.getFactory().add("http://example/square", square, new ArrayList<Var>(square.getVarsMentioned()));
//Test that with preserveDependencies set to true that the definition of cube is not expanded
Expr cube = new E_Multiply(new E_Function("http://example/square", new ExprList(new ExprVar("x"))), new ExprVar("x"));
UserDefinedFunctionFactory.getFactory().add("http://example/cube", cube, new ArrayList<Var>(cube.getVarsMentioned()));
UserDefinedFunctionDefinition def = UserDefinedFunctionFactory.getFactory().get("http://example/cube");
Expr base = def.getBaseExpr();
Assert.assertTrue(base instanceof E_Multiply);
E_Multiply multiply = (E_Multiply)base;
Assert.assertTrue(multiply.getArg1() instanceof E_Function);
Assert.assertTrue(multiply.getArg2() instanceof ExprVar);
E_Function lhs = (E_Function)multiply.getArg1();
Assert.assertEquals("http://example/square", lhs.getFunctionIRI());
Assert.assertEquals(1, base.getVarsMentioned().size());
}