@Test public void Pattern_via_has() { assertEquals( Blocks.pattern(subject, predicate, object), subject.has(predicate, object)); }
@Test public void Pattern_via_has_with_Context() { assertEquals( Blocks.pattern(subject, predicate, object, context), subject.has(predicate, object, context)); }
@Test public void Optional_via_has() { assertEquals( Blocks.optional(Blocks.pattern(subject, predicate, object)), subject.has(predicate, object).asOptional()); }
@Test public void Delete_Where_No_Match() throws IOException { RDFUpdate delete = update().delete(s.a(example)).where(s.has(p, o)); delete.execute(); assertTrue(connection().exists(null, null, null, null, false)); }
@Test public void Delete_Where_Matches() throws IOException { RDFUpdate delete = update().delete(s.a(RDFS.Class)).where(s.has(p, o)); delete.execute(); assertFalse(connection().exists(null, RDF.type, RDFS.Class, null, false)); }
@Test public void Insert_Where() throws IOException { RDFUpdate insert = update().insert(s.a(ex2)).where(s.has(p, o)); insert.execute(); assertTrue(connection().exists(RDFS.Resource, RDF.type, ex2, null, false)); }
@Test public void Insert_Into_Where() throws IOException { RDFUpdate insert = update().insert(s.a(ex2)).into(ex1).where(s.has(p, o)); insert.execute(); assertTrue(connection().exists(RDFS.Resource, RDF.type, ex2, ex1, false)); }
@Test public void Delete_From_From_Where() throws IOException { connection().update(null, Collections.singleton(new STMT(RDFS.Resource, RDF.type, RDFS.Class, ex1))); connection().update(null, Collections.singleton(new STMT(RDFS.Resource, RDF.type, RDFS.Class, ex2))); RDFUpdate delete = update().delete(s.a(RDFS.Class)).from(ex1, ex2).where(s.has(p, o)); delete.execute(); assertFalse(connection().exists(null, null, null, ex1, false)); assertFalse(connection().exists(null, null, null, ex2, false)); assertTrue(connection().exists(null, null, null, null, false)); }
@Test public void Delete_From_Where() throws IOException { connection().update(null, Collections.singleton(new STMT(RDFS.Resource, RDF.type, RDFS.Class, ex1))); RDFUpdate delete = update().delete(s.a(RDFS.Class)).from(ex1).where(s.has(p, o)); delete.execute(); assertFalse(connection().exists(null, null, null, ex1, false)); assertTrue(connection().exists(null, null, null, null, false)); }
@Test public void Insert_Into_Into_Where() throws IOException { RDFUpdate insert = update().insert(s.a(example)).into(ex1, ex2).where(s.has(p, o)); insert.execute(); assertTrue(connection().exists(RDFS.Resource, RDF.type, example, ex1, false)); assertTrue(connection().exists(RDFS.Resource, RDF.type, example, ex2, false)); }