Search in sources :

Example 21 with Element

use of org.apache.jena.sparql.syntax.Element in project jena by apache.

the class AbstractTestUpdateGraph method testModify2.

@Test
public void testModify2() {
    // Use blank nodes (will expose any problems in serialization when spill occurs)
    Triple t = new Triple(org.apache.jena.graph.NodeFactory.createBlankNode(), p, o2);
    DatasetGraph gStore = getEmptyDatasetGraph();
    // Set the threshold to in order to force spill to disk
    gStore.getContext().set(ARQ.spillToDiskThreshold, 0L);
    defaultGraphData(gStore, data(t));
    namedGraphData(gStore, graphIRI, data(t));
    UpdateModify modify = new UpdateModify();
    Element element = QueryFactory.createElement("{ ?s <http://example/p> ?o }");
    modify.setElement(element);
    modify.getInsertAcc().addQuad(new Quad(graphIRI, triple1));
    modify.getDeleteAcc().addTriple(SSE.parseTriple("(?s <http://example/p> ?o)"));
    modify.getDeleteAcc().addQuad(SSE.parseQuad("(<http://example/graph> ?s <http://example/p> ?o)"));
    UpdateAction.execute(modify, gStore);
    assertFalse(graphEmpty(gStore.getGraph(graphIRI)));
    assertTrue(graphEmpty(gStore.getDefaultGraph()));
    assertTrue(graphContains(gStore.getGraph(graphIRI), triple1));
    assertFalse(graphContains(gStore.getGraph(graphIRI), t));
}
Also used : Quad(org.apache.jena.sparql.core.Quad) Element(org.apache.jena.sparql.syntax.Element) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test)

Aggregations

Element (org.apache.jena.sparql.syntax.Element)21 Test (org.junit.Test)9 ElementGroup (org.apache.jena.sparql.syntax.ElementGroup)8 Query (org.apache.jena.query.Query)7 Quad (org.apache.jena.sparql.core.Quad)6 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)5 ElementTriplesBlock (org.apache.jena.sparql.syntax.ElementTriplesBlock)4 Node (org.apache.jena.graph.Node)3 Var (org.apache.jena.sparql.core.Var)3 Binding (org.apache.jena.sparql.engine.binding.Binding)3 ElementPathBlock (org.apache.jena.sparql.syntax.ElementPathBlock)3 UpdateBuilder (org.apache.jena.arq.querybuilder.UpdateBuilder)2 Triple (org.apache.jena.graph.Triple)2 UpdateModify (org.apache.jena.sparql.modify.request.UpdateModify)2 ElementNamedGraph (org.apache.jena.sparql.syntax.ElementNamedGraph)2 Update (org.apache.jena.update.Update)2 ContractTest (org.xenei.junit.contract.ContractTest)2 InternalErrorException (org.apache.jena.atlas.lib.InternalErrorException)1 BasicPattern (org.apache.jena.sparql.core.BasicPattern)1 E_Random (org.apache.jena.sparql.expr.E_Random)1