use of org.apache.jena.sparql.core.DatasetGraphWrapper in project jena by apache.
the class TestUpdateOperations method delete_insert_where_01.
// Check constant and template quads
@Test
public void delete_insert_where_01() {
DatasetGraph dsg0 = DatasetGraphFactory.create();
UpdateRequest req = UpdateFactory.create("INSERT DATA { <x> <p> 2 . <z> <q> 2 . <z> <q> 3 . }");
UpdateAction.execute(req, dsg0);
assertEquals(3, dsg0.getDefaultGraph().size());
AtomicLong counterIns = new AtomicLong(0);
AtomicLong counterDel = new AtomicLong(0);
DatasetGraph dsg = new DatasetGraphWrapper(dsg0) {
@Override
public void add(Quad quad) {
counterIns.incrementAndGet();
super.add(quad);
}
@Override
public void delete(Quad quad) {
counterDel.incrementAndGet();
super.delete(quad);
}
};
// WHERE clause doubles the effect.
String s = "DELETE { ?x <p> 2 . <z> <q> 2 } INSERT { ?x <p> 1 . <x> <q> 1 } WHERE { ?x <p> ?o {} UNION {} }";
req = UpdateFactory.create(s);
UpdateAction.execute(req, dsg);
// 3 : 1 constant, 2 from template.
assertEquals(3, counterIns.get());
assertEquals(3, counterIns.get());
assertEquals(3, dsg.getDefaultGraph().size());
}
Aggregations