public void test_service_002() throws Exception {
  final BigdataURI dcCreator=valueFactory.asValue(DC.CREATOR);
  final BigdataURI book1=valueFactory.createURI("http://example.org/book/book1");
  final BigdataURI book2=valueFactory.createURI("http://example.org/book/book2");
  final BigdataURI author1=valueFactory.createURI("http://example.org/author/author1");
  final BigdataURI author2=valueFactory.createURI("http://example.org/author/author2");
  addResolveIVs(dcCreator,book1,book2,author1,author2);
  final BigdataURI serviceURI=valueFactory.createURI("http://www.bigdata.com/myService");
  final GraphPatternGroup<IGroupMemberNode> groupNode=new JoinGroupNode();
{
    groupNode.addChild(new StatementPatternNode(new VarNode("s"),new VarNode("p"),new VarNode("o")));
  }
  final String exprImage="SERVICE <" + serviceURI + "> { ?s ?p ?o }";
  final Map<String,String> prefixDecls=new LinkedHashMap<String,String>(PrefixDeclProcessor.defaultDecls);
{
    prefixDecls.put("foo","http://www.bigdata.com/foo");
  }
  final ServiceNode serviceNode=new ServiceNode(new ConstantNode(makeIV(serviceURI)),groupNode);
{
    final Set<IVariable<?>> projectedVars=new LinkedHashSet<IVariable<?>>();
{
      projectedVars.add(Var.var("s"));
      projectedVars.add(Var.var("p"));
      projectedVars.add(Var.var("o"));
    }
    serviceNode.setExprImage(exprImage);
    serviceNode.setPrefixDecls(prefixDecls);
    serviceNode.setProjectedVars(projectedVars);
  }
  final List<BindingSet> bindingSets=new LinkedList<BindingSet>();
{
    final MapBindingSet bset=new MapBindingSet();
    bset.addBinding("s",book1);
    bset.addBinding("p",DC.CREATOR);
    bset.addBinding("o",author1);
    bindingSets.add(bset);
  }
{
    final MapBindingSet bset=new MapBindingSet();
    bset.addBinding("s",book2);
    bset.addBinding("p",DC.CREATOR);
    bset.addBinding("o",author2);
    bindingSets.add(bset);
  }
  final BindingSet[] a=bindingSets.toArray(new BindingSet[bindingSets.size()]);
  final IRemoteSparqlQueryBuilder fixture=newFixture(serviceNode,a);
  final String queryStr=fixture.getSparqlQuery(a);
  final QueryRoot expected=new QueryRoot(QueryType.SELECT);
{
    expected.setPrefixDecls(prefixDecls);
    final ProjectionNode projection=new ProjectionNode();
    projection.addProjectionVar(new VarNode("s"));
    projection.addProjectionVar(new VarNode("p"));
    projection.addProjectionVar(new VarNode("o"));
    expected.setProjection(projection);
    final JoinGroupNode whereClause=new JoinGroupNode();
    expected.setWhereClause(whereClause);
    final UnionNode union=new UnionNode();
    whereClause.addChild(union);
{
      final JoinGroupNode graphPattern=new JoinGroupNode();
      union.addChild(graphPattern);
      graphPattern.addChild(new FilterNode(FunctionNode.sameTerm(new VarNode("s"),new ConstantNode(book1.getIV()))));
      graphPattern.addChild(new FilterNode(FunctionNode.sameTerm(new VarNode("p"),new ConstantNode(dcCreator.getIV()))));
      graphPattern.addChild(new FilterNode(FunctionNode.sameTerm(new VarNode("o"),new ConstantNode(author1.getIV()))));
      graphPattern.addChild(new StatementPatternNode(new VarNode("s"),new VarNode("p"),new VarNode("o"),null,Scope.DEFAULT_CONTEXTS));
    }
{
      final JoinGroupNode graphPattern=new JoinGroupNode();
      union.addChild(graphPattern);
      graphPattern.addChild(new FilterNode(FunctionNode.sameTerm(new VarNode("s"),new ConstantNode(book2.getIV()))));
      graphPattern.addChild(new FilterNode(FunctionNode.sameTerm(new VarNode("p"),new ConstantNode(dcCreator.getIV()))));
      graphPattern.addChild(new FilterNode(FunctionNode.sameTerm(new VarNode("o"),new ConstantNode(author2.getIV()))));
      graphPattern.addChild(new StatementPatternNode(new VarNode("s"),new VarNode("p"),new VarNode("o"),null,Scope.DEFAULT_CONTEXTS));
    }
  }
  final QueryRoot actual=parse(queryStr,baseURI);
  assertSameAST(queryStr,expected,actual);
}

