Skip to content

Commit

Permalink
Merge pull request #172 from Swirrl/repository-single-statement-test
Browse files Browse the repository at this point in the history
Forward the graph to add/remove-statement in the arity-3 case
  • Loading branch information
RickMoynihan authored Jan 11, 2021
2 parents 142ce41 + e105856 commit c864a47
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/grafter_2/rdf4j/repository.clj
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
(when (seq triples)
(let [^Iterable stmts (map rio/quad->backend-quad triples)]
(.add this stmts (resource-array (rio/->rdf4j-uri graph)))))
(pr/add-statement this triples))
(pr/add-statement this graph triples))
this)

([this graph format triple-stream]
Expand Down Expand Up @@ -494,7 +494,7 @@
(when (seq triples)
(let [^Iterable stmts (map rio/quad->backend-quad triples)]
(.remove this stmts (resource-array (rio/->rdf4j-uri graph)))))
(pr/delete-statement this triples)))))
(pr/delete-statement this graph triples)))))

(extend-protocol ToConnection
RepositoryConnection
Expand Down
28 changes: 28 additions & 0 deletions test/grafter_2/rdf4j/repository_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,34 @@
(is (query test-db "ASK { GRAPH <http://b> { ?s ?p ?o } } LIMIT 1")
"Should not be deleted")))))

(deftest single-statement-test
(let [triple (core/->Triple
(URI. "http://one")
(URI. "http://lonely")
(URI. "http://triple"))]
(testing "arity 2"
(let [ask "ASK { <http://one> <http://lonely> <http://triple> }"]
(with-open [conn (->connection (sail-repo))]
(core/add conn triple)
(is (query conn ask))
(core/delete conn triple)
(is (not (query conn ask))))))
(testing "arity 3"
(let [ask-a "ASK {
GRAPH <http://a> {
<http://one> <http://lonely> <http://triple> } }"
ask-b "ASK {
GRAPH <http://b> {
<http://one> <http://lonely> <http://triple> } }"]
(with-open [conn (->connection (sail-repo))]
(core/add conn (URL. "http://a") triple)
(core/add conn (URL. "http://b") triple)
(is (query conn ask-a))
(is (query conn ask-b))
(core/delete conn (URL. "http://a") triple)
(is (not (query conn ask-a)))
(is (query conn ask-b)))))))

(deftest col-reduce-repo-test
(is (= (into #{} (sail-repo))
#{}))
Expand Down

0 comments on commit c864a47

Please sign in to comment.