My team is implementing a variation of Ceusters's Referent Tracking. In our implementation, the original URI for an entity can be changed (to something containing a UUID), although a link to the original URI is always kept.
For example:
:Joey rdf:type :person .
:New_York_City rdf:type :locality .
:Joey :hometown :New_York_City .
might become:
:Joey :replacedWith :ABC123 .
:ABC123 rdf:type :person .
:New_York_City :replacedWith :FFF555 .
:FFF555 rdf:type :locality .
:ABC123 :hometown :FFF555 .
I am writing some Scala integration tests to see if our software does the referent tracking correctly.
Specifically, I know I should expect this CorrectPattern
:
:Joey :replacedWith ?person .
?person rdf:type :person .
:New_York_City :replacedWith ?locale .
?locale rdf:type :locality .
?person :hometown ?locale .
But I don't know what the values of ?person
and ?locale
will be.
I can SPARQL ASK
for CorrectPattern
... that will tell me if the pattern is present. But I also want to confirm that nothing else has been added.
I thought I could CONSTRUCT { ?s ?p ?o }
, MINUS
out CorrectPattern
, and check for an empty result, but Blazegraph is saying:
java.util.concurrent.ExecutionException: org.openrdf.query.MalformedQueryException: CONSTRUCT WHERE only permits statement patterns in the WHERE clause.
Any ideas? I want to check that the whole triple store contains nothing more and nothing less than CorrectPattern
, but I think CorrectPattern
must contain variables.
Once again bailed out by a comment from @AKSW, who doesn't seem to be especially obsessed with earning reputation points.
This
CONSTRUCT
, with an embeddedSELECT
, gets all triples from my model, depleted of any triples in theMINUS
block, even when they contain variables. I'm pretty sure I can flesh out theMINUS
block and finish my task.In order to determine that the triple-store contains only the triples which you expect and nothing more, you could test for the exact triples which you expect while simultaneously counting the number of triples which appear in the database before and after you run your program. If the difference in triples is higher or lower than you expect, you will know that you have some extraneous or missing data.
Use
SPARQL SELECT
Count function:Pseudocode:
Additionally, if you are resistant to using variables in your tests, you could write additional queries to capture the URI of the node you have created, then add the results to your test queries using String concatenation.