use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class UpdateBuilderTest method testInsertAndDelete.
@Test
public void testInsertAndDelete() {
UpdateBuilder builder = new UpdateBuilder();
builder.addInsert(new Quad(g, s, p, o));
builder.addDelete(new Triple(s, p, o));
builder.addWhere(null, p, "foo");
Update update = builder.build();
assertTrue(update instanceof UpdateModify);
UpdateModify um = (UpdateModify) update;
List<Quad> quads = um.getInsertQuads();
assertEquals(1, quads.size());
Quad q = quads.get(0);
assertEquals(g, q.getGraph());
assertEquals(s, q.getSubject());
assertEquals(p, q.getPredicate());
assertEquals(o, q.getObject());
quads = um.getDeleteQuads();
assertEquals(1, quads.size());
q = quads.get(0);
assertEquals(Quad.defaultGraphNodeGenerated, q.getGraph());
assertEquals(s, q.getSubject());
assertEquals(p, q.getPredicate());
assertEquals(o, q.getObject());
Element e = um.getWherePattern();
assertTrue(e instanceof ElementGroup);
ElementGroup eg = (ElementGroup) e;
assertEquals(1, eg.getElements().size());
ElementPathBlock epb = (ElementPathBlock) eg.getElements().get(0);
Triple t = epb.getPattern().get(0).asTriple();
assertEquals(Node.ANY, t.getSubject());
assertEquals(p, t.getPredicate());
assertEquals(builder.makeNode("foo"), t.getObject());
}
use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class UpdateBuilderTest method testInsert_Quad.
@Test
public void testInsert_Quad() {
UpdateBuilder builder = new UpdateBuilder();
builder.addInsert(new Quad(g, s, p, o));
Update update = builder.build();
assertTrue(update instanceof UpdateDataInsert);
UpdateDataInsert udi = (UpdateDataInsert) update;
List<Quad> quads = udi.getQuads();
assertEquals(1, quads.size());
Quad q = quads.get(0);
assertEquals(g, q.getGraph());
assertEquals(s, q.getSubject());
assertEquals(p, q.getPredicate());
assertEquals(o, q.getObject());
}
use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class UpdateBuilderTest method testInsert_NodeTriple.
@Test
public void testInsert_NodeTriple() {
Triple t = new Triple(s, p, o);
UpdateBuilder builder = new UpdateBuilder();
builder.addInsert(g, t);
Update update = builder.build();
assertTrue(update instanceof UpdateDataInsert);
UpdateDataInsert udi = (UpdateDataInsert) update;
List<Quad> quads = udi.getQuads();
assertEquals(1, quads.size());
Quad q = quads.get(0);
assertEquals(g, q.getGraph());
assertEquals(s, q.getSubject());
assertEquals(p, q.getPredicate());
assertEquals(o, q.getObject());
}
use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class UpdateBuilderTest method testInsert_GSPO.
@Test
public void testInsert_GSPO() {
UpdateBuilder builder = new UpdateBuilder();
builder.addInsert(g, s, p, o);
Update update = builder.build();
assertTrue(update instanceof UpdateDataInsert);
UpdateDataInsert udi = (UpdateDataInsert) update;
List<Quad> quads = udi.getQuads();
assertEquals(1, quads.size());
Quad q = quads.get(0);
assertEquals(g, q.getGraph());
assertEquals(s, q.getSubject());
assertEquals(p, q.getPredicate());
assertEquals(o, q.getObject());
}
use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class UpdateBuilderTest method testDelete_SPO.
@Test
public void testDelete_SPO() {
UpdateBuilder builder = new UpdateBuilder();
builder.addDelete(s, p, o);
Update update = builder.build();
assertTrue(update instanceof UpdateDataDelete);
UpdateDataDelete udd = (UpdateDataDelete) update;
List<Quad> quads = udd.getQuads();
assertEquals(1, quads.size());
Quad q = quads.get(0);
assertEquals(Quad.defaultGraphNodeGenerated, q.getGraph());
assertEquals(s, q.getSubject());
assertEquals(p, q.getPredicate());
assertEquals(o, q.getObject());
}
Aggregations