@Override public Iterator<Quad> execConstructQuads() { beforeExec(); try { return decoratee.execConstructQuads(); } catch(Exception e) { onException(e); // throw new RuntimeException(e); throw e; } finally { afterExec(); } }
Iterator<Quad> it = qe.execConstructQuads(); while (it.hasNext()) { Quad t = it.next();
@Test public void testARQConstructQuad_Duplicate_1() { String queryString = "CONSTRUCT { GRAPH ?g1 {?s ?p ?o} } WHERE { ?s ?p ?o. GRAPH ?g1 {?s1 ?p1 ?o1} }"; Query q = QueryFactory.create(queryString, Syntax.syntaxARQ); QueryExecution qExec = QueryExecutionFactory.create(q, d); Iterator<Quad> ts = qExec.execConstructQuads(); long count = 0; Quad expected = Quad.create( g1.asNode(), s.asNode(), p.asNode(), o.asNode()); while (ts.hasNext()) { count++; Quad qd = ts.next(); assertEquals(expected, qd); } assertEquals(3, count); // 3 duplicated quads }
@Test public void testARQConstructQuad_Duplicate_3() { String queryString = "CONSTRUCT { GRAPH ?g1 {?s ?p ?o} GRAPH ?g1 {?s ?p ?o} } WHERE { ?s ?p ?o. GRAPH ?g1 {?s1 ?p1 ?o1} }"; Query q = QueryFactory.create(queryString, Syntax.syntaxARQ); QueryExecution qExec = QueryExecutionFactory.create(q, d); Iterator<Quad> ts = qExec.execConstructQuads(); long count = 0; Quad expected = Quad.create( g1.asNode(), s.asNode(), p.asNode(), o.asNode()); while (ts.hasNext()) { count++; Quad qd = ts.next(); assertEquals(expected, qd); } assertEquals(6, count); // 6 duplicated quads }
@Test public void testARQConstructQuad_a_2() { String queryString = "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o }"; Query q = QueryFactory.create(queryString, Syntax.syntaxARQ); QueryExecution qExec = QueryExecutionFactory.create(q, d); Iterator<Quad> ts = qExec.execConstructQuads(); DatasetGraph result = DatasetGraphFactory.create(); long count = 0; while (ts.hasNext()) { count++; result.add( ts.next() ); } DatasetGraph expected = DatasetGraphFactory.create(); expected.add(Quad.defaultGraphNodeGenerated, s.asNode(), p.asNode(), o.asNode()); assertEquals(1, count); assertTrue(IsoMatcher.isomorphic( expected, result) ); }
@Test public void testARQConstructQuad_b_2() { String queryString = "CONSTRUCT { GRAPH ?g1 {?s ?p ?o} } WHERE { ?s ?p ?o. GRAPH ?g1 {?s1 ?p1 'x1'} }"; Query q = QueryFactory.create(queryString, Syntax.syntaxARQ); QueryExecution qExec = QueryExecutionFactory.create(q, d); Iterator<Quad> ts = qExec.execConstructQuads(); DatasetGraph result = DatasetGraphFactory.create(); long count = 0; while (ts.hasNext()) { count++; Quad qd = ts.next(); result.add(qd); } DatasetGraph expected = DatasetGraphFactory.create(); expected.add(g1.asNode(), s.asNode(), p.asNode(), o.asNode()); assertEquals(1, count); assertTrue(IsoMatcher.isomorphic( expected, result) ); }
@Test public void testARQConstructQuad_Prefix() { String queryString = "PREFIX : <http://example/ns#> CONSTRUCT { GRAPH :g1 { ?s :p ?o} } WHERE { ?s ?p ?o }"; Query q = QueryFactory.create(queryString, Syntax.syntaxARQ); QueryExecution qExec = QueryExecutionFactory.create(q, d); Iterator<Quad> quads = qExec.execConstructQuads(); DatasetGraph result = DatasetGraphFactory.create(); long count = 0; while (quads.hasNext()) { count++; Quad qd = quads.next(); result.add(qd); } DatasetGraph expected = DatasetGraphFactory.create(); expected.add(g1.asNode(), s.asNode(), p.asNode(), o.asNode()); assertEquals(1, count); assertTrue(IsoMatcher.isomorphic( expected, result) ); }
Iterator<Quad> it = qe.execConstructQuads(); result = SPARQLResultEx.createQuads(it);