use of fr.lirmm.graphik.graal.api.core.ConjunctiveQuery in project graal by graphik-team.
the class DlgpParserTest method parseQueryWithIntegerLiteralInAns.
@Test
public void parseQueryWithIntegerLiteralInAns() throws ParseException {
ConjunctiveQuery q = DlgpParser.parseQuery("?(1,X) :- p(a,X).");
List<Term> ans = q.getAnswerVariables();
Assert.assertEquals(L1, ans.get(0));
Assert.assertEquals(X, ans.get(1));
Atom a = q.getAtomSet().iterator().next();
Assert.assertEquals(A, a.getTerm(0));
Assert.assertEquals(X, a.getTerm(1));
}
use of fr.lirmm.graphik.graal.api.core.ConjunctiveQuery in project graal by graphik-team.
the class DlgpParserTest method parseQueryWithConstantInAns.
@Test
public void parseQueryWithConstantInAns() throws ParseException {
ConjunctiveQuery q = DlgpParser.parseQuery("?(b,X) :- p(a,X).");
List<Term> ans = q.getAnswerVariables();
Assert.assertEquals(B, ans.get(0));
Assert.assertEquals(X, ans.get(1));
Atom a = q.getAtomSet().iterator().next();
Assert.assertEquals(A, a.getTerm(0));
Assert.assertEquals(X, a.getTerm(1));
}
use of fr.lirmm.graphik.graal.api.core.ConjunctiveQuery in project graal by graphik-team.
the class DlgpParserTest method parseQueryWithBooleanLiteralInAns.
@Test
public void parseQueryWithBooleanLiteralInAns() throws ParseException {
ConjunctiveQuery q = DlgpParser.parseQuery("?(true,X) :- p(a,X).");
List<Term> ans = q.getAnswerVariables();
Assert.assertEquals(LTRUE, ans.get(0));
Assert.assertEquals(X, ans.get(1));
Atom a = q.getAtomSet().iterator().next();
Assert.assertEquals(A, a.getTerm(0));
Assert.assertEquals(X, a.getTerm(1));
}
use of fr.lirmm.graphik.graal.api.core.ConjunctiveQuery in project graal by graphik-team.
the class EqualityUtilsTest method testBottomQuery2.
@Test
public void testBottomQuery2() throws ParseException {
ConjunctiveQuery q = DlgpParser.parseQuery("?(X,Y) :- p(X,Y), X=a, X=Y, Y=b.");
Pair<ConjunctiveQuery, Substitution> pair = EqualityUtils.processEquality(q);
q = pair.getLeft();
Substitution s = pair.getRight();
// check substitution minimality
Assert.assertTrue(s.getTerms().isEmpty());
// check query ans part
Assert.assertEquals(0, q.getAnswerVariables().size());
// check query atomset
Assert.assertEquals(1, Iterators.count(q.getAtomSet().iterator()));
Atom atom = q.getAtomSet().iterator().next();
Assert.assertEquals(Predicate.BOTTOM, atom.getPredicate());
}
use of fr.lirmm.graphik.graal.api.core.ConjunctiveQuery in project graal by graphik-team.
the class EqualityUtilsTest method test1.
@Test
public void test1() throws ParseException {
ConjunctiveQuery q = DlgpParser.parseQuery("?(X,Y) :- b(X), Y=a.");
Pair<ConjunctiveQuery, Substitution> pair = EqualityUtils.processEquality(q);
q = pair.getLeft();
Substitution s = pair.getRight();
// check substitution
Assert.assertEquals(1, s.getTerms().size());
Assert.assertEquals(a, s.createImageOf(y));
// check query
Assert.assertEquals(DlgpParser.parseQuery("?(X) :- b(X)."), q);
}
Aggregations