public void test_service_006() throws Exception {
  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")));
    groupNode.addChild(new StatementPatternNode(new VarNode("s"),new VarNode("p"),new VarNode("o1")));
  }
  final String exprImage="SERVICE <" + serviceURI + "> { ?s ?p ?o . ?s ?p ?o1 }";
  final Map<String,String> prefixDecls=new LinkedHashMap<String,String>(PrefixDeclProcessor.defaultDecls);
  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"));
      projectedVars.add(Var.var("o1"));
    }
    serviceNode.setExprImage(exprImage);
    serviceNode.setPrefixDecls(prefixDecls);
    serviceNode.setProjectedVars(projectedVars);
  }
  final List<BindingSet> bindingSets=new LinkedList<BindingSet>();
{
    final MapBindingSet bset=new MapBindingSet();
    final BNode tmp=new BNodeImpl("abc");
    bset.addBinding("s",tmp);
    bset.addBinding("o",tmp);
    bset.addBinding("o1",tmp);
    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"));
    projection.addProjectionVar(new VarNode("o1"));
    expected.setProjection(projection);
    final JoinGroupNode whereClause=new JoinGroupNode();
    whereClause.addChild(new FilterNode(FunctionNode.AND(FunctionNode.sameTerm(new VarNode("s"),new VarNode("o")),FunctionNode.sameTerm(new VarNode("s"),new VarNode("o1")))));
    whereClause.addChild(new StatementPatternNode(new VarNode("s"),new VarNode("p"),new VarNode("o"),null,Scope.DEFAULT_CONTEXTS));
    whereClause.addChild(new StatementPatternNode(new VarNode("s"),new VarNode("p"),new VarNode("o1"),null,Scope.DEFAULT_CONTEXTS));
    expected.setWhereClause(whereClause);
  }
  final QueryRoot actual=parse(queryStr,baseURI);
  assertSameAST(queryStr,expected,actual);
}

public void test_service_006 ( ) throws Exception { 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" ) ) ) ; groupNode . addChild ( new StatementPatternNode ( new VarNode ( "s" ) , new VarNode ( "p" ) , new VarNode ( "o1" ) ) ) ; } final String exprImage = "SERVICE <" + serviceURI + "> { ?s ?p ?o . ?s ?p ?o1 }" ; final Map < String , String > prefixDecls = new LinkedHashMap < String , String > ( PrefixDeclProcessor . defaultDecls ) ; 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" ) ) ; projectedVars . add ( Var . var ( "o1" ) ) ; } serviceNode . setExprImage ( exprImage ) ; serviceNode . setPrefixDecls ( prefixDecls ) ; serviceNode . setProjectedVars ( projectedVars ) ; } final List < BindingSet > bindingSets = new LinkedList < BindingSet > ( ) ; { final MapBindingSet bset = new MapBindingSet ( ) ; final BNode tmp = new BNodeImpl ( "abc" ) ; bset . addBinding ( "s" , tmp ) ; bset . addBinding ( "o" , tmp ) ; bset . addBinding ( "o1" , tmp ) ; 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" ) ) ; projection . addProjectionVar ( new VarNode ( "o1" ) ) ; expected . setProjection ( projection ) ; final JoinGroupNode whereClause = new JoinGroupNode ( ) ; whereClause . addChild ( new FilterNode ( FunctionNode . AND ( FunctionNode . sameTerm ( new VarNode ( "s" ) , new VarNode ( "o" ) ) , FunctionNode . sameTerm ( new VarNode ( "s" ) , new VarNode ( "o1" ) ) ) ) ) ; whereClause . addChild ( new StatementPatternNode ( new VarNode ( "s" ) , new VarNode ( "p" ) , new VarNode ( "o" ) , null , Scope . DEFAULT_CONTEXTS ) ) ; whereClause . addChild ( new StatementPatternNode ( new VarNode ( "s" ) , new VarNode ( "p" ) , new VarNode ( "o1" ) , null , Scope . DEFAULT_CONTEXTS ) ) ; expected . setWhereClause ( whereClause ) ; } final QueryRoot actual = parse ( queryStr , baseURI ) ; assertSameAST ( queryStr , expected , actual ) ; }
a variant test in there is a blank node in the bindings to be flowed through to the remote service . in this test the blank nodes are correlated but there is only one solution to be vectored so we will impose a filter on the remote service to enforce that correlation . this test differs from the previous test by making more than two variables in the service clause correlated through shared blank nodes . we need to use a more complex service graph pattern to accomplish this since the predicate can not be a blank node .
