use of org.openrdf.query.parser.sparql.SPARQLParser in project incubator-rya by apache.
the class QueryVariableNormalizerTest method testNeq2.
/**
* @throws Exception
* Tests QueryVariableNormalizerContext to see if it recognizes
* that no substitution exists for the variables of q8 given
* that it has more variables than q1
*/
@Test
public void testNeq2() throws Exception {
SPARQLParser parser1 = new SPARQLParser();
SPARQLParser parser2 = new SPARQLParser();
ParsedQuery pq1 = parser1.parseQuery(q1, null);
ParsedQuery pq2 = parser2.parseQuery(q8, null);
List<TupleExpr> normalize = QueryVariableNormalizer.getNormalizedIndex(pq1.getTupleExpr(), pq2.getTupleExpr());
Assert.assertTrue(normalize.size() == 0);
}
use of org.openrdf.query.parser.sparql.SPARQLParser in project incubator-rya by apache.
the class QueryVariableNormalizerTest method tesGraphVarInBody.
@Test
public void tesGraphVarInBody() throws Exception {
SPARQLParser parser1 = new SPARQLParser();
SPARQLParser parser2 = new SPARQLParser();
ParsedQuery pq1 = parser1.parseQuery(q19, null);
ParsedQuery pq2 = parser2.parseQuery(q25, null);
List<TupleExpr> normalize = QueryVariableNormalizer.getNormalizedIndex(pq1.getTupleExpr(), pq2.getTupleExpr());
Assert.assertTrue(normalize.size() == 1);
}
use of org.openrdf.query.parser.sparql.SPARQLParser in project incubator-rya by apache.
the class QueryVariableNormalizerTest method testOrderEq.
/**
* @throws Exception
* Tests QueryVariable normalizer on queries q9 and q18, where
* q18 is obtained from q9 by reordering lines.
*/
@Test
public void testOrderEq() throws Exception {
SPARQLParser parser1 = new SPARQLParser();
SPARQLParser parser2 = new SPARQLParser();
ParsedQuery pq1 = parser1.parseQuery(q9, null);
ParsedQuery pq2 = parser2.parseQuery(q18, null);
List<TupleExpr> normalize = QueryVariableNormalizer.getNormalizedIndex(pq1.getTupleExpr(), pq2.getTupleExpr());
Assert.assertTrue(normalize.size() == 24);
for (TupleExpr s : normalize) {
Assert.assertTrue(isTupleSubset(s, pq1.getTupleExpr()) && isTupleSubset(pq1.getTupleExpr(), s));
}
}
use of org.openrdf.query.parser.sparql.SPARQLParser in project incubator-rya by apache.
the class QueryVariableNormalizerTest method testVarGraph.
@Test
public void testVarGraph() throws Exception {
SPARQLParser parser1 = new SPARQLParser();
SPARQLParser parser2 = new SPARQLParser();
ParsedQuery pq1 = parser1.parseQuery(q19, null);
ParsedQuery pq2 = parser2.parseQuery(q22, null);
List<TupleExpr> normalize = QueryVariableNormalizer.getNormalizedIndex(pq1.getTupleExpr(), pq2.getTupleExpr());
Assert.assertTrue(normalize.size() == 1);
for (TupleExpr s : normalize) {
Assert.assertTrue(tupleEquals(s, pq1.getTupleExpr()));
}
}
use of org.openrdf.query.parser.sparql.SPARQLParser in project incubator-rya by apache.
the class VarConstQueryVariableNormalizerTest method queryConstantNodeOneMatch.
@Test
public void queryConstantNodeOneMatch() throws Exception {
SPARQLParser p = new SPARQLParser();
ParsedQuery pq1 = p.parseQuery(query1, null);
ParsedQuery pq2 = p.parseQuery(index1, null);
List<TupleExpr> normalize = QueryVariableNormalizer.getNormalizedIndex(pq1.getTupleExpr(), pq2.getTupleExpr());
Assert.assertEquals(1, normalize.size());
for (TupleExpr te : normalize) {
Assert.assertTrue(isTupleSubset(pq1.getTupleExpr(), te));
}
}
Aggregations