public void test_service_002 ( ) throws Exception { final BigdataURI dcCreator = valueFactory . asValue ( DC . CREATOR ) ; final BigdataURI book1 = valueFactory . createURI ( "http://example.org/book/book1" ) ; final BigdataURI book2 = valueFactory . createURI ( "http://example.org/book/book2" ) ; final BigdataURI author1 = valueFactory . createURI ( "http://example.org/author/author1" ) ; final BigdataURI author2 = valueFactory . createURI ( "http://example.org/author/author2" ) ; addResolveIVs ( dcCreator , book1 , book2 , author1 , author2 ) ; final BigdataURI serviceURI = valueFactory . createURI ( "http://www.bigdata.com/myService" ) ; final GraphPatternGroup < IGroupMemberNode > groupNode = new JoinGroupNode ( ) ; { groupNode . addChild ( new StatementPatternNode ( new VarNode ( "s" ) , new VarNode ( "p" ) , new VarNode ( "o" ) ) ) ; } final String exprImage = "SERVICE <" + serviceURI + "> { ?s ?p ?o }" ; final Map < String , String > prefixDecls = new LinkedHashMap < String , String > ( PrefixDeclProcessor . defaultDecls ) ; { prefixDecls . put ( "foo" , "http://www.bigdata.com/foo" ) ; } final ServiceNode serviceNode = new ServiceNode ( new ConstantNode ( makeIV ( serviceURI ) ) , groupNode ) ; { final Set < IVariable < ? > > projectedVars = new LinkedHashSet < IVariable < ? > > ( ) ; { projectedVars . add ( Var . var ( "s" ) ) ; projectedVars . add ( Var . var ( "p" ) ) ; projectedVars . add ( Var . var ( "o" ) ) ; } serviceNode . setExprImage ( exprImage ) ; serviceNode . setPrefixDecls ( prefixDecls ) ; serviceNode . setProjectedVars ( projectedVars ) ; } final List < BindingSet > bindingSets = new LinkedList < BindingSet > ( ) ; { final MapBindingSet bset = new MapBindingSet ( ) ; bset . addBinding ( "s" , book1 ) ; bset . addBinding ( "p" , DC . CREATOR ) ; bset . addBinding ( "o" , author1 ) ; bindingSets . add ( bset ) ; } { final MapBindingSet bset = new MapBindingSet ( ) ; bset . addBinding ( "s" , book2 ) ; bset . addBinding ( "p" , DC . CREATOR ) ; bset . addBinding ( "o" , author2 ) ; bindingSets . add ( bset ) ; } final BindingSet [ ] a = bindingSets . toArray ( new BindingSet [ bindingSets . size ( ) ] ) ; final IRemoteSparqlQueryBuilder fixture = newFixture ( serviceNode , a ) ; final String queryStr = fixture . getSparqlQuery ( a ) ; final QueryRoot expected = new QueryRoot ( QueryType . SELECT ) ; { expected . setPrefixDecls ( prefixDecls ) ; final ProjectionNode projection = new ProjectionNode ( ) ; projection . addProjectionVar ( new VarNode ( "s" ) ) ; projection . addProjectionVar ( new VarNode ( "p" ) ) ; projection . addProjectionVar ( new VarNode ( "o" ) ) ; expected . setProjection ( projection ) ; final JoinGroupNode whereClause = new JoinGroupNode ( ) ; expected . setWhereClause ( whereClause ) ; final UnionNode union = new UnionNode ( ) ; whereClause . addChild ( union ) ; { final JoinGroupNode graphPattern = new JoinGroupNode ( ) ; union . addChild ( graphPattern ) ; graphPattern . addChild ( new FilterNode ( FunctionNode . sameTerm ( new VarNode ( "s" ) , new ConstantNode ( book1 . getIV ( ) ) ) ) ) ; graphPattern . addChild ( new FilterNode ( FunctionNode . sameTerm ( new VarNode ( "p" ) , new ConstantNode ( dcCreator . getIV ( ) ) ) ) ) ; graphPattern . addChild ( new FilterNode ( FunctionNode . sameTerm ( new VarNode ( "o" ) , new ConstantNode ( author1 . getIV ( ) ) ) ) ) ; graphPattern . addChild ( new StatementPatternNode ( new VarNode ( "s" ) , new VarNode ( "p" ) , new VarNode ( "o" ) , null , Scope . DEFAULT_CONTEXTS ) ) ; } { final JoinGroupNode graphPattern = new JoinGroupNode ( ) ; union . addChild ( graphPattern ) ; graphPattern . addChild ( new FilterNode ( FunctionNode . sameTerm ( new VarNode ( "s" ) , new ConstantNode ( book2 . getIV ( ) ) ) ) ) ; graphPattern . addChild ( new FilterNode ( FunctionNode . sameTerm ( new VarNode ( "p" ) , new ConstantNode ( dcCreator . getIV ( ) ) ) ) ) ; graphPattern . addChild ( new FilterNode ( FunctionNode . sameTerm ( new VarNode ( "o" ) , new ConstantNode ( author2 . getIV ( ) ) ) ) ) ; graphPattern . addChild ( new StatementPatternNode ( new VarNode ( "s" ) , new VarNode ( "p" ) , new VarNode ( "o" ) , null , Scope . DEFAULT_CONTEXTS ) ) ; } } final QueryRoot actual = parse ( queryStr , baseURI ) ; assertSameAST ( queryStr , expected , actual ) ; }
a test where a single fully bound triple pattern is presented . < p > note : it is possible to optimize this as an ask query , but only when there is a single solution flowing into the service end point .
