Skip to content

Commit

Permalink
Add Sparql test to query default view by tag
Browse files Browse the repository at this point in the history
  • Loading branch information
dantb committed Oct 11, 2023
1 parent 06b8813 commit 7e40993
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"head": {
"vars": [
"s"
]
},
"results": {
"bindings": [
{
"s": {
"type": "uri",
"value": "https://bbp.epfl.ch/nexus/v0/data/bbp/experiment/patchedcell/v0.1.0/010b8ecb-21ac-4987-8faa-91f1274e656d"
}
},
{
"s": {
"type": "uri",
"value": "https://bbp.epfl.ch/nexus/v0/data/bbp/experiment/patchedcell/v0.1.0/03e9025f-35ab-42ca-ac4a-5da2701b93f3"
}
},
{
"s": {
"type": "uri",
"value": "https://bbp.epfl.ch/nexus/v0/data/bbp/experiment/patchedcell/v0.1.0/048bf2a9-c3e4-4401-bb1e-61f5fcacb85b"
}
},
{
"s": {
"type": "uri",
"value": "https://bbp.epfl.ch/nexus/v0/data/bbp/experiment/patchedcell/v0.1.0/04e5f081-26fb-49ea-9d38-da7ef49d9e9f"
}
},
{
"s": {
"type": "uri",
"value": "https://bbp.epfl.ch/nexus/v0/data/bbp/experiment/patchedcell/v0.1.0/08825325-0a84-4924-839b-baabcd9bdbb8"
}
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class SparqlViewsSpec extends BaseSpec with EitherValuable with CirceEq {
"create a context" in {
val payload = jsonContentOf("/kg/views/context.json")

projects.parTraverse { project =>
projects.traverse { project =>
deltaClient.put[Json](s"/resources/$project/resource/test-resource:context", payload, ScoobyDoo) {
(_, response) =>
response.status shouldEqual StatusCodes.Created
Expand Down Expand Up @@ -230,7 +230,7 @@ class SparqlViewsSpec extends BaseSpec with EitherValuable with CirceEq {
}

"tag resources" in {
(1 to 5).toList.parTraverse { i =>
(1 to 5).toList.traverse { i =>
val payload = jsonContentOf(s"/kg/views/instances/instance$i.json")
val id = `@id`.getOption(payload).value
val unprefixedId = id.stripPrefix("https://bbp.epfl.ch/nexus/v0/data/bbp/experiment/patchedcell/v0.1.0/")
Expand Down Expand Up @@ -259,6 +259,24 @@ class SparqlViewsSpec extends BaseSpec with EitherValuable with CirceEq {
}
}

val byTagQuery =
"""
|prefix nxv: <https://bluebrain.github.io/nexus/vocabulary/>
|
|select ?s where {
| ?s nxv:tags "one"
|}
|order by ?s
""".stripMargin

"search by tag in SPARQL endpoint in project 1 with default view" in eventually {
deltaClient.sparqlQuery[Json](s"/views/$fullId/nxv:defaultSparqlIndex/sparql", byTagQuery, ScoobyDoo) {
(json, response) =>
response.status shouldEqual StatusCodes.OK
json shouldEqual jsonContentOf("/kg/views/sparql-search-response-tagged.json")
}
}

"search instances in SPARQL endpoint in project 1 with custom SparqlView after tags added" in {
eventually {
deltaClient.sparqlQuery[Json](s"/views/$fullId/test-resource:cell-view/sparql", query, ScoobyDoo) {
Expand Down

0 comments on commit 7e40993

Please sign in to comment.