QBQuadHolder implements QuadHolder { @Override public ExtendedIterator<Quad> getQuads() { Query q = qb.build(); QuadIteratorBuilder builder = new QuadIteratorBuilder(defaultGraphName); q.getQueryPattern().visit(builder); return builder.iter; } QBQuadHolder( Node graph, AbstractQueryBuilder<?> qb );  QBQuadHolder( AbstractQueryBuilder<?> qb ); @Override ExtendedIterator<Quad> getQuads(); @Override QuadHolder setValues(Map<Var, Node> values);  }
@Test public void anonymousTest() { WhereBuilder builder = new WhereBuilder(); List<Triple> tLst = new ArrayList<Triple>(); Node s = NodeFactory.createURI( "s" ); Node p = NodeFactory.createURI( "p" ); Node o = NodeFactory.createURI( "o" ); tLst.add( new Triple( s, p, o ) ); builder.addWhere( s, p, o ); Node s2 = NodeFactory.createURI( "s2" ); Node p2 = NodeFactory.createURI( "p2" ); Node o2 = NodeFactory.createURI( "o2" ); tLst.add( new Triple( s2, p2, o2 ) ); builder.addWhere( s2, p2, o2 ); holder = new QBQuadHolder( builder ); List<Quad> lst = holder.getQuads().toList(); assertEquals( 2, lst.size() ); assertEquals( new Quad( Quad.defaultGraphNodeGenerated, tLst.get(0)), lst.get(0)); assertEquals( new Quad( Quad.defaultGraphNodeGenerated, tLst.get(1)), lst.get(1)); }
@Test public void namedTest() { WhereBuilder builder = new WhereBuilder(); Node g = NodeFactory.createURI( "g" ); List<Triple> tLst = new ArrayList<Triple>(); Node s = NodeFactory.createURI( "s" ); Node p = NodeFactory.createURI( "p" ); Node o = NodeFactory.createURI( "o" ); tLst.add( new Triple( s, p, o ) ); builder.addGraph( g, s, p, o ); Node s2 = NodeFactory.createURI( "s2" ); Node p2 = NodeFactory.createURI( "p2" ); Node o2 = NodeFactory.createURI( "o2" ); tLst.add( new Triple( s2, p2, o2 ) ); builder.addGraph( g, s2, p2, o2 ); holder = new QBQuadHolder( builder ); List<Quad> lst = holder.getQuads().toList(); assertEquals( 2, lst.size() ); assertEquals( new Quad( g, tLst.get(0)), lst.get(0)); assertEquals( new Quad( g, tLst.get(1)), lst.get(1)); }
@Test public void mixedTest() { WhereBuilder builder = new WhereBuilder(); List<Triple> tLst = new ArrayList<Triple>(); Node s = NodeFactory.createURI( "s" ); Node p = NodeFactory.createURI( "p" ); Node o = NodeFactory.createURI( "o" ); tLst.add( new Triple( s, p, o ) ); builder.addWhere( s, p, o ); Node g = NodeFactory.createURI( "g" ); Node s2 = NodeFactory.createURI( "s2" ); Node p2 = NodeFactory.createURI( "p2" ); Node o2 = NodeFactory.createURI( "o2" ); tLst.add( new Triple( s2, p2, o2 ) ); builder.addGraph( g, s2, p2, o2 ); holder = new QBQuadHolder( builder ); List<Quad> lst = holder.getQuads().toList(); assertEquals( 2, lst.size() ); assertEquals( new Quad( Quad.defaultGraphNodeGenerated, tLst.get(0)), lst.get(0)); assertEquals( new Quad( g, tLst.get(1)), lst.get(1)); }