@Test public void Pattern_via_a() { assertEquals( Blocks.pattern(subject, RDF.type, RDFS.Class), subject.a(RDFS.Class)); }
@Test public void Pattern_via_a_with_Context() { assertEquals( Blocks.pattern(subject, RDF.type, RDFS.Class, context), subject.a(RDFS.Class, context)); }
@Test public void ToString() { MiniConnection connection = new MiniRepository().openConnection(); RDFQuery query = new RDFQueryImpl(connection); query.where(QNODE.s.a(RDFS.Resource)); assertEquals( "SELECT * WHERE { ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Resource> } ", query.toString().replaceAll("\\s+", " ")); }
@Test public void ToString_After_Invocation() { MiniConnection connection = new MiniRepository().openConnection(); RDFQuery query = new RDFQueryImpl(connection); query.where(QNODE.s.a(RDFS.Resource)); query.createBooleanQuery(); assertEquals( "SELECT * WHERE { ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Resource> } ", query.toString().replaceAll("\\s+", " ")); }
@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)); }