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)));
}
Aggregations