use of org.apache.jena.graph.Graph in project jena by apache.
the class TestCustomAggregates method customAgg_20.
@Test
public void customAgg_20() {
Graph g = SSE.parseGraph("(graph (:s :p :o) (:s :p 1))");
Model m = ModelFactory.createModelForGraph(g);
String qs = "SELECT (<" + aggIRI + ">(?o) AS ?x) {?s ?p ?o } GROUP BY ?s";
Query q = QueryFactory.create(qs, Syntax.syntaxARQ);
try (QueryExecution qExec = QueryExecutionFactory.create(q, m)) {
ResultSet rs = qExec.execSelect();
QuerySolution soln = rs.nextSolution();
assertFalse(rs.hasNext());
int v = soln.getLiteral("x").getInt();
assertEquals(1, v);
}
}
use of org.apache.jena.graph.Graph in project jena by apache.
the class TestCustomAggregates method customAgg_21.
@Test
public void customAgg_21() {
Graph g = SSE.parseGraph("(graph (:s :p :o) (:s :p 1))");
Model m = ModelFactory.createModelForGraph(g);
String qs = "SELECT (<" + aggIRI + ">(?o) AS ?x) {?s ?p ?o FILTER (false) } GROUP BY ?s";
Query q = QueryFactory.create(qs, Syntax.syntaxARQ);
try (QueryExecution qExec = QueryExecutionFactory.create(q, m)) {
ResultSet rs = qExec.execSelect();
QuerySolution soln = rs.nextSolution();
assertFalse(rs.hasNext());
int v = soln.getLiteral("x").getInt();
assertEquals(-1, v);
}
}
use of org.apache.jena.graph.Graph in project jena by apache.
the class AbstractTestDatasetGraphAccessor method put_02.
@Test
public void put_02() {
DatasetGraphAccessor updater = getDatasetUpdater();
updater.httpPut(n1, graph1);
Graph graph = updater.httpGet();
assertNullOrEmpty(graph);
graph = updater.httpGet(n1);
assertNotNull("Graph is null", graph);
assertTrue(graph.isIsomorphicWith(graph1));
}
use of org.apache.jena.graph.Graph in project jena by apache.
the class AbstractTestDatasetGraphAccessor method put_01.
@Test
public void put_01() {
DatasetGraphAccessor updater = getDatasetUpdater();
updater.httpPut(graph1);
Graph graph = updater.httpGet();
assertNotNull("Graph is null", graph);
assertTrue(graph.isIsomorphicWith(graph1));
}
use of org.apache.jena.graph.Graph in project jena by apache.
the class GraphMakerContractTest method testListAfterDelete.
/**
* Test that a maker with some things put in and then some removed gets the
* right things listed.
*/
@ContractTest
public void testListAfterDelete() {
String x = "x_y", y = "y//zub", z = "a:b/c";
Graph X = graphMaker.createGraph(x);
Graph Y = graphMaker.createGraph(y);
Graph Z = graphMaker.createGraph(z);
graphMaker.removeGraph(x);
Set<String> s = GraphHelper.iteratorToSet(graphMaker.listGraphs());
assertEquals(TestUtils.setOfStrings(y + " " + z), s);
X.close();
Y.close();
Z.close();
}
Aggregations