Search in sources :

Example 6 with ParsedQuery

use of org.eclipse.rdf4j.query.parser.ParsedQuery in project rdf4j by eclipse.

the class SPARQLParserTest method testSES1922PathSequenceWithValueConstant.

@Test
public void testSES1922PathSequenceWithValueConstant() throws Exception {
    StringBuilder qb = new StringBuilder();
    qb.append("ASK {?A (<foo:bar>)/<foo:foo> <foo:objValue>} ");
    ParsedQuery q = parser.parseQuery(qb.toString(), null);
    TupleExpr te = q.getTupleExpr();
    assertNotNull(te);
    assertTrue(te instanceof Slice);
    Slice s = (Slice) te;
    assertTrue(s.getArg() instanceof Join);
    Join j = (Join) s.getArg();
    assertTrue(j.getLeftArg() instanceof StatementPattern);
    assertTrue(j.getRightArg() instanceof StatementPattern);
    StatementPattern leftArg = (StatementPattern) j.getLeftArg();
    StatementPattern rightArg = (StatementPattern) j.getRightArg();
    assertTrue(leftArg.getObjectVar().equals(rightArg.getSubjectVar()));
    assertEquals(leftArg.getObjectVar().getName(), rightArg.getSubjectVar().getName());
}
Also used : StatementPattern(org.eclipse.rdf4j.query.algebra.StatementPattern) ParsedQuery(org.eclipse.rdf4j.query.parser.ParsedQuery) Slice(org.eclipse.rdf4j.query.algebra.Slice) Join(org.eclipse.rdf4j.query.algebra.Join) TupleExpr(org.eclipse.rdf4j.query.algebra.TupleExpr) Test(org.junit.Test)

Example 7 with ParsedQuery

use of org.eclipse.rdf4j.query.parser.ParsedQuery in project rdf4j by eclipse.

the class SPARQLParserTest method testSES1927UnequalLiteralValueConstants1.

@Test
public void testSES1927UnequalLiteralValueConstants1() throws Exception {
    StringBuilder qb = new StringBuilder();
    qb.append("ASK {?a <foo:bar> \"test\". ?a <foo:foo> \"test\"@en .} ");
    ParsedQuery q = parser.parseQuery(qb.toString(), null);
    TupleExpr te = q.getTupleExpr();
    assertNotNull(te);
    assertTrue(te instanceof Slice);
    Slice s = (Slice) te;
    assertTrue(s.getArg() instanceof Join);
    Join j = (Join) s.getArg();
    assertTrue(j.getLeftArg() instanceof StatementPattern);
    assertTrue(j.getRightArg() instanceof StatementPattern);
    StatementPattern leftArg = (StatementPattern) j.getLeftArg();
    StatementPattern rightArg = (StatementPattern) j.getRightArg();
    assertFalse(leftArg.getObjectVar().equals(rightArg.getObjectVar()));
    assertNotEquals(leftArg.getObjectVar().getName(), rightArg.getObjectVar().getName());
}
Also used : StatementPattern(org.eclipse.rdf4j.query.algebra.StatementPattern) ParsedQuery(org.eclipse.rdf4j.query.parser.ParsedQuery) Slice(org.eclipse.rdf4j.query.algebra.Slice) Join(org.eclipse.rdf4j.query.algebra.Join) TupleExpr(org.eclipse.rdf4j.query.algebra.TupleExpr) Test(org.junit.Test)

Aggregations

ParsedQuery (org.eclipse.rdf4j.query.parser.ParsedQuery)7 TupleExpr (org.eclipse.rdf4j.query.algebra.TupleExpr)6 Test (org.junit.Test)5 Join (org.eclipse.rdf4j.query.algebra.Join)3 Slice (org.eclipse.rdf4j.query.algebra.Slice)3 StatementPattern (org.eclipse.rdf4j.query.algebra.StatementPattern)3 MalformedQueryException (org.eclipse.rdf4j.query.MalformedQueryException)2 ParsedGraphQuery (org.eclipse.rdf4j.query.parser.ParsedGraphQuery)2 ParsedTupleQuery (org.eclipse.rdf4j.query.parser.ParsedTupleQuery)2 Dataset (org.eclipse.rdf4j.query.Dataset)1 IncompatibleOperationException (org.eclipse.rdf4j.query.IncompatibleOperationException)1 Extension (org.eclipse.rdf4j.query.algebra.Extension)1 Order (org.eclipse.rdf4j.query.algebra.Order)1 Projection (org.eclipse.rdf4j.query.algebra.Projection)1 ParsedBooleanQuery (org.eclipse.rdf4j.query.parser.ParsedBooleanQuery)1 ParsedDescribeQuery (org.eclipse.rdf4j.query.parser.ParsedDescribeQuery)1 ASTGraphQuery (org.eclipse.rdf4j.query.parser.serql.ast.ASTGraphQuery)1 ASTQuery (org.eclipse.rdf4j.query.parser.serql.ast.ASTQuery)1 ASTQueryContainer (org.eclipse.rdf4j.query.parser.serql.ast.ASTQueryContainer)1 ASTTupleQuery (org.eclipse.rdf4j.query.parser.serql.ast.ASTTupleQuery)1