diff --git a/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/client/BlazegraphClientSpec.scala b/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/client/BlazegraphClientSpec.scala index 14fd67bf78..5f64269aa0 100644 --- a/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/client/BlazegraphClientSpec.scala +++ b/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/client/BlazegraphClientSpec.scala @@ -22,6 +22,7 @@ import ch.epfl.bluebrain.nexus.delta.sdk.model.ComponentDescription.ServiceDescr import ch.epfl.bluebrain.nexus.delta.sdk.model.Name import ch.epfl.bluebrain.nexus.delta.sdk.syntax._ import ch.epfl.bluebrain.nexus.testkit.blazegraph.BlazegraphDocker +import ch.epfl.bluebrain.nexus.testkit.ce.CatsIOValues import ch.epfl.bluebrain.nexus.testkit.{EitherValuable, IOValues, TestHelpers, TestMatchers} import io.circe.Json import monix.execution.Scheduler @@ -46,7 +47,8 @@ class BlazegraphClientSpec(docker: BlazegraphDocker) with Eventually with Inspectors with TestMatchers - with IOValues { + with IOValues + with CatsIOValues { implicit private val sc: Scheduler = Scheduler.global implicit private val httpCfg: HttpClientConfig = httpClientConfig diff --git a/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/CompositeSink.scala b/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/CompositeSink.scala index 911ec085e0..027242b678 100644 --- a/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/CompositeSink.scala +++ b/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/CompositeSink.scala @@ -13,6 +13,7 @@ import ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.model.CompositeViewP import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.client.ElasticSearchClient.Refresh import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.client.{ElasticSearchClient, IndexLabel} import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.indexing.{ElasticSearchSink, GraphResourceToDocument} +import ch.epfl.bluebrain.nexus.delta.rdf.RdfError import ch.epfl.bluebrain.nexus.delta.rdf.graph.Graph import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.{JsonLdApi, JsonLdJavaApi} import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.{ContextValue, RemoteContextResolution} @@ -24,6 +25,7 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.state.GraphResource import ch.epfl.bluebrain.nexus.delta.sourcing.stream.Elem import ch.epfl.bluebrain.nexus.delta.sourcing.stream.Elem.{DroppedElem, FailedElem, SuccessElem} import ch.epfl.bluebrain.nexus.delta.sourcing.stream.Operation.Sink +import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import fs2.Chunk import monix.bio.Task import shapeless.Typeable @@ -124,7 +126,7 @@ final class Batch[SinkFormat]( fullGraph .replaceRootNode(iri"${gr.id}/alias") .toCompactedJsonLd(ContextValue.empty) - .flatMap(_.toGraph) + .flatMap(_.toGraph.toBIO[RdfError]) .map(g => gr.copy(graph = g.replaceRootNode(gr.id))) } diff --git a/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/JsonLdDocumentSpec.scala b/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/JsonLdDocumentSpec.scala index 400fec5d4f..945a4a2dae 100644 --- a/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/JsonLdDocumentSpec.scala +++ b/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/JsonLdDocumentSpec.scala @@ -6,6 +6,7 @@ import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri 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.sdk.syntax._ +import ch.epfl.bluebrain.nexus.testkit.ce.CatsIOValues import ch.epfl.bluebrain.nexus.testkit.{CirceEq, IOValues, TestHelpers} import io.circe.syntax.EncoderOps import monix.bio.UIO @@ -18,6 +19,7 @@ class JsonLdDocumentSpec with Matchers with TestHelpers with IOValues + with CatsIOValues with OptionValues with ContextFixtures with CirceEq { 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 index 6b0252771e..5bf6ae2eb3 100644 --- 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 @@ -60,7 +60,7 @@ class SearchSparqlQuerySpec private def toNTriples(json: Json): NTriples = { for { - expanded <- toCatsIO(ExpandedJsonLd(json)) + expanded <- ExpandedJsonLd(json) graph <- IO.fromEither(expanded.toGraph) ntriples <- IO.fromEither(graph.toNTriples) } yield ntriples diff --git a/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/ExplainResult.scala b/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/ExplainResult.scala index ccf50adeaa..d09359d44b 100644 --- a/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/ExplainResult.scala +++ b/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/ExplainResult.scala @@ -1,8 +1,8 @@ package ch.epfl.bluebrain.nexus.delta.rdf +import cats.effect.IO import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.RemoteContext -import monix.bio.IO /** * Gives additional information besides the result of the Json-Ld operation @@ -18,6 +18,6 @@ final case class ExplainResult[A](remoteContexts: Map[Iri, RemoteContext], value def map[B](f: A => B): ExplainResult[B] = copy(value = f(value)) - def evalMap[E, B](f: A => IO[E, B]): IO[E, ExplainResult[B]] = + def evalMap[B](f: A => IO[B]): IO[ExplainResult[B]] = f(value).map { b => copy(value = b) } } diff --git a/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/graph/Graph.scala b/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/graph/Graph.scala index 1c5832744f..dbde998da9 100644 --- a/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/graph/Graph.scala +++ b/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/graph/Graph.scala @@ -230,10 +230,13 @@ final case class Graph private (rootNode: IriOrBNode, value: DatasetGraph) { sel opts: JsonLdOptions ): IO[RdfError, CompactedJsonLd] = { - def computeCompacted(id: IriOrBNode, input: Json) = { + def computeCompacted(id: IriOrBNode, input: Json): IO[RdfError, CompactedJsonLd] = { if (triples.isEmpty) UIO.delay(CompactedJsonLd.unsafe(id, contextValue, JsonObject.empty)) - else if (value.listGraphNodes().asScala.nonEmpty) CompactedJsonLd(id, contextValue, input) - else CompactedJsonLd.frame(id, contextValue, input) + else if (value.listGraphNodes().asScala.nonEmpty) { + CompactedJsonLd(id, contextValue, input).toBIO[RdfError] + } else { + CompactedJsonLd.frame(id, contextValue, input).toBIO[RdfError] + } } if (rootNode.isBNode) @@ -257,7 +260,7 @@ final case class Graph private (rootNode: IriOrBNode, value: DatasetGraph) { sel resolution: RemoteContextResolution, opts: JsonLdOptions ): IO[RdfError, ExpandedJsonLd] = - toCompactedJsonLd(ContextValue.empty).flatMap(_.toExpanded) + toCompactedJsonLd(ContextValue.empty).flatMap(_.toExpanded.toBIO[RdfError]) /** * Merges the current graph with the passed ''that'' while keeping the current ''rootNode'' diff --git a/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/jsonld/CompactedJsonLd.scala b/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/jsonld/CompactedJsonLd.scala index 980a948c32..adeefebe5b 100644 --- a/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/jsonld/CompactedJsonLd.scala +++ b/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/jsonld/CompactedJsonLd.scala @@ -1,16 +1,15 @@ package ch.epfl.bluebrain.nexus.delta.rdf.jsonld +import cats.effect.IO +import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.{BNode, Iri} import ch.epfl.bluebrain.nexus.delta.rdf.graph.Graph import ch.epfl.bluebrain.nexus.delta.rdf.implicits._ -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.{JsonLdApi, JsonLdOptions} import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.JsonLdContext.keywords import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context._ -import ch.epfl.bluebrain.nexus.delta.rdf.{IriOrBNode, RdfError} import io.circe.syntax._ -import io.circe.{Decoder, DecodingFailure, Encoder, Json, JsonObject} -import monix.bio.IO +import io.circe._ /** * Json-LD Compacted Document. CompactedJsonLd specific implementation is entity centric, having always only one root @@ -29,7 +28,7 @@ final case class CompactedJsonLd private (rootId: IriOrBNode, ctx: ContextValue, opts: JsonLdOptions, api: JsonLdApi, resolution: RemoteContextResolution - ): IO[RdfError, ExpandedJsonLd] = + ): IO[ExpandedJsonLd] = ExpandedJsonLd(json).map(_.replaceId(rootId)) /** @@ -39,7 +38,7 @@ final case class CompactedJsonLd private (rootId: IriOrBNode, ctx: ContextValue, opts: JsonLdOptions, api: JsonLdApi, resolution: RemoteContextResolution - ): IO[RdfError, Graph] = + ): IO[Graph] = toExpanded.flatMap(expanded => IO.fromEither(expanded.toGraph)) /** @@ -95,13 +94,12 @@ object CompactedJsonLd { rootId: IriOrBNode, contextValue: ContextValue, input: Json - )(implicit api: JsonLdApi, rcr: RemoteContextResolution, opts: JsonLdOptions): IO[RdfError, CompactedJsonLd] = + )(implicit api: JsonLdApi, rcr: RemoteContextResolution, opts: JsonLdOptions): IO[CompactedJsonLd] = api .compact(input, contextValue) .map { compacted => CompactedJsonLd(rootId, contextValue, compacted.remove(keywords.context)) } - .toBIO[RdfError] /** * Creates a [[CompactedJsonLd]] document framed on the passed ''rootId''. @@ -117,7 +115,7 @@ object CompactedJsonLd { rootId: IriOrBNode, contextValue: ContextValue, input: Json - )(implicit api: JsonLdApi, rcr: RemoteContextResolution, opts: JsonLdOptions): IO[RdfError, CompactedJsonLd] = + )(implicit api: JsonLdApi, rcr: RemoteContextResolution, opts: JsonLdOptions): IO[CompactedJsonLd] = rootId.asIri.map(iri => contextValue.contextObj deepMerge JsonObject(keywords.id -> iri.asJson)) match { case Some(frame) => api @@ -125,7 +123,6 @@ object CompactedJsonLd { .map { compacted => CompactedJsonLd(rootId, contextValue, compacted.remove(keywords.context)) } - .toBIO[RdfError] case _ => apply(rootId, contextValue, input) } diff --git a/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/jsonld/ExpandedJsonLd.scala b/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/jsonld/ExpandedJsonLd.scala index 89e90181aa..a06b7f9677 100644 --- a/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/jsonld/ExpandedJsonLd.scala +++ b/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/jsonld/ExpandedJsonLd.scala @@ -1,5 +1,6 @@ package ch.epfl.bluebrain.nexus.delta.rdf.jsonld +import cats.effect.IO import cats.implicits._ import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.{BNode, Iri} import ch.epfl.bluebrain.nexus.delta.rdf.RdfError.{InvalidIri, UnexpectedJsonLd} @@ -15,7 +16,6 @@ import ch.epfl.bluebrain.nexus.delta.rdf.{ExplainResult, IriOrBNode, RdfError} import ch.epfl.bluebrain.nexus.delta.rdf.syntax._ import io.circe.syntax._ import io.circe.{Decoder, Encoder, Json, JsonObject} -import monix.bio.{IO, UIO} import java.util.UUID @@ -42,7 +42,7 @@ final case class ExpandedJsonLd private (rootId: IriOrBNode, obj: JsonObject) ex opts: JsonLdOptions, api: JsonLdApi, resolution: RemoteContextResolution - ): IO[RdfError, CompactedJsonLd] = + ): IO[CompactedJsonLd] = CompactedJsonLd(rootId, contextValue, json) /** @@ -185,14 +185,14 @@ object ExpandedJsonLd { api: JsonLdApi, resolution: RemoteContextResolution, opts: JsonLdOptions - ): IO[RdfError, ExpandedJsonLd] = + ): IO[ExpandedJsonLd] = explain(input).map(_.value) def explain(input: Json)(implicit api: JsonLdApi, resolution: RemoteContextResolution, opts: JsonLdOptions - ): IO[RdfError, ExplainResult[ExpandedJsonLd]] = + ): IO[ExplainResult[ExpandedJsonLd]] = api .explainExpand(input) .flatMap { @@ -244,9 +244,8 @@ object ExpandedJsonLd { api .expand(Json.obj(keywords.id -> graphId.asJson, keywords.graph -> expandedSeq.asJson)) .map(_ -> true) - .toBIO[RdfError] else - UIO.pure((expandedSeq, false)) + IO.pure((expandedSeq, false)) result <- IO.fromEither(expanded(expandedSeqFinal)) } yield (result, isGraph) diff --git a/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/jsonld/encoder/JsonLdEncoder.scala b/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/jsonld/encoder/JsonLdEncoder.scala index f310ec0487..cbcc6b7253 100644 --- a/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/jsonld/encoder/JsonLdEncoder.scala +++ b/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/jsonld/encoder/JsonLdEncoder.scala @@ -10,6 +10,7 @@ import ch.epfl.bluebrain.nexus.delta.rdf.{IriOrBNode, RdfError} import io.circe.{Encoder, Json} import io.circe.syntax._ import monix.bio.IO +import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ trait JsonLdEncoder[A] { @@ -138,7 +139,7 @@ object JsonLdEncoder { )(implicit opts: JsonLdOptions, api: JsonLdApi, rcr: RemoteContextResolution): IO[RdfError, CompactedJsonLd] = for { (expanded, context) <- expandAndExtractContext(value) - compacted <- expanded.toCompacted(context) + compacted <- expanded.toCompacted(context).toBIO[RdfError] } yield compacted override def expand( @@ -152,6 +153,7 @@ object JsonLdEncoder { val json = value.asJson val context = contextFromJson(json) ExpandedJsonLd(json.replaceContext(context.contextObj)) + .toBIO[RdfError] .map { case expanded if fId(value).isBNode && expanded.rootId.isIri => expanded case expanded => expanded.replaceId(fId(value)) diff --git a/delta/rdf/src/test/scala/ch/epfl/bluebrain/nexus/delta/rdf/shacl/ShaclEngineSpec.scala b/delta/rdf/src/test/scala/ch/epfl/bluebrain/nexus/delta/rdf/shacl/ShaclEngineSpec.scala index 3fcabe9cbf..b834ca4402 100644 --- a/delta/rdf/src/test/scala/ch/epfl/bluebrain/nexus/delta/rdf/shacl/ShaclEngineSpec.scala +++ b/delta/rdf/src/test/scala/ch/epfl/bluebrain/nexus/delta/rdf/shacl/ShaclEngineSpec.scala @@ -7,6 +7,7 @@ import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.{JsonLdApi, JsonLdJavaApi} import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.JsonLdContext.keywords import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.RemoteContextResolution import ch.epfl.bluebrain.nexus.delta.rdf.syntax._ +import ch.epfl.bluebrain.nexus.testkit.ce.CatsIOValues import ch.epfl.bluebrain.nexus.testkit.{EitherValuable, IOValues, TestHelpers} import org.scalatest.Inspectors import org.scalatest.matchers.should.Matchers @@ -17,6 +18,7 @@ class ShaclEngineSpec with Matchers with TestHelpers with IOValues + with CatsIOValues with EitherValuable with Inspectors { diff --git a/delta/rdf/src/test/scala/ch/epfl/bluebrain/nexus/delta/rdf/shacl/ValidationReportSpec.scala b/delta/rdf/src/test/scala/ch/epfl/bluebrain/nexus/delta/rdf/shacl/ValidationReportSpec.scala index 096e9c54fa..9b5b459be6 100644 --- a/delta/rdf/src/test/scala/ch/epfl/bluebrain/nexus/delta/rdf/shacl/ValidationReportSpec.scala +++ b/delta/rdf/src/test/scala/ch/epfl/bluebrain/nexus/delta/rdf/shacl/ValidationReportSpec.scala @@ -6,6 +6,7 @@ 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.RemoteContextResolution import ch.epfl.bluebrain.nexus.delta.rdf.syntax._ +import ch.epfl.bluebrain.nexus.testkit.ce.CatsIOValues import ch.epfl.bluebrain.nexus.testkit.{EitherValuable, IOValues, TestHelpers} import io.circe.Json import io.circe.syntax._ @@ -21,6 +22,7 @@ class ValidationReportSpec with TestHelpers with EitherValuable with OptionValues + with CatsIOValues with IOValues { implicit val api: JsonLdApi = JsonLdJavaApi.strict diff --git a/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/jsonld/JsonLdSourceProcessor.scala b/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/jsonld/JsonLdSourceProcessor.scala index d7fbd366d2..ea661fad62 100644 --- a/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/jsonld/JsonLdSourceProcessor.scala +++ b/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/jsonld/JsonLdSourceProcessor.scala @@ -2,7 +2,7 @@ package ch.epfl.bluebrain.nexus.delta.sdk.jsonld import ch.epfl.bluebrain.nexus.delta.kernel.Mapper import ch.epfl.bluebrain.nexus.delta.kernel.utils.UUIDF -import ch.epfl.bluebrain.nexus.delta.rdf.ExplainResult +import ch.epfl.bluebrain.nexus.delta.rdf.{ExplainResult, RdfError} import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.{BNode, Iri} import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.{JsonLdApi, JsonLdOptions} import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.ContextValue.ContextObject @@ -17,6 +17,7 @@ import ch.epfl.bluebrain.nexus.delta.sdk.projects.model.ProjectContext import ch.epfl.bluebrain.nexus.delta.sdk.resolvers.ResolverContextResolution import ch.epfl.bluebrain.nexus.delta.sdk.syntax._ import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef +import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import io.circe.syntax._ import io.circe.{Json, JsonObject} import monix.bio.{IO, UIO} @@ -38,10 +39,11 @@ sealed abstract class JsonLdSourceProcessor(implicit api: JsonLdApi) { implicit val opts: JsonLdOptions = JsonLdOptions(base = Some(context.base.iri)) ExpandedJsonLd .explain(source) + .toBIO[RdfError] .flatMap { case result if result.value.isEmpty && source.topContextValueOrEmpty.isEmpty => val ctx = defaultCtx(context) - ExpandedJsonLd.explain(source.addContext(ctx.contextObj)).map(ctx -> _) + ExpandedJsonLd.explain(source.addContext(ctx.contextObj)).map(ctx -> _).toBIO[RdfError] case result => UIO.pure(source.topContextValueOrEmpty -> result) } @@ -119,7 +121,7 @@ object JsonLdSourceProcessor { originalExpanded = result.value iri <- getOrGenerateId(originalExpanded.rootId.asIri, context) expanded = originalExpanded.replaceId(iri) - compacted <- expanded.toCompacted(ctx).mapError(err => InvalidJsonLdFormat(Some(iri), err)) + compacted <- expanded.toCompacted(ctx).toBIO[RdfError].mapError(err => InvalidJsonLdFormat(Some(iri), err)) } yield JsonLdResult(iri, compacted, expanded, result.remoteContexts) }.mapError(rejectionMapper.to) @@ -146,7 +148,7 @@ object JsonLdSourceProcessor { (ctx, result) <- expandSource(context, source.addContext(contextIri: _*)) originalExpanded = result.value expanded <- checkAndSetSameId(iri, originalExpanded) - compacted <- expanded.toCompacted(ctx).mapError(err => InvalidJsonLdFormat(Some(iri), err)) + compacted <- expanded.toCompacted(ctx).toBIO[RdfError].mapError(err => InvalidJsonLdFormat(Some(iri), err)) } yield JsonLdResult(iri, compacted, expanded, result.remoteContexts) }.mapError(rejectionMapper.to) diff --git a/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/generators/ResourceGen.scala b/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/generators/ResourceGen.scala index 3fcbb34e07..28e776632f 100644 --- a/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/generators/ResourceGen.scala +++ b/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/generators/ResourceGen.scala @@ -1,7 +1,6 @@ package ch.epfl.bluebrain.nexus.delta.sdk.generators import cats.effect.IO -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.schemas import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.ExpandedJsonLd @@ -17,12 +16,12 @@ import ch.epfl.bluebrain.nexus.delta.sdk.syntax._ import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.{Anonymous, Subject} import ch.epfl.bluebrain.nexus.delta.sourcing.model.ResourceRef.Latest import ch.epfl.bluebrain.nexus.delta.sourcing.model.{ProjectRef, ResourceRef} -import ch.epfl.bluebrain.nexus.testkit.IOValues +import ch.epfl.bluebrain.nexus.testkit.ce.CatsIOValues import io.circe.Json import java.time.Instant -object ResourceGen extends IOValues { +object ResourceGen extends CatsIOValues { // We put a lenient api for schemas otherwise the api checks data types before the actual schema validation process implicit val api: JsonLdApi = JsonLdJavaApi.strict @@ -77,8 +76,8 @@ object ResourceGen extends IOValues { tags: Tags = Tags.empty )(implicit resolution: RemoteContextResolution): IO[Resource] = { for { - expanded <- ExpandedJsonLd(source).toCatsIO.map(_.replaceId(id)) - compacted <- expanded.toCompacted(source.topContextValueOrEmpty).toCatsIO + expanded <- ExpandedJsonLd(source).map(_.replaceId(id)) + compacted <- expanded.toCompacted(source.topContextValueOrEmpty) } yield { Resource(id, project, tags, schema, source, compacted, expanded) } diff --git a/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/generators/SchemaGen.scala b/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/generators/SchemaGen.scala index d5224ed437..7d5fb707c4 100644 --- a/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/generators/SchemaGen.scala +++ b/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/generators/SchemaGen.scala @@ -2,7 +2,6 @@ package ch.epfl.bluebrain.nexus.delta.sdk.generators import cats.data.NonEmptyList import cats.effect.IO -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.ExpandedJsonLd import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.{JsonLdApi, JsonLdJavaApi} @@ -61,8 +60,8 @@ object SchemaGen extends CatsIOValues with EitherValuable { tags: Tags = Tags.empty )(implicit resolution: RemoteContextResolution): IO[Schema] = { for { - expanded <- ExpandedJsonLd(source).toCatsIO.map(_.replaceId(id)) - compacted <- expanded.toCompacted(source.topContextValueOrEmpty).toCatsIO + expanded <- ExpandedJsonLd(source).map(_.replaceId(id)) + compacted <- expanded.toCompacted(source.topContextValueOrEmpty) } yield { Schema(id, project, tags, source, compacted, NonEmptyList.of(expanded)) } diff --git a/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/resolvers/model/ResolverValueSpec.scala b/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/resolvers/model/ResolverValueSpec.scala index 0ea1425da4..94b88db58b 100644 --- a/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/resolvers/model/ResolverValueSpec.scala +++ b/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/resolvers/model/ResolverValueSpec.scala @@ -9,7 +9,8 @@ import ch.epfl.bluebrain.nexus.delta.sdk.resolvers.model.ResolverValue.{CrossPro import ch.epfl.bluebrain.nexus.delta.sdk.utils.Fixtures import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.{Authenticated, Group, User} import ch.epfl.bluebrain.nexus.delta.sourcing.model.{Label, ProjectRef} -import ch.epfl.bluebrain.nexus.testkit.{EitherValuable, IOValues, TestHelpers} +import ch.epfl.bluebrain.nexus.testkit.ce.CatsIOValues +import ch.epfl.bluebrain.nexus.testkit.{EitherValuable, TestHelpers} import org.scalatest.Inspectors import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpecLike @@ -18,7 +19,7 @@ class ResolverValueSpec extends AnyWordSpecLike with Matchers with EitherValuable - with IOValues + with CatsIOValues with Inspectors with TestHelpers with Fixtures { diff --git a/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/resources/ResourcesTrialSuite.scala b/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/resources/ResourcesTrialSuite.scala index 50031da3fe..ff3f161b11 100644 --- a/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/resources/ResourcesTrialSuite.scala +++ b/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/resources/ResourcesTrialSuite.scala @@ -1,6 +1,7 @@ package ch.epfl.bluebrain.nexus.delta.sdk.resources import cats.effect.IO +import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.kernel.utils.UUIDF import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.{contexts, nxv, schema} import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.{JsonLdApi, JsonLdJavaApi} @@ -18,12 +19,12 @@ import ch.epfl.bluebrain.nexus.delta.sdk.resources.model.{Resource, ResourceGene import ch.epfl.bluebrain.nexus.delta.sdk.syntax._ import ch.epfl.bluebrain.nexus.delta.sourcing.model.ResourceRef.Revision import ch.epfl.bluebrain.nexus.testkit.TestHelpers -import ch.epfl.bluebrain.nexus.testkit.ce.{CatsEffectSuite, IOFixedClock} +import ch.epfl.bluebrain.nexus.testkit.ce.CatsEffectSuite import munit.Location import java.util.UUID -class ResourcesTrialSuite extends CatsEffectSuite with ValidateResourceFixture with TestHelpers with IOFixedClock { +class ResourcesTrialSuite extends CatsEffectSuite with ValidateResourceFixture with TestHelpers { private val uuid = UUID.randomUUID() implicit private val uuidF: UUIDF = UUIDF.fixed(uuid) @@ -131,7 +132,7 @@ class ResourcesTrialSuite extends CatsEffectSuite with ValidateResourceFixture w .resourceAsync(id, projectRef, source.value, Revision(resourceSchema, 1)) .map(ResourceGen.resourceFor(_)) trial = ResourcesTrial( - (_, _) => IO.pure(resource), + (_, _) => IO.pure(resource).toUIO, alwaysValidate, fetchContext, resolverContextResolution @@ -148,7 +149,7 @@ class ResourcesTrialSuite extends CatsEffectSuite with ValidateResourceFixture w .resourceAsync(id, projectRef, source.value, Revision(resourceSchema, 1)) .map(ResourceGen.resourceFor(_)) trial = ResourcesTrial( - (_, _) => IO.pure(resource), + (_, _) => IO.pure(resource).toUIO, alwaysValidate, fetchContext, resolverContextResolution @@ -168,7 +169,7 @@ class ResourcesTrialSuite extends CatsEffectSuite with ValidateResourceFixture w expectedError = InvalidResource(id, Revision(anotherSchema, defaultSchemaRevision), defaultReport, resource.value.expanded) trial = ResourcesTrial( - (_, _) => IO.pure(resource), + (_, _) => IO.pure(resource).toUIO, alwaysFail(expectedError), fetchContext, resolverContextResolution diff --git a/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/schemas/SchemaImportsSuite.scala b/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/schemas/SchemaImportsSuite.scala index 674f1d36d5..ee7fd3d01f 100644 --- a/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/schemas/SchemaImportsSuite.scala +++ b/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/schemas/SchemaImportsSuite.scala @@ -2,7 +2,6 @@ package ch.epfl.bluebrain.nexus.delta.sdk.schemas import cats.data.NonEmptyList import cats.effect.IO -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.ExpandedJsonLd import ch.epfl.bluebrain.nexus.delta.sdk.Resolve import ch.epfl.bluebrain.nexus.delta.sdk.generators.ResourceGen @@ -74,7 +73,7 @@ class SchemaImportsSuite extends CatsEffectSuite with TestHelpers with CirceLite case (_, _, _) => IO.pure(Left(errorReport)) } - private def toExpanded(json: Json) = toCatsIO(ExpandedJsonLd(json)) + private def toExpanded(json: Json) = ExpandedJsonLd(json) val imports = new SchemaImports(fetchSchema, fetchResource) diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/ce/CatsEffectSuite.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/ce/CatsEffectSuite.scala index 70402a7bb5..6522803699 100644 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/ce/CatsEffectSuite.scala +++ b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/ce/CatsEffectSuite.scala @@ -17,6 +17,7 @@ abstract class CatsEffectSuite with CatsRunContext with CatsEffectAssertions with CatsStreamAssertions + with CatsIOValues with CollectionAssertions with EitherAssertions { protected val ioTimeout: FiniteDuration = 45.seconds