use of org.openrdf.query.parser.sparql.SPARQLParser in project incubator-rya by apache.
the class QueryVariableNormalizerTest method testEqNEQ.
/**
* @throws Exception
* Tests QueryVariableNormalizerContext to see if it recognizes
* that no substitution exists for two moderate, similar queries
* q5 and q1 that are structurally different
*/
@Test
public void testEqNEQ() throws Exception {
SPARQLParser parser1 = new SPARQLParser();
SPARQLParser parser2 = new SPARQLParser();
ParsedQuery pq1 = parser1.parseQuery(q1, null);
ParsedQuery pq2 = parser2.parseQuery(q5, null);
List<TupleExpr> normalize = QueryVariableNormalizer.getNormalizedIndex(pq1.getTupleExpr(), pq2.getTupleExpr());
Assert.assertTrue(normalize.size() == 0);
pq1 = parser1.parseQuery(q5, null);
pq2 = parser2.parseQuery(q1, null);
List<TupleExpr> normalize2 = QueryVariableNormalizer.getNormalizedIndex(pq1.getTupleExpr(), pq2.getTupleExpr());
Assert.assertEquals(1, normalize2.size());
for (TupleExpr s : normalize2) {
List<TupleExpr> testList = QueryVariableNormalizer.getNormalizedIndex(pq2.getTupleExpr(), s);
Assert.assertEquals(1, testList.size());
for (TupleExpr t : testList) {
Assert.assertTrue(t.equals(pq2.getTupleExpr()));
}
}
}
use of org.openrdf.query.parser.sparql.SPARQLParser in project incubator-rya by apache.
the class QueryVariableNormalizerTest method testFilters1.
@Test
public void testFilters1() throws Exception {
SPARQLParser parser1 = new SPARQLParser();
SPARQLParser parser2 = new SPARQLParser();
ParsedQuery pq1 = parser1.parseQuery(q30, null);
ParsedQuery pq2 = parser2.parseQuery(q31, null);
List<TupleExpr> normalize = QueryVariableNormalizer.getNormalizedIndex(pq1.getTupleExpr(), pq2.getTupleExpr());
Assert.assertTrue(normalize.size() == 1);
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 testMedVarGraph.
@Test
public void testMedVarGraph() throws Exception {
SPARQLParser parser1 = new SPARQLParser();
SPARQLParser parser2 = new SPARQLParser();
ParsedQuery pq1 = parser1.parseQuery(q24, null);
ParsedQuery pq2 = parser2.parseQuery(q25, null);
List<TupleExpr> normalize = QueryVariableNormalizer.getNormalizedIndex(pq1.getTupleExpr(), pq2.getTupleExpr());
Assert.assertTrue(normalize.size() == 2);
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 testFilters3.
@Test
public void testFilters3() throws Exception {
SPARQLParser parser1 = new SPARQLParser();
SPARQLParser parser2 = new SPARQLParser();
ParsedQuery pq1 = parser1.parseQuery(q33, null);
ParsedQuery pq2 = parser2.parseQuery(q35, null);
List<TupleExpr> normalize = QueryVariableNormalizer.getNormalizedIndex(pq1.getTupleExpr(), pq2.getTupleExpr());
Assert.assertTrue(normalize.size() == 1);
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 testNeq.
/**
* @throws Exception
* Tests QueryVariableNormalizerContext to see if it recognizes
* that no substitution exists for the large queries q8 and q9
* which contain the same number of variables and are similar.
*/
@Test
public void testNeq() throws Exception {
SPARQLParser parser1 = new SPARQLParser();
SPARQLParser parser2 = new SPARQLParser();
ParsedQuery pq1 = parser1.parseQuery(q9, null);
ParsedQuery pq2 = parser2.parseQuery(q8, null);
List<TupleExpr> normalize = QueryVariableNormalizer.getNormalizedIndex(pq1.getTupleExpr(), pq2.getTupleExpr());
Assert.assertTrue(normalize.size() == 0);
}
Aggregations