@Test public void testInsert4() { DatasetGraph gStore = getEmptyDatasetGraph() ; defaultGraphData(gStore, graph1) ; UpdateModify insert = new UpdateModify() ; insert.getInsertAcc().addTriple(SSE.parseTriple("(?s <http://example/p> 1066)")) ; Element element = QueryFactory.createElement("{ ?s <http://example/p> 2007 }" ) ; insert.setElement(element) ; UpdateAction.execute(insert, gStore) ; assertTrue(graphContains(gStore.getDefaultGraph(), triple2)) ; }
@Test public void testDelete5() { DatasetGraph gStore = getEmptyDatasetGraph() ; defaultGraphData(gStore, data2()) ; namedGraphData(gStore, graphIRI, data1()) ; UpdateModify modify = new UpdateModify() ; Element element = QueryFactory.createElement("{ ?s <http://example/p> ?o }" ) ; modify.setElement(element) ; modify.getDeleteAcc().addQuad(SSE.parseQuad("(<http://example/graph> ?s <http://example/p> 2007 )")) ; UpdateAction.execute(modify, gStore) ; assertTrue("Not empty", graphEmpty(gStore.getGraph(graphIRI))) ; assertFalse(graphEmpty(gStore.getDefaultGraph())) ; }
@Test public void testModify1() { DatasetGraph gStore = getEmptyDatasetGraph() ; defaultGraphData(gStore, data2()) ; namedGraphData(gStore, graphIRI, Factory.createDefaultGraph()) ; 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)) ; }
@Test public void testModifyInitialBindings() { DatasetGraph gStore = getEmptyDatasetGraph() ; defaultGraphData(gStore, data12()) ; namedGraphData(gStore, graphIRI, Factory.createDefaultGraph()) ; Binding initialBinding = BindingFactory.binding(Var.alloc("o"), o1) ; 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, initialBinding) ; assertFalse(graphEmpty(gStore.getGraph(graphIRI))) ; assertFalse(graphEmpty(gStore.getDefaultGraph())) ; assertTrue(graphContains(gStore.getGraph(graphIRI), triple1)) ; assertTrue(graphContains(gStore.getDefaultGraph(), triple2)) ; assertFalse(graphContains(gStore.getDefaultGraph(), triple1)) ; }
@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)); }