Skip to content

Commit

Permalink
Make projects fields a list in suite json-ld context (#5047)
Browse files Browse the repository at this point in the history
* Make projects fields a list in suite json-ld context

* Address feedback

* Fix flaky test

---------

Co-authored-by: Simon Dumas <simon.dumas@epfl.ch>
  • Loading branch information
imsdu and Simon Dumas authored Jun 28, 2024
1 parent c56b221 commit 4882be8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ class SearchRoutesSpec extends BaseRouteSpec {

private val fields = Json.obj("fields" := true)

private val publicProjects = Set(ProjectRef.unsafe("org", "project"), ProjectRef.unsafe("org2", "project2"))
private val multiProjects = Set(ProjectRef.unsafe("org", "project"), ProjectRef.unsafe("org2", "project2"))
private val singleProjects = Set(ProjectRef.unsafe("org3", "project3"))
private val suites = Map(
Label.unsafe("public") -> publicProjects,
Label.unsafe("private") -> Set(ProjectRef.unsafe("org3", "project3"))
Label.unsafe("multi") -> multiProjects,
Label.unsafe("single") -> singleProjects
)

private lazy val routes = Route.seal(
Expand Down Expand Up @@ -76,7 +77,7 @@ class SearchRoutesSpec extends BaseRouteSpec {
}

"fail for an invalid payload during a search in a suite" in {
val searchSuiteName = "public"
val searchSuiteName = "multi"
val payload = Json.obj()
Post(s"/v1/search/query/suite/$searchSuiteName", payload.toEntity) ~> routes ~> check {
status shouldEqual StatusCodes.NotFound
Expand All @@ -90,11 +91,19 @@ class SearchRoutesSpec extends BaseRouteSpec {
}
}

"fetch a suite" in {
Get(s"/v1/search/suites/public") ~> routes ~> check {
"fetch a suite with several projects" in {
Get(s"/v1/search/suites/multi") ~> routes ~> check {
status shouldEqual StatusCodes.OK
response.asJson should have(name("multi"))
response.asJson should have(projects(multiProjects))
}
}

"fetch a suite with a single project" in {
Get(s"/v1/search/suites/single") ~> routes ~> check {
status shouldEqual StatusCodes.OK
response.asJson should have(name("public"))
response.asJson should have(projects(publicProjects))
response.asJson should have(name("single"))
response.asJson should have(projects(singleProjects))
}
}

Expand Down
5 changes: 4 additions & 1 deletion delta/sdk/src/main/resources/contexts/suites.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"@context": {
"@vocab": "https://bluebrain.github.io/nexus/vocabulary/",
"name": "https://schema.org/name"
"name": "https://schema.org/name",
"projects": {
"@container": "@list"
}
},
"@id": "https://bluebrain.github.io/nexus/contexts/suites.json"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ class SearchConfigIndexingSpec extends BaseIntegrationSpec {
}"""

assertOneSource(queryField(singleNeuronSimulationId, "singleNeuronSimulation")) { json =>
json shouldEqual expected
json should equalIgnoreArrayOrder(expected)
}
}

Expand Down

0 comments on commit 4882be8

Please sign in to comment.