Search in sources :

Example 6 with ASTQueryContainer

use of org.eclipse.rdf4j.query.parser.sparql.ast.ASTQueryContainer in project rdf4j by eclipse.

the class TupleExprBuilderTest method testServiceGraphPatternStringDetection4.

@Test
public void testServiceGraphPatternStringDetection4() throws TokenMgrError, ParseException, VisitorException {
    String servicePattern1 = "SERVICE <http://localhost:18080/openrdf/repositories/endpoint1> {  ?s ?p ?o1 . " + "OPTIONAL {	SERVICE SILENT <http://invalid.endpoint.org/sparql> { ?s ?p2 ?o2 } } }";
    String servicePattern2 = "SERVICE SILENT <http://invalid.endpoint.org/sparql> { ?s ?p2 ?o2 }";
    StringBuilder qb = new StringBuilder();
    qb.append("SELECT * \n");
    qb.append("WHERE { \n");
    qb.append(servicePattern1);
    qb.append(" } ");
    ASTQueryContainer qc = SyntaxTreeBuilder.parseQuery(qb.toString());
    ServiceNodeFinder f = new ServiceNodeFinder();
    f.visit(qc, null);
    assertTrue(f.getGraphPatterns().size() == 2);
    assertTrue(servicePattern1.equals(f.getGraphPatterns().get(0)));
    assertTrue(servicePattern2.equals(f.getGraphPatterns().get(1)));
}
Also used : ASTQueryContainer(org.eclipse.rdf4j.query.parser.sparql.ast.ASTQueryContainer) Test(org.junit.Test)

Aggregations

ASTQueryContainer (org.eclipse.rdf4j.query.parser.sparql.ast.ASTQueryContainer)6 Test (org.junit.Test)5 TupleExpr (org.eclipse.rdf4j.query.algebra.TupleExpr)2 ParseException (org.eclipse.rdf4j.query.parser.sparql.ast.ParseException)2 Dataset (org.eclipse.rdf4j.query.Dataset)1 IncompatibleOperationException (org.eclipse.rdf4j.query.IncompatibleOperationException)1 MalformedQueryException (org.eclipse.rdf4j.query.MalformedQueryException)1 Order (org.eclipse.rdf4j.query.algebra.Order)1 ParsedBooleanQuery (org.eclipse.rdf4j.query.parser.ParsedBooleanQuery)1 ParsedDescribeQuery (org.eclipse.rdf4j.query.parser.ParsedDescribeQuery)1 ParsedGraphQuery (org.eclipse.rdf4j.query.parser.ParsedGraphQuery)1 ParsedQuery (org.eclipse.rdf4j.query.parser.ParsedQuery)1 ParsedTupleQuery (org.eclipse.rdf4j.query.parser.ParsedTupleQuery)1 ASTAskQuery (org.eclipse.rdf4j.query.parser.sparql.ast.ASTAskQuery)1 ASTConstructQuery (org.eclipse.rdf4j.query.parser.sparql.ast.ASTConstructQuery)1 ASTDescribeQuery (org.eclipse.rdf4j.query.parser.sparql.ast.ASTDescribeQuery)1 ASTQuery (org.eclipse.rdf4j.query.parser.sparql.ast.ASTQuery)1 ASTSelectQuery (org.eclipse.rdf4j.query.parser.sparql.ast.ASTSelectQuery)1 TokenMgrError (org.eclipse.rdf4j.query.parser.sparql.ast.TokenMgrError)1 VisitorException (org.eclipse.rdf4j.query.parser.sparql.ast.VisitorException)1