From e7a97239f99d2b7dea2b961cf0478769e0af0fcc Mon Sep 17 00:00:00 2001 From: Simon Dumas Date: Thu, 4 Apr 2024 18:19:21 +0200 Subject: [PATCH] Remove useless test --- .../resources/contexts/search-document.json | 30 -- .../src/test/resources/organization.json | 74 ---- .../search/src/test/resources/person.json | 79 ----- .../search/src/test/resources/project.json | 86 ----- .../resources/search-document-result.json | 41 --- .../search/src/test/resources/trace.json | 319 ------------------ .../search/SearchSparqlQuerySpec.scala | 94 ------ 7 files changed, 723 deletions(-) delete mode 100644 delta/plugins/search/src/test/resources/contexts/search-document.json delete mode 100644 delta/plugins/search/src/test/resources/organization.json delete mode 100644 delta/plugins/search/src/test/resources/person.json delete mode 100644 delta/plugins/search/src/test/resources/project.json delete mode 100644 delta/plugins/search/src/test/resources/search-document-result.json delete mode 100644 delta/plugins/search/src/test/resources/trace.json delete mode 100644 delta/plugins/search/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/search/SearchSparqlQuerySpec.scala diff --git a/delta/plugins/search/src/test/resources/contexts/search-document.json b/delta/plugins/search/src/test/resources/contexts/search-document.json deleted file mode 100644 index 7f3a168939..0000000000 --- a/delta/plugins/search/src/test/resources/contexts/search-document.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "@context": { - "@vocab": "https://bluebrain.github.io/nexus/field/", - "identifier": { - "@type": "@id" - }, - "label": "http://www.w3.org/2000/01/rdf-schema#label", - "name": "http://schema.org/name", - "createdAt": { - "@type": "http://www.w3.org/2001/XMLSchema#dateTime" - }, - "contributors": { - "@container": "@set" - }, - "organizations": { - "@container": "@set" - }, - "project": { - "@type": "@id" - }, - "createdBy": { - "@type": "@id" - }, - "_self": { - "@type": "@id", - "@id": "https://bluebrain.github.io/nexus/vocabulary/self" - } - }, - "@id": "https://bluebrain.github.io/nexus/contexts/search-document.json" -} \ No newline at end of file diff --git a/delta/plugins/search/src/test/resources/organization.json b/delta/plugins/search/src/test/resources/organization.json deleted file mode 100644 index 0f4da3902d..0000000000 --- a/delta/plugins/search/src/test/resources/organization.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "@id": "https://www.grid.ac/institutes/grid.5333.6", - "@type": [ - "http://schema.org/Organization", - "http://www.w3.org/ns/prov#Agent" - ], - "http://schema.org/name": [ - { - "@value": "École Polytechnique Fédérale de Lausanne" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/constrainedBy": [ - { - "@id": "https://bluebrain.github.io/nexus/schemas/unconstrained.json" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/createdAt": [ - { - "@type": "http://www.w3.org/2001/XMLSchema#dateTime", - "@value": "2021-07-14T05:00:16.995Z" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/createdBy": [ - { - "@id": "http://localhost/v1/realms/bbp/users/broman" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/deprecated": [ - { - "@value": false - } - ], - "https://bluebrain.github.io/nexus/vocabulary/incoming": [ - { - "@id": "http://localhost/v1/resources/copies/sscx/_/https:%2F%2Fwww.grid.ac%2Finstitutes%2Fgrid.5333.6/incoming" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/outgoing": [ - { - "@id": "http://localhost/v1/resources/copies/sscx/_/https:%2F%2Fwww.grid.ac%2Finstitutes%2Fgrid.5333.6/outgoing" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/project": [ - { - "@id": "http://localhost/v1/projects/copies/sscx" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/rev": [ - { - "@value": 2 - } - ], - "https://bluebrain.github.io/nexus/vocabulary/schemaProject": [ - { - "@id": "http://localhost/v1/projects/copies/sscx" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/self": [ - { - "@id": "http://localhost/v1/resources/copies/sscx/_/https:%2F%2Fwww.grid.ac%2Finstitutes%2Fgrid.5333.6" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/updatedAt": [ - { - "@type": "http://www.w3.org/2001/XMLSchema#dateTime", - "@value": "2021-07-22T14:04:41.458Z" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/updatedBy": [ - { - "@id": "http://localhost/v1/realms/local/users/localuser" - } - ] -} \ No newline at end of file diff --git a/delta/plugins/search/src/test/resources/person.json b/delta/plugins/search/src/test/resources/person.json deleted file mode 100644 index 31aa489d64..0000000000 --- a/delta/plugins/search/src/test/resources/person.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "@id": "http://localhost/nexus/v1/realms/bbp/users/tuncel", - "@type": [ - "http://schema.org/Person", - "http://www.w3.org/ns/prov#Agent" - ], - "http://schema.org/familyName": [ - { - "@value": "Tuncel" - } - ], - "http://schema.org/givenName": [ - { - "@value": "Anil" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/constrainedBy": [ - { - "@id": "https://bluebrain.github.io/nexus/schemas/unconstrained.json" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/createdAt": [ - { - "@type": "http://www.w3.org/2001/XMLSchema#dateTime", - "@value": "2021-07-14T05:56:56.185Z" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/createdBy": [ - { - "@id": "http://localhost/v1/realms/bbp/users/broman" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/deprecated": [ - { - "@value": false - } - ], - "https://bluebrain.github.io/nexus/vocabulary/incoming": [ - { - "@id": "http://localhost/v1/resources/copies/sscx/_/https:%2F%2Fbbp.epfl.ch%2Fnexus%2Fv1%2Frealms%2Fbbp%2Fusers%2Ftuncel/incoming" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/outgoing": [ - { - "@id": "http://localhost/v1/resources/copies/sscx/_/https:%2F%2Fbbp.epfl.ch%2Fnexus%2Fv1%2Frealms%2Fbbp%2Fusers%2Ftuncel/outgoing" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/project": [ - { - "@id": "http://localhost/v1/projects/copies/sscx" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/rev": [ - { - "@value": 2 - } - ], - "https://bluebrain.github.io/nexus/vocabulary/schemaProject": [ - { - "@id": "http://localhost/v1/projects/copies/sscx" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/self": [ - { - "@id": "http://localhost/v1/resources/copies/sscx/_/https:%2F%2Fbbp.epfl.ch%2Fnexus%2Fv1%2Frealms%2Fbbp%2Fusers%2Ftuncel" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/updatedAt": [ - { - "@type": "http://www.w3.org/2001/XMLSchema#dateTime", - "@value": "2021-07-22T14:01:37.490Z" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/updatedBy": [ - { - "@id": "http://localhost/v1/realms/local/users/localuser" - } - ] -} \ No newline at end of file diff --git a/delta/plugins/search/src/test/resources/project.json b/delta/plugins/search/src/test/resources/project.json deleted file mode 100644 index 4e2ddcd178..0000000000 --- a/delta/plugins/search/src/test/resources/project.json +++ /dev/null @@ -1,86 +0,0 @@ -[ - { - "@id": "http://localhost/v1/projects/copies/sscx", - "@type": [ - "https://bluebrain.github.io/nexus/vocabulary/Project" - ], - "https://bluebrain.github.io/nexus/vocabulary/apiMappings": [], - "https://bluebrain.github.io/nexus/vocabulary/base": [ - { - "@id": "http://localhost/v1/resources/copies/sscx/_/" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/constrainedBy": [ - { - "@id": "https://bluebrain.github.io/nexus/schemas/projects.json" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/createdAt": [ - { - "@type": "http://www.w3.org/2001/XMLSchema#dateTime", - "@value": "2021-07-14T04:44:51.128Z" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/createdBy": [ - { - "@id": "http://localhost/v1/realms/bbp/users/broman" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/deprecated": [ - { - "@value": false - } - ], - "https://bluebrain.github.io/nexus/vocabulary/description": [ - { - "@value": "" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/label": [ - { - "@value": "sscx" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/organizationLabel": [ - { - "@value": "copies" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/organizationUuid": [ - { - "@value": "b11742dc-ddc5-450c-9532-405d47bff7b6" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/rev": [ - { - "@value": 1 - } - ], - "https://bluebrain.github.io/nexus/vocabulary/self": [ - { - "@id": "http://localhost/v1/projects/copies/sscx" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/updatedAt": [ - { - "@type": "http://www.w3.org/2001/XMLSchema#dateTime", - "@value": "2021-07-14T04:44:51.128Z" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/updatedBy": [ - { - "@id": "http://localhost/v1/realms/bbp/users/broman" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/uuid": [ - { - "@value": "534af0b6-4351-4f47-b100-1822bb66ee1f" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/vocab": [ - { - "@id": "http://localhost/v1/vocabs/copies/sscx/" - } - ] - } -] diff --git a/delta/plugins/search/src/test/resources/search-document-result.json b/delta/plugins/search/src/test/resources/search-document-result.json deleted file mode 100644 index e3826b7d57..0000000000 --- a/delta/plugins/search/src/test/resources/search-document-result.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "@context" : "https://bluebrain.github.io/nexus/contexts/search-document.json", - "@id" : "http://localhost/neurosciencegraph/data/traces/28c68330-1649-4702-b608-5cde6349a2d8", - "@type" : [ - "http://schema.org/Dataset", - "http://www.w3.org/ns/prov#Entity", - "https://neuroshapes.org/Trace", - "https://neuroshapes.org/SingleCellSimulationTrace" - ], - "name" : "S1HL_L6_LBC_cNAC_5", - "brainRegion" : { - "label" : "S1HL", - "identifier" : "http://uri.interlex.org/paxinos/uris/rat/labels/798" - }, - "contributors" : [ - { - "label" : "Anil Tuncel", - "identifier" : "http://localhost/nexus/v1/realms/bbp/users/tuncel" - } - ], - "createdBy" : "http://localhost/v1/realms/bbp/users/broman", - "description" : "This dataset is about simulated electrophysiology traces for cell instance S1HL_L6_LBC_cNAC_5. The dataset contains one distribution of the traces in RAB file format.", - "license" : { - "identifier" : "https://creativecommons.org/licenses/by/4.0/" - }, - "organizations" : [ - { - "label" : "École Polytechnique Fédérale de Lausanne", - "identifier" : "https://www.grid.ac/institutes/grid.5333.6" - } - ], - "project" : { - "label" : "copies/sscx", - "identifier" : "http://localhost/v1/projects/copies/sscx" - }, - "subjectSpecies" : { - "label" : "Rattus norvegicus", - "identifier" : "http://purl.obolibrary.org/obo/NCBITaxon_10116" - }, - "_self" : "http://localhost/v1/resources/copies/sscx/_/https:%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2Ftraces%2F28c68330-1649-4702-b608-5cde6349a2d8" -} diff --git a/delta/plugins/search/src/test/resources/trace.json b/delta/plugins/search/src/test/resources/trace.json deleted file mode 100644 index 8686a521ab..0000000000 --- a/delta/plugins/search/src/test/resources/trace.json +++ /dev/null @@ -1,319 +0,0 @@ -{ - "@id": "http://localhost/neurosciencegraph/data/traces/28c68330-1649-4702-b608-5cde6349a2d8", - "@type": [ - "http://schema.org/Dataset", - "https://neuroshapes.org/Trace", - "http://www.w3.org/ns/prov#Entity", - "https://neuroshapes.org/SingleCellSimulationTrace" - ], - "http://schema.org/dateCreated": [ - { - "@type": "http://www.w3.org/2001/XMLSchema#dateTime", - "@value": "2021-05-18T18:31:14.687696+02:00" - } - ], - "http://schema.org/description": [ - { - "@value": "This dataset is about simulated electrophysiology traces for cell instance S1HL_L6_LBC_cNAC_5. The dataset contains one distribution of the traces in RAB file format." - } - ], - "http://schema.org/distribution": [ - { - "@type": [ - "http://schema.org/DataDownload" - ], - "http://schema.org/contentSize": [ - { - "http://schema.org/unitCode": [ - { - "@value": "bytes" - } - ], - "http://schema.org/value": [ - { - "@value": 595176 - } - ] - } - ], - "http://schema.org/contentUrl": [ - { - "@id": "http://localhost/nexus/v1/files/public/sscx/476b625e-7146-4090-8fec-2cb028fcb5af" - } - ], - "http://schema.org/encodingFormat": [ - { - "@value": "application/rab" - } - ], - "http://schema.org/name": [ - { - "@value": "S1HL_L6_LBC_cNAC_5.rab" - } - ], - "http://www.w3.org/ns/prov#atLocation": [ - { - "@type": [ - "http://www.w3.org/ns/prov#Location" - ], - "https://neuroshapes.org/location": [ - { - "@value": "file:///gpfs/bbp.cscs.ch/data/project/proj109/nexus/public/sscx/b/e/5/e/8/8/f/2/S1HL_L6_LBC_cNAC_5.rab" - } - ], - "https://neuroshapes.org/store": [ - { - "@id": "http://localhost/neurosciencegraph/data/4820323e-bee0-48d2-824f-9d9d404dbbee" - } - ] - } - ], - "https://neuroshapes.org/digest": [ - { - "http://schema.org/algorithm": [ - { - "@value": "SHA-256" - } - ], - "http://schema.org/value": [ - { - "@value": "d9a1b8ec1f2afccfe80e26bcae30c81f1c6e2d93d7720c9071368d93b14599db" - } - ] - } - ] - } - ], - "http://schema.org/isPartOf": [ - { - "@id": "http://localhost/neurosciencegraph/data/traces/ceb6e006-1ae3-4d3e-8be6-010af894f99d", - "@type": [ - "https://neuroshapes.org/Trace" - ] - } - ], - "http://schema.org/name": [ - { - "@value": "S1HL_L6_LBC_cNAC_5" - } - ], - "http://www.w3.org/2004/02/skos/core#note": [ - { - "@value": "SSCX Simulation Data" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/constrainedBy": [ - { - "@id": "https://bluebrain.github.io/nexus/schemas/unconstrained.json" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/createdAt": [ - { - "@type": "http://www.w3.org/2001/XMLSchema#dateTime", - "@value": "2021-07-14T06:51:55.600Z" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/createdBy": [ - { - "@id": "http://localhost/v1/realms/bbp/users/broman" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/deprecated": [ - { - "@value": false - } - ], - "https://bluebrain.github.io/nexus/vocabulary/incoming": [ - { - "@id": "http://localhost/v1/resources/copies/sscx/_/https:%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2Ftraces%2F28c68330-1649-4702-b608-5cde6349a2d8/incoming" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/outgoing": [ - { - "@id": "http://localhost/v1/resources/copies/sscx/_/https:%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2Ftraces%2F28c68330-1649-4702-b608-5cde6349a2d8/outgoing" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/project": [ - { - "@id": "http://localhost/v1/projects/copies/sscx" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/rev": [ - { - "@value": 2 - } - ], - "https://bluebrain.github.io/nexus/vocabulary/schemaProject": [ - { - "@id": "http://localhost/v1/projects/copies/sscx" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/self": [ - { - "@id": "http://localhost/v1/resources/copies/sscx/_/https:%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2Ftraces%2F28c68330-1649-4702-b608-5cde6349a2d8" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/updatedAt": [ - { - "@type": "http://www.w3.org/2001/XMLSchema#dateTime", - "@value": "2021-07-14T12:06:58.661Z" - } - ], - "https://bluebrain.github.io/nexus/vocabulary/updatedBy": [ - { - "@id": "http://localhost/v1/realms/bbp/users/broman" - } - ], - "https://neuroshapes.org/annotation": [ - { - "@type": [ - "http://localhost/nexus/v1/resources/public/sscx/_/ETypeAnnotation", - "https://neuroshapes.org/Annotation" - ], - "http://schema.org/name": [ - { - "@value": "E-type annotation" - } - ], - "https://neuroshapes.org/hasBody": [ - { - "@id": "http://uri.interlex.org/base/ilx_0738201", - "@type": [ - "https://neuroshapes.org/EType", - "https://neuroshapes.org/AnnotationBody" - ], - "http://www.w3.org/2000/01/rdf-schema#label": [ - { - "@value": "cNAC" - } - ] - } - ] - }, - { - "@type": [ - "https://neuroshapes.org/Annotation", - "http://localhost/nexus/v1/resources/public/sscx/_/MTypeAnnotation" - ], - "http://schema.org/name": [ - { - "@value": "M-type annotation" - } - ], - "https://neuroshapes.org/hasBody": [ - { - "@id": "http://uri.interlex.org/base/ilx_0383233", - "@type": [ - "https://neuroshapes.org/AnnotationBody", - "https://neuroshapes.org/MType" - ], - "http://www.w3.org/2000/01/rdf-schema#label": [ - { - "@value": "L6_LBC" - } - ] - } - ] - } - ], - "https://neuroshapes.org/brainLocation": [ - { - "@type": [ - "https://neuroshapes.org/BrainLocation" - ], - "https://neuroshapes.org/brainRegion": [ - { - "@id": "http://uri.interlex.org/paxinos/uris/rat/labels/798", - "http://www.w3.org/2000/01/rdf-schema#label": [ - { - "@value": "S1HL" - } - ], - "http://www.w3.org/2004/02/skos/core#prefLabel": [ - { - "@value": "primary somatosensory cortex, hindlimb region" - } - ] - } - ], - "https://neuroshapes.org/layer": [ - { - "@id": "http://purl.obolibrary.org/obo/UBERON_0005395", - "http://www.w3.org/2000/01/rdf-schema#label": [ - { - "@value": "layer 6" - } - ] - } - ] - } - ], - "https://neuroshapes.org/contribution": [ - { - "@type": [ - "https://neuroshapes.org/Contribution" - ], - "http://www.w3.org/ns/prov#agent": [ - { - "@id": "https://www.grid.ac/institutes/grid.5333.6", - "@type": [ - "http://www.w3.org/ns/prov#Agent", - "http://schema.org/Organization" - ] - } - ] - }, - { - "@type": [ - "https://neuroshapes.org/Contribution" - ], - "http://www.w3.org/ns/prov#agent": [ - { - "@id": "http://localhost/nexus/v1/realms/bbp/users/tuncel", - "@type": [ - "http://www.w3.org/ns/prov#Agent", - "http://schema.org/Person" - ] - } - ] - } - ], - "https://neuroshapes.org/objectOfStudy": [ - { - "@id": "http://bbp.epfl.ch/neurosciencegraph/taxonomies/objectsofstudy/singlecells", - "@type": [ - "https://neuroshapes.org/ObjectOfStudy" - ], - "http://www.w3.org/2000/01/rdf-schema#label": [ - { - "@value": "Single Cell" - } - ] - } - ], - "https://neuroshapes.org/subject": [ - { - "@type": [ - "https://neuroshapes.org/Subject" - ], - "https://neuroshapes.org/species": [ - { - "@id": "http://purl.obolibrary.org/obo/NCBITaxon_10116", - "http://www.w3.org/2000/01/rdf-schema#label": [ - { - "@value": "Rattus norvegicus" - } - ] - } - ] - } - ], - "http://schema.org/license": [ - { - "@id": "https://creativecommons.org/licenses/by/4.0/", - "@type": [ - "https://neuroshapes.org/License" - ] - } - ] -} \ No newline at end of file diff --git a/delta/plugins/search/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/search/SearchSparqlQuerySpec.scala b/delta/plugins/search/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/search/SearchSparqlQuerySpec.scala deleted file mode 100644 index 53840eeb35..0000000000 --- a/delta/plugins/search/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/search/SearchSparqlQuerySpec.scala +++ /dev/null @@ -1,94 +0,0 @@ -package ch.epfl.bluebrain.nexus.delta.plugins.search - -import akka.actor.ActorSystem -import akka.testkit.TestKit -import cats.effect.IO -import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.Fixtures.defaultProperties -import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.client.BlazegraphClient -import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.client.SparqlQueryResponseType.SparqlNTriples -import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode -import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.contexts -import ch.epfl.bluebrain.nexus.delta.rdf.graph.{Graph, NTriples} -import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.ExpandedJsonLd -import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.{JsonLdApi, JsonLdJavaApi} -import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.{ContextValue, RemoteContextResolution} -import ch.epfl.bluebrain.nexus.delta.rdf.query.SparqlQuery.SparqlConstructQuery -import ch.epfl.bluebrain.nexus.delta.sdk.ConfigFixtures -import ch.epfl.bluebrain.nexus.delta.sdk.http.{HttpClient, HttpClientConfig} -import ch.epfl.bluebrain.nexus.delta.sdk.syntax._ -import ch.epfl.bluebrain.nexus.testkit.blazegraph.BlazegraphDocker -import ch.epfl.bluebrain.nexus.testkit.scalatest.EitherValues -import ch.epfl.bluebrain.nexus.testkit.scalatest.ce.{CatsEffectSpec, CatsIOValues} -import io.circe.Json -import org.scalatest.CancelAfterFailure -import org.scalatest.concurrent.Eventually - -import java.util.regex.Pattern.quote -import scala.concurrent.duration._ - -class SearchSparqlQuerySpec - extends TestKit(ActorSystem("SearchSparqlQuerySpec")) - with CatsEffectSpec - with ConfigFixtures - with EitherValues - with CancelAfterFailure - with Eventually - with CatsIOValues - with BlazegraphDocker { - - implicit override def patienceConfig: PatienceConfig = PatienceConfig(6.seconds, 10.milliseconds) - - private val searchDocument = contexts + "search-document.json" - - implicit private val httpCfg: HttpClientConfig = httpClientConfig - implicit private val api: JsonLdApi = JsonLdJavaApi.strict - implicit private val rcr: RemoteContextResolution = RemoteContextResolution.fixed( - searchDocument -> jsonContentOf("contexts/search-document.json").topContextValueOrEmpty - ) - - private lazy val endpoint = hostConfig.endpoint - private lazy val client = BlazegraphClient(HttpClient(), endpoint, None, 10.seconds, defaultProperties.accepted) - - private def toNTriples(json: Json): NTriples = { - for { - expanded <- ExpandedJsonLd(json) - graph <- IO.fromEither(expanded.toGraph) - ntriples <- IO.fromEither(graph.toNTriples) - } yield ntriples - }.accepted - - "A search SPARQL query" should { - val index = "myindex" - val ctx = ContextValue(searchDocument) - - val traceId = iri"http://localhost/neurosciencegraph/data/traces/28c68330-1649-4702-b608-5cde6349a2d8" - val trace = jsonContentOf("trace.json") - val personId = iri"http://localhost/nexus/v1/realms/bbp/users/tuncel" - val person = jsonContentOf("person.json") - val organizationId = iri"https://www.grid.ac/institutes/grid.5333.6" - val organization = jsonContentOf("organization.json") - val projectId = iri"http://localhost/v1/projects/copies/sscx" - val project = jsonContentOf("project.json") - - "index resources" in { - client.createNamespace(index).accepted - val toInsert: Seq[(IriOrBNode.Iri, Json)] = - List(traceId -> trace, personId -> person, organizationId -> organization, projectId -> project) - forAll(toInsert) { case (id, json) => - client.replace(index, id.toUri.rightValue, toNTriples(json)).accepted - } - } - - "return the expected results" in eventually { - val q = contentOf("construct-query.sparql").replaceAll(quote("{resource_id}"), traceId.rdfFormat) - val query = SparqlConstructQuery(q).rightValue - val compacted = for { - ntriples <- client.query(Set(index), query, SparqlNTriples) - graph <- IO.fromEither(Graph(ntriples.value.copy(rootNode = traceId))) - compacted <- graph.toCompactedJsonLd(ctx) - } yield compacted - compacted.accepted.json shouldEqual jsonContentOf("search-document-result.json") - } - } - -}