use of org.openrdf.query.parser.sparql.SPARQLParser in project incubator-rya by apache.
the class QueryVariableNormalizerTest method testSimpleVarGraph.
@Test
public void testSimpleVarGraph() throws Exception {
SPARQLParser parser1 = new SPARQLParser();
SPARQLParser parser2 = new SPARQLParser();
ParsedQuery pq1 = parser1.parseQuery(q22, null);
ParsedQuery pq2 = parser2.parseQuery(q23, 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 QueryVariableNormalizerTest method tesVarConstantGraph.
@Test
public void tesVarConstantGraph() throws Exception {
SPARQLParser parser1 = new SPARQLParser();
SPARQLParser parser2 = new SPARQLParser();
ParsedQuery pq1 = parser1.parseQuery(q19, null);
ParsedQuery pq2 = parser2.parseQuery(q20, 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 testConstantGraph.
@Test
public void testConstantGraph() throws Exception {
SPARQLParser parser1 = new SPARQLParser();
SPARQLParser parser2 = new SPARQLParser();
ParsedQuery pq1 = parser1.parseQuery(q20, null);
ParsedQuery pq2 = parser2.parseQuery(q21, 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 QueryVariableNormalizerTest method testLargeNeq.
/**
* @throws Exception
* Tests QueryVariableNormalizerContext on the large query q11
* and q6, which have many similar nodes, to see if the correct
* number of outputs are produced.
*/
@Test
public void testLargeNeq() throws Exception {
SPARQLParser parser1 = new SPARQLParser();
SPARQLParser parser2 = new SPARQLParser();
ParsedQuery pq1 = parser1.parseQuery(q11, null);
ParsedQuery pq2 = parser2.parseQuery(q6, null);
List<TupleExpr> normalize = QueryVariableNormalizer.getNormalizedIndex(pq1.getTupleExpr(), pq2.getTupleExpr());
Assert.assertTrue(normalize.size() == 33);
for (TupleExpr s : normalize) {
Assert.assertTrue(isTupleSubset(pq1.getTupleExpr(), s));
}
}
use of org.openrdf.query.parser.sparql.SPARQLParser in project incubator-rya by apache.
the class QueryVariableNormalizerTest method testEqThreeDiffVars.
/**
* @throws Exception
* Tests QueryVariableNormalizerContext on the queries q1,q2
* which are the same up to a relabeling of variables.
*/
@Test
public void testEqThreeDiffVars() throws Exception {
SPARQLParser parser1 = new SPARQLParser();
SPARQLParser parser2 = new SPARQLParser();
ParsedQuery pq1 = parser1.parseQuery(q1, null);
ParsedQuery pq2 = parser2.parseQuery(q2, null);
List<TupleExpr> normalize = QueryVariableNormalizer.getNormalizedIndex(pq1.getTupleExpr(), pq2.getTupleExpr());
Assert.assertEquals(1, normalize.size());
for (TupleExpr s : normalize) {
Assert.assertTrue(tupleEquals(s, pq1.getTupleExpr()));
}
}
Aggregations