From 66b6b0c028fc503b9f810f5da452d394217433f6 Mon Sep 17 00:00:00 2001 From: Daniel Bell Date: Thu, 9 Nov 2023 15:44:14 +0100 Subject: [PATCH 01/18] Remove Clock[BIO] --- .../epfl/bluebrain/nexus/delta/wiring/DeltaModule.scala | 2 -- .../epfl/bluebrain/nexus/delta/kernel/utils/IOUtils.scala | 7 ------- .../epfl/bluebrain/nexus/testkit/bio/IOFixedClock.scala | 8 -------- 3 files changed, 17 deletions(-) diff --git a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/DeltaModule.scala b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/DeltaModule.scala index 4b115e1b22..0eb9983293 100644 --- a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/DeltaModule.scala +++ b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/DeltaModule.scala @@ -33,7 +33,6 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.config.{DatabaseConfig, Projection import ch.megard.akka.http.cors.scaladsl.settings.CorsSettings import com.typesafe.config.Config import izumi.distage.model.definition.{Id, ModuleDef} -import monix.bio.UIO import org.slf4j.{Logger, LoggerFactory} import scala.concurrent.duration.DurationInt @@ -106,7 +105,6 @@ class DeltaModule(appCfg: AppConfig, config: Config)(implicit classLoader: Class new JsonLdJavaApi(appCfg.jsonLdApi)(contextShift) } - make[Clock[UIO]].from(Clock[UIO]) make[Clock[IO]].from(Clock.create[IO]) make[UUIDF].from(UUIDF.random) make[JsonKeyOrdering].from( diff --git a/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/utils/IOUtils.scala b/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/utils/IOUtils.scala index fc4773d316..f6c702fcc5 100644 --- a/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/utils/IOUtils.scala +++ b/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/utils/IOUtils.scala @@ -2,7 +2,6 @@ package ch.epfl.bluebrain.nexus.delta.kernel.utils import cats.effect.concurrent.Ref import cats.effect.{Clock, IO} -import monix.bio.UIO import java.time.Instant import java.util.UUID @@ -11,12 +10,6 @@ import scala.concurrent.duration.{DurationLong, FiniteDuration, MILLISECONDS} trait IOUtils { - /** - * Creates an Instant deferring its evaluation to the to ''clock'' scheduler - */ - def instant(implicit clock: Clock[UIO]): UIO[Instant] = - clock.realTime(TimeUnit.MILLISECONDS).map(Instant.ofEpochMilli) - implicit class IoOps[A](val io: IO[A]) { def timed(implicit clock: Clock[IO]): IO[(FiniteDuration, A)] = { for { diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/bio/IOFixedClock.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/bio/IOFixedClock.scala index 1c06e195fd..4489b24052 100644 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/bio/IOFixedClock.scala +++ b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/bio/IOFixedClock.scala @@ -1,22 +1,14 @@ package ch.epfl.bluebrain.nexus.testkit.bio import cats.effect.{Clock, IO} -import monix.bio.UIO import java.time.Instant import scala.concurrent.duration.TimeUnit trait IOFixedClock { - def bioClock(instant: Instant): Clock[UIO] = new Clock[UIO] { - override def realTime(unit: TimeUnit): UIO[Long] = UIO.pure(instant.toEpochMilli) - override def monotonic(unit: TimeUnit): UIO[Long] = UIO.pure(instant.toEpochMilli) - } - private val realClock: Clock[IO] = Clock.create - implicit def bioClock: Clock[UIO] = bioClock(Instant.EPOCH) - def ceClock(instant: Instant): Clock[IO] = new Clock[IO] { override def realTime(unit: TimeUnit): IO[Long] = IO.pure(instant.toEpochMilli) override def monotonic(unit: TimeUnit): IO[Long] = realClock.monotonic(unit) From e4efdb2a067d90f88a1f2d042f4fafd380473e7f Mon Sep 17 00:00:00 2001 From: Daniel Bell Date: Thu, 9 Nov 2023 15:45:44 +0100 Subject: [PATCH 02/18] Tidy up clock test classes --- .../routes/BlazegraphViewRoutesFixtures.scala | 4 ++-- .../routes/CompositeViewsRoutesFixtures.scala | 4 ++-- .../graph/analytics/GraphAnalyticsSpec.scala | 4 ++-- .../ShouldDeleteProjectSuite.scala | 2 +- .../files/routes/FilesRoutesSpec.scala | 2 +- .../postgres/DoobieScalaTestFixture.scala | 4 ++-- .../projections/FailedElemLogStoreSuite.scala | 6 +++--- .../state/EphemeralStateStoreSuite.scala | 4 ++-- .../stream/ProjectionStoreSuite.scala | 3 ++- .../sourcing/stream/SupervisorSetup.scala | 4 ++-- .../nexus/testkit/bio/IOFixedClock.scala | 20 ------------------ .../nexus/testkit/clock/FixedClock.scala | 21 +++++++++++++++++++ .../testkit/{ => clock}/MutableClock.scala | 4 ++-- .../nexus/testkit/mu/bio/BioSuite.scala | 5 +++-- .../nexus/testkit/mu/ce/CatsEffectSuite.scala | 4 ++-- .../nexus/testkit/scalatest/bio/BioSpec.scala | 4 ++-- .../testkit/scalatest/ce/CatsEffectSpec.scala | 4 ++-- .../nexus/tests/BaseIntegrationSpec.scala | 4 ++-- 18 files changed, 53 insertions(+), 50 deletions(-) delete mode 100644 delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/bio/IOFixedClock.scala create mode 100644 delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/clock/FixedClock.scala rename delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/{ => clock}/MutableClock.scala (86%) diff --git a/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/routes/BlazegraphViewRoutesFixtures.scala b/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/routes/BlazegraphViewRoutesFixtures.scala index 7fb9d74130..7d29de4e53 100644 --- a/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/routes/BlazegraphViewRoutesFixtures.scala +++ b/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/routes/BlazegraphViewRoutesFixtures.scala @@ -26,8 +26,8 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.model.Label import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.{Authenticated, Group, User} import ch.epfl.bluebrain.nexus.delta.sourcing.postgres.DoobieScalaTestFixture -import ch.epfl.bluebrain.nexus.testkit.bio.IOFixedClock import ch.epfl.bluebrain.nexus.testkit.ce.CatsRunContext +import ch.epfl.bluebrain.nexus.testkit.clock.FixedClock import ch.epfl.bluebrain.nexus.testkit.scalatest.bio.BIOValues import ch.epfl.bluebrain.nexus.testkit.scalatest.ce.CatsIOValues import ch.epfl.bluebrain.nexus.testkit.scalatest.{EitherValues, TestMatchers} @@ -45,7 +45,7 @@ trait BlazegraphViewRoutesFixtures with CatsIOValues with CirceLiteral with CirceEq - with IOFixedClock + with FixedClock with CatsRunContext with BIOValues with OptionValues diff --git a/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/routes/CompositeViewsRoutesFixtures.scala b/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/routes/CompositeViewsRoutesFixtures.scala index 0ac9234ab0..3dd76adfb7 100644 --- a/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/routes/CompositeViewsRoutesFixtures.scala +++ b/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/routes/CompositeViewsRoutesFixtures.scala @@ -14,8 +14,8 @@ import ch.epfl.bluebrain.nexus.delta.sdk.utils.RouteHelpers import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.{Authenticated, Group, User} import ch.epfl.bluebrain.nexus.delta.sourcing.model.Label import ch.epfl.bluebrain.nexus.delta.sourcing.postgres.DoobieScalaTestFixture -import ch.epfl.bluebrain.nexus.testkit.bio.IOFixedClock import ch.epfl.bluebrain.nexus.testkit.ce.CatsRunContext +import ch.epfl.bluebrain.nexus.testkit.clock.FixedClock import ch.epfl.bluebrain.nexus.testkit.scalatest.TestMatchers import ch.epfl.bluebrain.nexus.testkit.scalatest.ce.CatsIOValues import ch.epfl.bluebrain.nexus.testkit.{CirceEq, CirceLiteral} @@ -29,7 +29,7 @@ trait CompositeViewsRoutesFixtures with CatsIOValues with CirceLiteral with CirceEq - with IOFixedClock + with FixedClock with CatsRunContext with OptionValues with TestMatchers diff --git a/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/GraphAnalyticsSpec.scala b/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/GraphAnalyticsSpec.scala index 59ccfe9b21..211732b242 100644 --- a/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/GraphAnalyticsSpec.scala +++ b/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/GraphAnalyticsSpec.scala @@ -16,7 +16,7 @@ import ch.epfl.bluebrain.nexus.delta.sdk.generators.ProjectGen import ch.epfl.bluebrain.nexus.delta.sdk.http.{HttpClient, HttpClientConfig, HttpClientWorthRetry} import ch.epfl.bluebrain.nexus.delta.sdk.projects.FetchContextDummy import ch.epfl.bluebrain.nexus.delta.sdk.syntax._ -import ch.epfl.bluebrain.nexus.testkit.bio.IOFixedClock +import ch.epfl.bluebrain.nexus.testkit.clock.FixedClock import ch.epfl.bluebrain.nexus.testkit.elasticsearch.ElasticSearchContainer._ import ch.epfl.bluebrain.nexus.testkit.elasticsearch.ElasticSearchDocker import ch.epfl.bluebrain.nexus.testkit.scalatest.ce.CatsEffectSpec @@ -32,7 +32,7 @@ import scala.concurrent.duration._ class GraphAnalyticsSpec(docker: ElasticSearchDocker) extends TestKit(ActorSystem("GraphAnalyticsSpec")) with CatsEffectSpec - with IOFixedClock + with FixedClock with ConfigFixtures with Eventually with Fixtures { diff --git a/delta/plugins/project-deletion/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/projectdeletion/ShouldDeleteProjectSuite.scala b/delta/plugins/project-deletion/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/projectdeletion/ShouldDeleteProjectSuite.scala index 323df2d563..ed0998af95 100644 --- a/delta/plugins/project-deletion/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/projectdeletion/ShouldDeleteProjectSuite.scala +++ b/delta/plugins/project-deletion/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/projectdeletion/ShouldDeleteProjectSuite.scala @@ -186,7 +186,7 @@ object ShouldDeleteProjectSuite extends Assertions with CatsRunContext with Cats val TwoDaysAgo = Instant.now().minus(Duration.ofDays(2)) val ThreeHoursAgo = Instant.now().minus(Duration.ofHours(3)) - implicit val clock: Clock[IO] = Clock.create + implicit val realClock: Clock[IO] = Clock.create def shouldBeDeleted( config: ProjectDeletionConfig, diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/files/routes/FilesRoutesSpec.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/files/routes/FilesRoutesSpec.scala index 07de82bc5e..1c71cd279c 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/files/routes/FilesRoutesSpec.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/files/routes/FilesRoutesSpec.scala @@ -133,7 +133,7 @@ class FilesRoutesSpec config, FilesConfig(eventLogConfig, MediaTypeDetectorConfig.Empty), remoteDiskStorageClient - )(ceClock, uuidF, timer, contextShift, typedSystem) + )(clock, uuidF, timer, contextShift, typedSystem) private val groupDirectives = DeltaSchemeDirectives(fetchContext, ioFromMap(uuid -> projectRef.organization), ioFromMap(uuid -> projectRef)) diff --git a/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/postgres/DoobieScalaTestFixture.scala b/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/postgres/DoobieScalaTestFixture.scala index de0690f22e..bf25ac4079 100644 --- a/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/postgres/DoobieScalaTestFixture.scala +++ b/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/postgres/DoobieScalaTestFixture.scala @@ -4,8 +4,8 @@ import cats.effect.IO import cats.implicits.toFlatMapOps import ch.epfl.bluebrain.nexus.delta.sourcing.Transactors import ch.epfl.bluebrain.nexus.testkit.TestHelpers -import ch.epfl.bluebrain.nexus.testkit.bio.IOFixedClock import ch.epfl.bluebrain.nexus.testkit.ce.CatsRunContext +import ch.epfl.bluebrain.nexus.testkit.clock.FixedClock import ch.epfl.bluebrain.nexus.testkit.scalatest.ce.CatsIOValues import org.scalatest.{BeforeAndAfterAll, Suite} @@ -14,7 +14,7 @@ trait DoobieScalaTestFixture with PostgresDocker with TestHelpers with CatsIOValues - with IOFixedClock { + with FixedClock { self: Suite with CatsRunContext => diff --git a/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/projections/FailedElemLogStoreSuite.scala b/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/projections/FailedElemLogStoreSuite.scala index 9d64d0d739..44f808e592 100644 --- a/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/projections/FailedElemLogStoreSuite.scala +++ b/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/projections/FailedElemLogStoreSuite.scala @@ -13,7 +13,7 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.postgres.Doobie import ch.epfl.bluebrain.nexus.delta.sourcing.query.RefreshStrategy import ch.epfl.bluebrain.nexus.delta.sourcing.stream.Elem.FailedElem import ch.epfl.bluebrain.nexus.delta.sourcing.stream.ProjectionMetadata -import ch.epfl.bluebrain.nexus.testkit.MutableClock +import ch.epfl.bluebrain.nexus.testkit.clock.MutableClock import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite import munit.{AnyFixture, Location} @@ -26,11 +26,11 @@ class FailedElemLogStoreSuite with Doobie.Fixture with Doobie.Assertions { - override def munitFixtures: Seq[AnyFixture[_]] = List(doobie, clock) + override def munitFixtures: Seq[AnyFixture[_]] = List(doobie, mutableClockFixture) private lazy val xas = doobie() - implicit private lazy val mutableClock: MutableClock = clock() + implicit private lazy val mutableClock: MutableClock = mutableClockFixture() private lazy val store = FailedElemLogStore(xas, QueryConfig(10, RefreshStrategy.Stop)) diff --git a/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/state/EphemeralStateStoreSuite.scala b/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/state/EphemeralStateStoreSuite.scala index 836e8fa920..28f9227ef9 100644 --- a/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/state/EphemeralStateStoreSuite.scala +++ b/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/state/EphemeralStateStoreSuite.scala @@ -7,7 +7,7 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.{Anonymous, User} import ch.epfl.bluebrain.nexus.delta.sourcing.model.{Label, ProjectRef} import ch.epfl.bluebrain.nexus.delta.sourcing.postgres.Doobie import ch.epfl.bluebrain.nexus.delta.sourcing.{DeleteExpired, Message} -import ch.epfl.bluebrain.nexus.testkit.bio.IOFixedClock +import ch.epfl.bluebrain.nexus.testkit.clock.FixedClock import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite import doobie.implicits._ import munit.AnyFixture @@ -37,7 +37,7 @@ class EphemeralStateStoreSuite extends CatsEffectSuite with Doobie.Fixture with private val m2 = nxv + "m2" private val message2 = MessageState(m2, project1, "Bye !", alice, Instant.EPOCH.plusSeconds(60L), Anonymous) - private lazy val deleteExpired = new DeleteExpired(xas)(IOFixedClock.ceClock(Instant.EPOCH.plusSeconds(6L))) + private lazy val deleteExpired = new DeleteExpired(xas)(FixedClock.atInstant(Instant.EPOCH.plusSeconds(6L))) test("save the states") { for { diff --git a/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/stream/ProjectionStoreSuite.scala b/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/stream/ProjectionStoreSuite.scala index 6abfc62351..fc096eb09b 100644 --- a/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/stream/ProjectionStoreSuite.scala +++ b/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/stream/ProjectionStoreSuite.scala @@ -6,6 +6,7 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef import ch.epfl.bluebrain.nexus.delta.sourcing.offset.Offset import ch.epfl.bluebrain.nexus.delta.sourcing.postgres.Doobie import ch.epfl.bluebrain.nexus.delta.sourcing.query.RefreshStrategy +import ch.epfl.bluebrain.nexus.testkit.clock.FixedClock import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite import munit.AnyFixture @@ -74,7 +75,7 @@ class ProjectionStoreSuite extends CatsEffectSuite with Doobie.Fixture with Doob test("Reset an offset") { val later = Instant.EPOCH.plusSeconds(1000) - val storeLater = ProjectionStore(xas, QueryConfig(10, RefreshStrategy.Stop))(ceClock(later)) + val storeLater = ProjectionStore(xas, QueryConfig(10, RefreshStrategy.Stop))(FixedClock.atInstant(later)) for { _ <- store.save(metadata, progress) diff --git a/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/stream/SupervisorSetup.scala b/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/stream/SupervisorSetup.scala index cbe4c10a73..e78d695c89 100644 --- a/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/stream/SupervisorSetup.scala +++ b/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/stream/SupervisorSetup.scala @@ -7,8 +7,8 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.config.{BatchConfig, ProjectionCon import ch.epfl.bluebrain.nexus.delta.sourcing.postgres.Doobie import ch.epfl.bluebrain.nexus.delta.sourcing.projections.{ProjectionErrors, Projections} import ch.epfl.bluebrain.nexus.delta.sourcing.query.RefreshStrategy -import ch.epfl.bluebrain.nexus.testkit.bio.IOFixedClock import ch.epfl.bluebrain.nexus.testkit.ce.CatsRunContext +import ch.epfl.bluebrain.nexus.testkit.clock.FixedClock import ch.epfl.bluebrain.nexus.testkit.mu.NexusSuite import ch.epfl.bluebrain.nexus.testkit.mu.ce.ResourceFixture import ch.epfl.bluebrain.nexus.testkit.mu.ce.ResourceFixture.IOFixture @@ -62,7 +62,7 @@ object SupervisorSetup { ): IOFixture[SupervisorSetup] = ResourceFixture.suiteLocal(name, resource(cluster)) - trait Fixture { self: NexusSuite with CatsRunContext with IOFixedClock => + trait Fixture { self: NexusSuite with CatsRunContext with FixedClock => val supervisor: IOFixture[SupervisorSetup] = SupervisorSetup.suiteLocalFixture("supervisor", ClusterConfig(1, 0)) val supervisor3_1: IOFixture[SupervisorSetup] = diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/bio/IOFixedClock.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/bio/IOFixedClock.scala deleted file mode 100644 index 4489b24052..0000000000 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/bio/IOFixedClock.scala +++ /dev/null @@ -1,20 +0,0 @@ -package ch.epfl.bluebrain.nexus.testkit.bio - -import cats.effect.{Clock, IO} - -import java.time.Instant -import scala.concurrent.duration.TimeUnit - -trait IOFixedClock { - - private val realClock: Clock[IO] = Clock.create - - def ceClock(instant: Instant): Clock[IO] = new Clock[IO] { - override def realTime(unit: TimeUnit): IO[Long] = IO.pure(instant.toEpochMilli) - override def monotonic(unit: TimeUnit): IO[Long] = realClock.monotonic(unit) - } - - implicit def ceClock: Clock[IO] = ceClock(Instant.EPOCH) -} - -object IOFixedClock extends IOFixedClock diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/clock/FixedClock.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/clock/FixedClock.scala new file mode 100644 index 0000000000..3e25cca8a5 --- /dev/null +++ b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/clock/FixedClock.scala @@ -0,0 +1,21 @@ +package ch.epfl.bluebrain.nexus.testkit.clock + +import cats.effect.{Clock, IO} +import ch.epfl.bluebrain.nexus.testkit.clock.FixedClock.atInstant + +import java.time.Instant +import scala.concurrent.duration.TimeUnit + +trait FixedClock { + implicit def clock: Clock[IO] = atInstant(Instant.EPOCH) +} + +object FixedClock { + private val realClock: Clock[IO] = Clock.create + + def atInstant(instant: Instant): Clock[IO] = new Clock[IO] { + override def realTime(unit: TimeUnit): IO[Long] = IO.pure(instant.toEpochMilli) + + override def monotonic(unit: TimeUnit): IO[Long] = realClock.monotonic(unit) + } +} diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/MutableClock.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/clock/MutableClock.scala similarity index 86% rename from delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/MutableClock.scala rename to delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/clock/MutableClock.scala index 07429015fd..96a390be90 100644 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/MutableClock.scala +++ b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/clock/MutableClock.scala @@ -1,4 +1,4 @@ -package ch.epfl.bluebrain.nexus.testkit +package ch.epfl.bluebrain.nexus.testkit.clock import cats.effect.concurrent.Ref import cats.effect.{Clock, IO, Resource} @@ -23,6 +23,6 @@ object MutableClock { trait Fixture { self: CatsEffectSuite => - val clock: ResourceFixture.IOFixture[MutableClock] = suiteLocalFixture + val mutableClockFixture: ResourceFixture.IOFixture[MutableClock] = suiteLocalFixture } } diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BioSuite.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BioSuite.scala index eaa25886ed..37d9786eaa 100644 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BioSuite.scala +++ b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BioSuite.scala @@ -1,6 +1,7 @@ package ch.epfl.bluebrain.nexus.testkit.mu.bio -import ch.epfl.bluebrain.nexus.testkit.bio.{BioRunContext, IOFixedClock} +import ch.epfl.bluebrain.nexus.testkit.bio.BioRunContext +import ch.epfl.bluebrain.nexus.testkit.clock.FixedClock import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsIOValues import ch.epfl.bluebrain.nexus.testkit.mu.{CollectionAssertions, EitherAssertions, EitherValues, NexusSuite} import monix.bio.IO @@ -16,7 +17,7 @@ abstract class BioSuite with CollectionAssertions with EitherAssertions with EitherValues - with IOFixedClock { + with FixedClock { protected val ioTimeout: FiniteDuration = 45.seconds diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/ce/CatsEffectSuite.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/ce/CatsEffectSuite.scala index 2773581053..53822d14ef 100644 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/ce/CatsEffectSuite.scala +++ b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/ce/CatsEffectSuite.scala @@ -1,8 +1,8 @@ package ch.epfl.bluebrain.nexus.testkit.mu.ce import cats.effect.IO -import ch.epfl.bluebrain.nexus.testkit.bio.IOFixedClock import ch.epfl.bluebrain.nexus.testkit.ce.CatsRunContext +import ch.epfl.bluebrain.nexus.testkit.clock.FixedClock import ch.epfl.bluebrain.nexus.testkit.mu.{CollectionAssertions, EitherAssertions, EitherValues, NexusSuite} import monix.bio.{IO => BIO} import monix.execution.Scheduler @@ -22,7 +22,7 @@ abstract class CatsEffectSuite with CollectionAssertions with EitherAssertions with EitherValues - with IOFixedClock { + with FixedClock { protected val ioTimeout: FiniteDuration = 45.seconds override def munitValueTransforms: List[ValueTransform] = diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/bio/BioSpec.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/bio/BioSpec.scala index 2ccc32243a..57cdebaa31 100644 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/bio/BioSpec.scala +++ b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/bio/BioSpec.scala @@ -1,6 +1,6 @@ package ch.epfl.bluebrain.nexus.testkit.scalatest.bio -import ch.epfl.bluebrain.nexus.testkit.bio.IOFixedClock +import ch.epfl.bluebrain.nexus.testkit.clock.FixedClock import ch.epfl.bluebrain.nexus.testkit.scalatest.BaseSpec -trait BioSpec extends BaseSpec with BIOValues with IOFixedClock +trait BioSpec extends BaseSpec with BIOValues with FixedClock diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/ce/CatsEffectSpec.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/ce/CatsEffectSpec.scala index 74a830570d..9af47e42bc 100644 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/ce/CatsEffectSpec.scala +++ b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/ce/CatsEffectSpec.scala @@ -1,7 +1,7 @@ package ch.epfl.bluebrain.nexus.testkit.scalatest.ce -import ch.epfl.bluebrain.nexus.testkit.bio.IOFixedClock import ch.epfl.bluebrain.nexus.testkit.ce.CatsRunContext +import ch.epfl.bluebrain.nexus.testkit.clock.FixedClock import ch.epfl.bluebrain.nexus.testkit.scalatest.BaseSpec -trait CatsEffectSpec extends BaseSpec with CatsRunContext with CatsIOValues with IOFixedClock +trait CatsEffectSpec extends BaseSpec with CatsRunContext with CatsIOValues with FixedClock diff --git a/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/BaseIntegrationSpec.scala b/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/BaseIntegrationSpec.scala index 1a2d8b3695..24d2dbcee5 100644 --- a/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/BaseIntegrationSpec.scala +++ b/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/BaseIntegrationSpec.scala @@ -11,8 +11,8 @@ import cats.effect.concurrent.Ref import cats.syntax.all._ import ch.epfl.bluebrain.nexus.delta.kernel.Logger import ch.epfl.bluebrain.nexus.testkit._ -import ch.epfl.bluebrain.nexus.testkit.bio.IOFixedClock import ch.epfl.bluebrain.nexus.testkit.ce.CatsRunContext +import ch.epfl.bluebrain.nexus.testkit.clock.FixedClock import ch.epfl.bluebrain.nexus.testkit.scalatest.EitherValues import ch.epfl.bluebrain.nexus.testkit.scalatest.ce.{CatsEffectAsyncScalaTestAdapter, CatsIOValues} import ch.epfl.bluebrain.nexus.tests.BaseIntegrationSpec._ @@ -44,7 +44,7 @@ trait BaseIntegrationSpec with Inspectors with CatsRunContext with CatsIOValues - with IOFixedClock + with FixedClock with CirceUnmarshalling with CirceLiteral with CirceEq From 997afd12c31c2d1efbd70287f5b8a9a4a06d78c8 Mon Sep 17 00:00:00 2001 From: Daniel Bell Date: Thu, 9 Nov 2023 15:58:16 +0100 Subject: [PATCH 03/18] remove a lot of UIO conversions --- .../delta/routes/OrganizationsRoutes.scala | 5 ++-- .../nexus/delta/routes/ProjectsRoutes.scala | 7 +++-- .../nexus/delta/routes/ResourcesRoutes.scala | 27 ++++++++----------- .../nexus/delta/wiring/AclsModule.scala | 3 +-- .../nexus/delta/wiring/MultiFetchModule.scala | 3 +-- .../nexus/delta/kernel/utils/IOUtils.scala | 2 +- .../blazegraph/BlazegraphPluginModule.scala | 5 ++-- .../BlazegraphViewsIndexingRoutes.scala | 3 +-- .../routes/BlazegraphViewsRoutes.scala | 18 +++++-------- .../CompositeViewsPluginModule.scala | 3 +-- .../projections/CompositeProjections.scala | 3 +-- .../ElasticSearchPluginModule.scala | 5 ++-- .../query/DefaultViewsQuery.scala | 2 -- .../ProjectDeletionRunner.scala | 3 +-- .../plugins/storage/StoragePluginModule.scala | 3 +-- .../client/RemoteDiskStorageClient.scala | 2 +- .../delta/sdk/http/HttpClientConfig.scala | 5 ++-- .../nexus/testkit/mu/bio/BIOValues.scala | 7 +---- 18 files changed, 39 insertions(+), 67 deletions(-) diff --git a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/OrganizationsRoutes.scala b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/OrganizationsRoutes.scala index 9f79668ccc..6a7d94f549 100644 --- a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/OrganizationsRoutes.scala +++ b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/OrganizationsRoutes.scala @@ -5,15 +5,14 @@ import akka.http.scaladsl.server.Directives._ import akka.http.scaladsl.server.{Directive1, Route} import cats.effect.IO import cats.implicits._ -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.RemoteContextResolution import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.encoder.JsonLdEncoder import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering import ch.epfl.bluebrain.nexus.delta.routes.OrganizationsRoutes.OrganizationInput import ch.epfl.bluebrain.nexus.delta.sdk.OrganizationResource import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclCheck -import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaDirectives._ import ch.epfl.bluebrain.nexus.delta.sdk.circe.CirceUnmarshalling +import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaDirectives._ import ch.epfl.bluebrain.nexus.delta.sdk.directives.{AuthDirectives, DeltaSchemeDirectives} import ch.epfl.bluebrain.nexus.delta.sdk.identities.Identities import ch.epfl.bluebrain.nexus.delta.sdk.identities.model.Caller @@ -71,7 +70,7 @@ final class OrganizationsRoutes( createdBy, updatedBy, label, - org => aclCheck.authorizeFor(org.label, orgs.read, allAcls).toUIO + org => aclCheck.authorizeFor(org.label, orgs.read, allAcls) ) } } diff --git a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/ProjectsRoutes.scala b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/ProjectsRoutes.scala index ee351928d9..1e60931ce8 100644 --- a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/ProjectsRoutes.scala +++ b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/ProjectsRoutes.scala @@ -6,14 +6,13 @@ import akka.http.scaladsl.server._ import cats.data.OptionT import cats.effect.{ContextShift, IO} import cats.implicits._ -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.RemoteContextResolution import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.encoder.JsonLdEncoder import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering import ch.epfl.bluebrain.nexus.delta.sdk._ import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclCheck -import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaDirectives._ import ch.epfl.bluebrain.nexus.delta.sdk.circe.CirceUnmarshalling +import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaDirectives._ import ch.epfl.bluebrain.nexus.delta.sdk.directives.{AuthDirectives, DeltaSchemeDirectives} import ch.epfl.bluebrain.nexus.delta.sdk.fusion.FusionConfig import ch.epfl.bluebrain.nexus.delta.sdk.identities.Identities @@ -23,7 +22,7 @@ import ch.epfl.bluebrain.nexus.delta.sdk.model.BaseUri import ch.epfl.bluebrain.nexus.delta.sdk.model.search.SearchParams.ProjectSearchParams import ch.epfl.bluebrain.nexus.delta.sdk.model.search.SearchResults.searchResultsJsonLdEncoder import ch.epfl.bluebrain.nexus.delta.sdk.model.search.{PaginationConfig, SearchResults} -import ch.epfl.bluebrain.nexus.delta.sdk.permissions.Permissions.{projects => projectsPermissions, resources} +import ch.epfl.bluebrain.nexus.delta.sdk.permissions.Permissions.{resources, projects => projectsPermissions} import ch.epfl.bluebrain.nexus.delta.sdk.projects.model.ProjectRejection.ProjectNotFound import ch.epfl.bluebrain.nexus.delta.sdk.projects.model._ import ch.epfl.bluebrain.nexus.delta.sdk.projects.{Projects, ProjectsConfig, ProjectsStatistics} @@ -75,7 +74,7 @@ final class ProjectsRoutes( createdBy, updatedBy, label, - proj => aclCheck.authorizeFor(proj.ref, projectsPermissions.read, allAcls).toUIO + proj => aclCheck.authorizeFor(proj.ref, projectsPermissions.read, allAcls) ) } } diff --git a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/ResourcesRoutes.scala b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/ResourcesRoutes.scala index 28633fec9f..b21e780cef 100644 --- a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/ResourcesRoutes.scala +++ b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/ResourcesRoutes.scala @@ -5,7 +5,6 @@ import akka.http.scaladsl.server.Directives._ import akka.http.scaladsl.server._ import cats.effect.IO import cats.syntax.all._ -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.rdf.RdfError import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.schemas import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.{ContextValue, RemoteContextResolution} @@ -14,8 +13,8 @@ import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering import ch.epfl.bluebrain.nexus.delta.routes.ResourcesRoutes.asSourceWithMetadata import ch.epfl.bluebrain.nexus.delta.sdk._ import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclCheck -import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaDirectives._ import ch.epfl.bluebrain.nexus.delta.sdk.circe.CirceUnmarshalling +import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaDirectives._ import ch.epfl.bluebrain.nexus.delta.sdk.directives.{AuthDirectives, DeltaSchemeDirectives} import ch.epfl.bluebrain.nexus.delta.sdk.fusion.FusionConfig import ch.epfl.bluebrain.nexus.delta.sdk.identities.Identities @@ -28,7 +27,6 @@ import ch.epfl.bluebrain.nexus.delta.sdk.resources.NexusSource.DecodingOption import ch.epfl.bluebrain.nexus.delta.sdk.resources.model.ResourceRejection.{InvalidJsonLdFormat, InvalidSchemaRejection, NoSchemaProvided, ResourceNotFound} import ch.epfl.bluebrain.nexus.delta.sdk.resources.model.{Resource, ResourceRejection} import ch.epfl.bluebrain.nexus.delta.sdk.resources.{NexusSource, Resources} -import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef import io.circe.{Json, Printer} /** @@ -68,9 +66,6 @@ final class ResourcesRoutes( implicit private def resourceFAJsonLdEncoder[A: JsonLdEncoder]: JsonLdEncoder[ResourceF[A]] = ResourceF.resourceFAJsonLdEncoder(ContextValue.empty) - private def indexUIO(project: ProjectRef, resource: ResourceF[Resource], mode: IndexingMode) = - index(project, resource, mode).toUIO - def routes: Route = baseUriPrefix(baseUri.prefix) { pathPrefix("resources") { @@ -85,7 +80,7 @@ final class ResourcesRoutes( Created, resources .create(project, resourceSchema, source.value, tag) - .flatTap(indexUIO(project, _, mode)) + .flatTap(index(project, _, mode)) .map(_.void) .attemptNarrow[ResourceRejection] ) @@ -102,7 +97,7 @@ final class ResourcesRoutes( Created, resources .create(project, schema, source.value, tag) - .flatTap(indexUIO(project, _, mode)) + .flatTap(index(project, _, mode)) .map(_.void) .attemptNarrow[ResourceRejection] .rejectWhen(wrongJsonOrNotFound) @@ -124,7 +119,7 @@ final class ResourcesRoutes( Created, resources .create(resource, project, schema, source.value, tag) - .flatTap(indexUIO(project, _, mode)) + .flatTap(index(project, _, mode)) .map(_.void) .attemptNarrow[ResourceRejection] .rejectWhen(wrongJsonOrNotFound) @@ -134,7 +129,7 @@ final class ResourcesRoutes( emit( resources .update(resource, project, schemaOpt, rev, source.value, tag) - .flatTap(indexUIO(project, _, mode)) + .flatTap(index(project, _, mode)) .map(_.void) .attemptNarrow[ResourceRejection] .rejectWhen(wrongJsonOrNotFound) @@ -148,7 +143,7 @@ final class ResourcesRoutes( emit( resources .deprecate(resource, project, schemaOpt, rev) - .flatTap(indexUIO(project, _, mode)) + .flatTap(index(project, _, mode)) .map(_.void) .attemptNarrow[ResourceRejection] .rejectWhen(wrongJsonOrNotFound) @@ -178,7 +173,7 @@ final class ResourcesRoutes( emit( resources .undeprecate(resource, project, schemaOpt, rev) - .flatTap(indexUIO(project, _, mode)) + .flatTap(index(project, _, mode)) .map(_.void) .attemptNarrow[ResourceRejection] .rejectWhen(wrongJsonOrNotFound) @@ -193,7 +188,7 @@ final class ResourcesRoutes( .flatMap { schema => resources .updateAttachedSchema(resource, project, schema) - .flatTap(indexUIO(project, _, mode)) + .flatTap(index(project, _, mode)) } .attemptNarrow[ResourceRejection] .rejectWhen(wrongJsonOrNotFound) @@ -207,7 +202,7 @@ final class ResourcesRoutes( OK, resources .refresh(resource, project, schemaOpt) - .flatTap(indexUIO(project, _, mode)) + .flatTap(index(project, _, mode)) .map(_.void) .attemptNarrow[ResourceRejection] .rejectWhen(wrongJsonOrNotFound) @@ -273,7 +268,7 @@ final class ResourcesRoutes( Created, resources .tag(resource, project, schemaOpt, tag, tagRev, rev) - .flatTap(indexUIO(project, _, mode)) + .flatTap(index(project, _, mode)) .map(_.void) .attemptNarrow[ResourceRejection] .rejectWhen(wrongJsonOrNotFound) @@ -289,7 +284,7 @@ final class ResourcesRoutes( emit( resources .deleteTag(resource, project, schemaOpt, tag, rev) - .flatTap(indexUIO(project, _, mode)) + .flatTap(index(project, _, mode)) .map(_.void) .attemptNarrow[ResourceRejection] .rejectOn[ResourceNotFound] diff --git a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/AclsModule.scala b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/AclsModule.scala index 12515b7c0c..717a5fb950 100644 --- a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/AclsModule.scala +++ b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/AclsModule.scala @@ -18,7 +18,6 @@ import ch.epfl.bluebrain.nexus.delta.sdk.permissions.{Permissions, StoragePermis import ch.epfl.bluebrain.nexus.delta.sdk.sse.SseEncoder import ch.epfl.bluebrain.nexus.delta.sourcing.Transactors import izumi.distage.model.definition.{Id, ModuleDef} -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ /** * Acls module wiring config. @@ -37,7 +36,7 @@ object AclsModule extends ModuleDef { timer: Timer[IO] ) => acls.AclsImpl( - permissions.fetchPermissionSet.toUIO, + permissions.fetchPermissionSet, AclsImpl.findUnknownRealms(xas), permissions.minimum, config.acls, diff --git a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/MultiFetchModule.scala b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/MultiFetchModule.scala index 563089cb2b..18ed6340a7 100644 --- a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/MultiFetchModule.scala +++ b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/MultiFetchModule.scala @@ -1,7 +1,6 @@ package ch.epfl.bluebrain.nexus.delta.wiring import ch.epfl.bluebrain.nexus.delta.Main.pluginsMaxPriority -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.RemoteContextResolution import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering import ch.epfl.bluebrain.nexus.delta.routes.MultiFetchRoutes @@ -23,7 +22,7 @@ object MultiFetchModule extends ModuleDef { ) => MultiFetch( aclCheck, - (input: MultiFetchRequest.Input) => shifts.fetch(input.id, input.project).toUIO + (input: MultiFetchRequest.Input) => shifts.fetch(input.id, input.project) ) } diff --git a/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/utils/IOUtils.scala b/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/utils/IOUtils.scala index f6c702fcc5..c1f94e9389 100644 --- a/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/utils/IOUtils.scala +++ b/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/utils/IOUtils.scala @@ -33,7 +33,7 @@ object IOInstant extends IOInstant trait UUIDF { /** - * Creates a UUID wrapped in an [[UIO]] + * Creates a UUID wrapped in an [[IO]] */ def apply(): IO[UUID] } diff --git a/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphPluginModule.scala b/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphPluginModule.scala index 4072bd60f4..deb82a8410 100644 --- a/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphPluginModule.scala +++ b/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphPluginModule.scala @@ -2,13 +2,12 @@ package ch.epfl.bluebrain.nexus.delta.plugins.blazegraph import akka.actor.typed.ActorSystem import cats.effect.{Clock, ContextShift, IO, Timer} -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.kernel.utils.{CatsEffectsClasspathResourceUtils, UUIDF} import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.client.BlazegraphClient import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.config.BlazegraphViewsConfig import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.indexing.BlazegraphCoordinator import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.model.BlazegraphViewRejection.ProjectContextRejection -import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.model.{contexts, schema => viewsSchemaId, BlazegraphView, BlazegraphViewEvent, DefaultProperties} +import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.model.{BlazegraphView, BlazegraphViewEvent, DefaultProperties, contexts, schema => viewsSchemaId} import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.routes.{BlazegraphViewsIndexingRoutes, BlazegraphViewsRoutes, BlazegraphViewsRoutesHandler} import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.slowqueries.{BlazegraphSlowQueryDeleter, BlazegraphSlowQueryLogger, BlazegraphSlowQueryStore} import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.JsonLdApi @@ -131,7 +130,7 @@ class BlazegraphPluginModule(priority: Int) extends ModuleDef { xas: Transactors ) => ValidateBlazegraphView( - permissions.fetchPermissionSet.toUIO, + permissions.fetchPermissionSet, config.maxViewRefs, xas ) diff --git a/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/routes/BlazegraphViewsIndexingRoutes.scala b/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/routes/BlazegraphViewsIndexingRoutes.scala index 56b7ea2d8d..81c12e1e72 100644 --- a/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/routes/BlazegraphViewsIndexingRoutes.scala +++ b/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/routes/BlazegraphViewsIndexingRoutes.scala @@ -4,7 +4,6 @@ import akka.http.scaladsl.server.Directives._ import akka.http.scaladsl.server.Route import cats.effect.{ContextShift, IO} import cats.implicits._ -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.indexing.IndexingViewDef.ActiveViewDef import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.model.BlazegraphViewRejection._ import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.model._ @@ -122,7 +121,7 @@ class BlazegraphViewsIndexingRoutes( (delete & authorizeFor(ref, Write)) { emit( fetch(id, ref) - .flatMap { r => projections.scheduleRestart(r.projection).toUIO } + .flatMap { r => projections.scheduleRestart(r.projection) } .as(Offset.start) .attemptNarrow[BlazegraphViewRejection] .rejectOn[ViewNotFound] diff --git a/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/routes/BlazegraphViewsRoutes.scala b/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/routes/BlazegraphViewsRoutes.scala index 4a943d356b..7a1b7b7317 100644 --- a/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/routes/BlazegraphViewsRoutes.scala +++ b/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/routes/BlazegraphViewsRoutes.scala @@ -4,7 +4,6 @@ import akka.http.scaladsl.model.StatusCodes.Created import akka.http.scaladsl.server.Directives._ import akka.http.scaladsl.server.{Directive0, Route} import cats.implicits._ -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.model.BlazegraphView._ import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.model.BlazegraphViewRejection._ import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.model._ @@ -15,6 +14,7 @@ import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.{ContextValue, RemoteCon import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.encoder.JsonLdEncoder import ch.epfl.bluebrain.nexus.delta.rdf.query.SparqlQuery import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering +import ch.epfl.bluebrain.nexus.delta.sdk.IndexingAction import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclCheck import ch.epfl.bluebrain.nexus.delta.sdk.circe.CirceUnmarshalling import ch.epfl.bluebrain.nexus.delta.sdk.directives.{AuthDirectives, DeltaDirectives, DeltaSchemeDirectives} @@ -26,8 +26,7 @@ import ch.epfl.bluebrain.nexus.delta.sdk.marshalling.RdfMarshalling import ch.epfl.bluebrain.nexus.delta.sdk.model.routes.Tag import ch.epfl.bluebrain.nexus.delta.sdk.model.search.SearchResults._ import ch.epfl.bluebrain.nexus.delta.sdk.model.search.{PaginationConfig, SearchResults} -import ch.epfl.bluebrain.nexus.delta.sdk.model.{BaseUri, IdSegment, ResourceF} -import ch.epfl.bluebrain.nexus.delta.sdk.{IndexingAction, IndexingMode} +import ch.epfl.bluebrain.nexus.delta.sdk.model.{BaseUri, IdSegment} import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef import io.circe.Json @@ -66,9 +65,6 @@ class BlazegraphViewsRoutes( import schemeDirectives._ - private def indexUIO(project: ProjectRef, resource: ResourceF[BlazegraphView], mode: IndexingMode) = - index(project, resource, mode).toUIO - def routes: Route = concat( pathPrefix("views") { @@ -82,7 +78,7 @@ class BlazegraphViewsRoutes( Created, views .create(ref, source) - .flatTap(indexUIO(ref, _, mode)) + .flatTap(index(ref, _, mode)) .mapValue(_.metadata) .attemptNarrow[BlazegraphViewRejection] .rejectWhen(decodingFailedOrViewNotFound) @@ -102,7 +98,7 @@ class BlazegraphViewsRoutes( Created, views .create(id, ref, source) - .flatTap(indexUIO(ref, _, mode)) + .flatTap(index(ref, _, mode)) .mapValue(_.metadata) .attemptNarrow[BlazegraphViewRejection] .rejectWhen(decodingFailedOrViewNotFound) @@ -112,7 +108,7 @@ class BlazegraphViewsRoutes( emit( views .update(id, ref, rev, source) - .flatTap(indexUIO(ref, _, mode)) + .flatTap(index(ref, _, mode)) .mapValue(_.metadata) .attemptNarrow[BlazegraphViewRejection] .rejectWhen(decodingFailedOrViewNotFound) @@ -126,7 +122,7 @@ class BlazegraphViewsRoutes( emit( views .deprecate(id, ref, rev) - .flatTap(indexUIO(ref, _, mode)) + .flatTap(index(ref, _, mode)) .mapValue(_.metadata) .attemptNarrow[BlazegraphViewRejection] .rejectOn[ViewNotFound] @@ -186,7 +182,7 @@ class BlazegraphViewsRoutes( Created, views .tag(id, ref, tag, tagRev, rev) - .flatTap(indexUIO(ref, _, mode)) + .flatTap(index(ref, _, mode)) .mapValue(_.metadata) .attemptNarrow[BlazegraphViewRejection] .rejectOn[ViewNotFound] diff --git a/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/CompositeViewsPluginModule.scala b/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/CompositeViewsPluginModule.scala index d4362ab78c..69df52a6ce 100644 --- a/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/CompositeViewsPluginModule.scala +++ b/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/CompositeViewsPluginModule.scala @@ -3,7 +3,6 @@ package ch.epfl.bluebrain.nexus.delta.plugins.compositeviews import akka.actor.typed.ActorSystem import cats.effect.{Clock, ContextShift, IO, Timer} import cats.syntax.all._ -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.kernel.utils.UUIDF import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.client.BlazegraphClient import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.model.DefaultProperties @@ -116,7 +115,7 @@ class CompositeViewsPluginModule(priority: Int) extends ModuleDef { ValidateCompositeView( aclCheck, projects, - permissions.fetchPermissionSet.toUIO, + permissions.fetchPermissionSet, client, deltaClient, config.prefix, diff --git a/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/projections/CompositeProjections.scala b/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/projections/CompositeProjections.scala index fa3b3514d7..7cce4f2870 100644 --- a/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/projections/CompositeProjections.scala +++ b/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/projections/CompositeProjections.scala @@ -4,7 +4,6 @@ import cats.effect.{Clock, ContextShift, IO, Timer} import cats.syntax.all._ import ch.epfl.bluebrain.nexus.delta.kernel.Logger import ch.epfl.bluebrain.nexus.delta.kernel.utils.IOInstant -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.indexing.CompositeViewDef.ActiveViewDef import ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.model.CompositeRestart import ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.model.CompositeRestart.{FullRebuild, FullRestart, PartialRebuild} @@ -111,7 +110,7 @@ object CompositeProjections { Operation.fromFs2Pipe[Unit]( Projection.persist( progress, - compositeProgressStore.save(view.indexingRef, branch, _).toUIO, + compositeProgressStore.save(view.indexingRef, branch, _), failedElemLogStore.save(view.metadata, _) )(batch, timer, cs) ) diff --git a/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchPluginModule.scala b/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchPluginModule.scala index 3f8c87d3df..1fbe7ff1bf 100644 --- a/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchPluginModule.scala +++ b/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchPluginModule.scala @@ -2,14 +2,13 @@ package ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch import akka.actor.typed.ActorSystem import cats.effect.{Clock, ContextShift, IO, Timer} -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.kernel.utils.UUIDF import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.client.ElasticSearchClient import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.config.ElasticSearchViewsConfig import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.deletion.{ElasticSearchDeletionTask, EventMetricsDeletionTask} import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.indexing.ElasticSearchCoordinator import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.model.ElasticSearchViewRejection.ProjectContextRejection -import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.model.{contexts, schema => viewsSchemaId, ElasticSearchFiles, ElasticSearchView, ElasticSearchViewEvent} +import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.model.{ElasticSearchFiles, ElasticSearchView, ElasticSearchViewEvent, contexts, schema => viewsSchemaId} import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.query.{DefaultViewsQuery, ElasticSearchQueryError} import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.routes._ import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary @@ -286,7 +285,7 @@ class ElasticSearchPluginModule(priority: Int) extends ModuleDef { } make[IdResolution].from { (defaultViewsQuery: DefaultViewsQuery.Elasticsearch, shifts: ResourceShifts) => - new IdResolution(defaultViewsQuery, (resourceRef, projectRef) => shifts.fetch(resourceRef, projectRef).toUIO) + new IdResolution(defaultViewsQuery, (resourceRef, projectRef) => shifts.fetch(resourceRef, projectRef)) } make[IdResolutionRoutes].from { diff --git a/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/query/DefaultViewsQuery.scala b/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/query/DefaultViewsQuery.scala index 348cb28906..4b2a8bd0c8 100644 --- a/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/query/DefaultViewsQuery.scala +++ b/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/query/DefaultViewsQuery.scala @@ -3,7 +3,6 @@ package ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.query import akka.http.scaladsl.model.Uri import cats.effect.IO import cats.implicits.catsSyntaxMonadError -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.client.ElasticSearchClient import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.config.ElasticSearchViewsConfig import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.model.permissions @@ -77,7 +76,6 @@ object DefaultViewsQuery { v => ProjectAcl(v.ref.project) -> permissions.read, identity )(caller) - .toUIO } .flatMap { case views if views.isEmpty => IO.raiseError(AuthorizationFailed("No views are accessible.")) diff --git a/delta/plugins/project-deletion/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/projectdeletion/ProjectDeletionRunner.scala b/delta/plugins/project-deletion/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/projectdeletion/ProjectDeletionRunner.scala index 5152b42f97..bce31f2135 100644 --- a/delta/plugins/project-deletion/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/projectdeletion/ProjectDeletionRunner.scala +++ b/delta/plugins/project-deletion/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/projectdeletion/ProjectDeletionRunner.scala @@ -3,7 +3,6 @@ package ch.epfl.bluebrain.nexus.delta.plugins.projectdeletion import cats.effect.{Clock, IO, Timer} import cats.implicits._ import ch.epfl.bluebrain.nexus.delta.kernel.Logger -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.kernel.search.Pagination import ch.epfl.bluebrain.nexus.delta.plugins.projectdeletion.model.ProjectDeletionConfig import ch.epfl.bluebrain.nexus.delta.sdk.ProjectResource @@ -33,7 +32,7 @@ class ProjectDeletionRunner(projects: Projects, config: ProjectDeletionConfig, p projects .list( Pagination.OnePage, - ProjectSearchParams(filter = _ => IO.pure(true).toUIO), + ProjectSearchParams(filter = _ => IO.pure(true)), Ordering.by(_.updatedAt) // this is not needed, we are forced to specify an ordering ) .map(_.results) diff --git a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/StoragePluginModule.scala b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/StoragePluginModule.scala index 4defa4d031..4970f416eb 100644 --- a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/StoragePluginModule.scala +++ b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/StoragePluginModule.scala @@ -4,7 +4,6 @@ import akka.actor import akka.actor.typed.ActorSystem import cats.effect.{Clock, ContextShift, IO, Timer} import cats.syntax.all._ -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.kernel.utils.UUIDF import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.client.ElasticSearchClient import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.config.ElasticSearchViewsConfig @@ -86,7 +85,7 @@ class StoragePluginModule(priority: Int) extends ModuleDef { Storages( fetchContext.mapRejection(StorageRejection.ProjectContextRejection), contextResolution, - permissions.fetchPermissionSet.toUIO, + permissions.fetchPermissionSet, StorageAccess.apply(_, _, remoteDiskStorageClient, storageTypeConfig), xas, cfg.storages, diff --git a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/client/RemoteDiskStorageClient.scala b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/client/RemoteDiskStorageClient.scala index 9ebf5bbdc7..05f9cc2007 100644 --- a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/client/RemoteDiskStorageClient.scala +++ b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/client/RemoteDiskStorageClient.scala @@ -66,7 +66,7 @@ final class RemoteDiskStorageClient(client: HttpClient, getAuthToken: AuthTokenP val endpoint = baseUri.endpoint / "buckets" / bucket.value val req = Head(endpoint).withCredentials(authToken) client(req) { - case resp if resp.status.isSuccess() => IO.delay(resp.discardEntityBytes()).void.toUIO + case resp if resp.status.isSuccess() => IO.delay(resp.discardEntityBytes()).void } } } diff --git a/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/http/HttpClientConfig.scala b/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/http/HttpClientConfig.scala index 1169b3b02f..65cf1488fb 100644 --- a/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/http/HttpClientConfig.scala +++ b/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/http/HttpClientConfig.scala @@ -1,10 +1,9 @@ package ch.epfl.bluebrain.nexus.delta.sdk.http import ch.epfl.bluebrain.nexus.delta.kernel.{Logger, RetryStrategy, RetryStrategyConfig} -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ +import ch.epfl.bluebrain.nexus.delta.sdk.http.HttpClientConfig.logger import pureconfig.ConfigReader import pureconfig.error.CannotConvert -import ch.epfl.bluebrain.nexus.delta.sdk.http.HttpClientConfig.logger import pureconfig.generic.semiauto.deriveReader import scala.annotation.nowarn @@ -31,7 +30,7 @@ final case class HttpClientConfig( * the retry strategy from the current configuration */ def strategy: RetryStrategy[HttpClientError] = - RetryStrategy(retry, isWorthRetrying, RetryStrategy.logError(logger, "http client")(_, _).toUIO) + RetryStrategy(retry, isWorthRetrying, RetryStrategy.logError(logger, "http client")(_, _)) } object HttpClientConfig { diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BIOValues.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BIOValues.scala index 667de86a27..c68770734c 100644 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BIOValues.scala +++ b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BIOValues.scala @@ -1,6 +1,6 @@ package ch.epfl.bluebrain.nexus.testkit.mu.bio -import monix.bio.{IO, UIO} +import monix.bio.IO import monix.execution.Scheduler import munit.Assertions.fail import munit.{Location, Suite} @@ -13,11 +13,6 @@ import scala.util.control.NonFatal trait BIOValues { self: Suite => - implicit class UIOValuesOps[A](private val uio: UIO[A]) { - def accepted(implicit s: Scheduler = Scheduler.global): A = - uio.runSyncUnsafe() - } - implicit class IOValuesOps[E, A](private val io: IO[E, A])(implicit E: ClassTag[E]) { def accepted(implicit loc: Location, s: Scheduler = Scheduler.global): A = acceptedWithTimeout(Duration.Inf) From 87aab3eff137f83c0f2e66c7110a3cbc8ff4e7f5 Mon Sep 17 00:00:00 2001 From: Daniel Bell Date: Thu, 9 Nov 2023 16:04:55 +0100 Subject: [PATCH 04/18] remove a lot of BIO conversions --- .../nexus/delta/routes/ProjectsRoutes.scala | 2 +- .../nexus/delta/wiring/EventsModule.scala | 4 +--- .../nexus/delta/kernel/syntax/IOSyntax.scala | 19 +------------------ .../blazegraph/BlazegraphPluginModule.scala | 2 +- .../blazegraph/BlazegraphViewsQuery.scala | 3 +-- .../ElasticSearchPluginModule.scala | 2 +- .../ElasticSearchViewsQuery.scala | 14 ++++++-------- .../client/ElasticSearchClient.scala | 6 ++---- .../nexus/delta/sdk/projects/Projects.scala | 4 ++-- 9 files changed, 16 insertions(+), 40 deletions(-) diff --git a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/ProjectsRoutes.scala b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/ProjectsRoutes.scala index 1e60931ce8..0bcdd837cf 100644 --- a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/ProjectsRoutes.scala +++ b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/ProjectsRoutes.scala @@ -22,7 +22,7 @@ import ch.epfl.bluebrain.nexus.delta.sdk.model.BaseUri import ch.epfl.bluebrain.nexus.delta.sdk.model.search.SearchParams.ProjectSearchParams import ch.epfl.bluebrain.nexus.delta.sdk.model.search.SearchResults.searchResultsJsonLdEncoder import ch.epfl.bluebrain.nexus.delta.sdk.model.search.{PaginationConfig, SearchResults} -import ch.epfl.bluebrain.nexus.delta.sdk.permissions.Permissions.{resources, projects => projectsPermissions} +import ch.epfl.bluebrain.nexus.delta.sdk.permissions.Permissions.{projects => projectsPermissions, resources} import ch.epfl.bluebrain.nexus.delta.sdk.projects.model.ProjectRejection.ProjectNotFound import ch.epfl.bluebrain.nexus.delta.sdk.projects.model._ import ch.epfl.bluebrain.nexus.delta.sdk.projects.{Projects, ProjectsConfig, ProjectsStatistics} diff --git a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/EventsModule.scala b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/EventsModule.scala index 76fdbc19c2..3072c2cc5f 100644 --- a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/EventsModule.scala +++ b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/wiring/EventsModule.scala @@ -3,7 +3,6 @@ package ch.epfl.bluebrain.nexus.delta.wiring import cats.effect.{ContextShift, IO, Timer} import ch.epfl.bluebrain.nexus.delta.Main.pluginsMaxPriority import ch.epfl.bluebrain.nexus.delta.config.AppConfig -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.RemoteContextResolution import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering import ch.epfl.bluebrain.nexus.delta.routes.{ElemRoutes, EventsRoutes} @@ -13,7 +12,6 @@ import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaSchemeDirectives import ch.epfl.bluebrain.nexus.delta.sdk.identities.Identities import ch.epfl.bluebrain.nexus.delta.sdk.model.BaseUri import ch.epfl.bluebrain.nexus.delta.sdk.organizations.Organizations -import ch.epfl.bluebrain.nexus.delta.sdk.organizations.model.OrganizationRejection import ch.epfl.bluebrain.nexus.delta.sdk.projects.Projects import ch.epfl.bluebrain.nexus.delta.sdk.sse.{SseElemStream, SseEncoder, SseEventLog} import ch.epfl.bluebrain.nexus.delta.sourcing.Transactors @@ -37,7 +35,7 @@ object EventsModule extends ModuleDef { ) => SseEventLog( sseEncoders, - organizations.fetch(_).void.toBIO[OrganizationRejection], + organizations.fetch(_).void, projects.fetch(_).map { p => (p.value.organizationUuid, p.value.uuid) }, config.sse, xas diff --git a/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/syntax/IOSyntax.scala b/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/syntax/IOSyntax.scala index 1ca7d93af5..90dc067585 100644 --- a/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/syntax/IOSyntax.scala +++ b/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/syntax/IOSyntax.scala @@ -6,17 +6,13 @@ import cats.syntax.functor._ import ch.epfl.bluebrain.nexus.delta.kernel.RetryStrategy import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import com.typesafe.scalalogging.Logger -import monix.bio.{IO => BIO, Task, UIO} +import monix.bio.{Task, UIO} import org.typelevel.log4cats.{Logger => Log4CatsLogger} import scala.reflect.ClassTag trait IOSyntax { - implicit final def bioFunctorOps[E, A, F[_]: Functor](io: BIO[E, F[A]]): BIOFunctorOps[E, A, F] = new BIOFunctorOps( - io - ) - implicit final def taskSyntaxLogErrors[A](task: Task[A]): TaskOps[A] = new TaskOps(task) implicit final def ioSyntaxLogErrors[A](io: IO[A]): IOOps[A] = new IOOps(io) @@ -37,19 +33,6 @@ final class IORetryStrategyOps[A](private val io: IO[A]) extends AnyVal { } -final class BIOFunctorOps[E, A, F[_]: Functor](private val io: BIO[E, F[A]]) { - - /** - * Map value of [[F]] wrapped in an [[IO]]. - * - * @param f - * the mapping function - * @return - * a new [[F]] with value being the result of applying [[f]] to the value of old [[F]] - */ - def mapValue[B](f: A => B): BIO[E, F[B]] = io.map(_.map(f)) -} - final class TaskOps[A](private val task: Task[A]) extends AnyVal { /** diff --git a/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphPluginModule.scala b/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphPluginModule.scala index deb82a8410..ffe2b1d32a 100644 --- a/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphPluginModule.scala +++ b/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphPluginModule.scala @@ -7,7 +7,7 @@ import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.client.BlazegraphClient import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.config.BlazegraphViewsConfig import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.indexing.BlazegraphCoordinator import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.model.BlazegraphViewRejection.ProjectContextRejection -import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.model.{BlazegraphView, BlazegraphViewEvent, DefaultProperties, contexts, schema => viewsSchemaId} +import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.model.{contexts, schema => viewsSchemaId, BlazegraphView, BlazegraphViewEvent, DefaultProperties} import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.routes.{BlazegraphViewsIndexingRoutes, BlazegraphViewsRoutes, BlazegraphViewsRoutesHandler} import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.slowqueries.{BlazegraphSlowQueryDeleter, BlazegraphSlowQueryLogger, BlazegraphSlowQueryStore} import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.JsonLdApi diff --git a/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphViewsQuery.scala b/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphViewsQuery.scala index 0fbd2ffa65..1d36c8bd38 100644 --- a/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphViewsQuery.scala +++ b/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphViewsQuery.scala @@ -125,8 +125,7 @@ object BlazegraphViewsQuery { ) ) } - } - .toBIO[BlazegraphViewRejection], + }, xas ) } yield new BlazegraphViewsQuery { diff --git a/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchPluginModule.scala b/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchPluginModule.scala index 1fbe7ff1bf..1873d33e13 100644 --- a/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchPluginModule.scala +++ b/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchPluginModule.scala @@ -8,7 +8,7 @@ import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.config.ElasticSearchV import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.deletion.{ElasticSearchDeletionTask, EventMetricsDeletionTask} import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.indexing.ElasticSearchCoordinator import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.model.ElasticSearchViewRejection.ProjectContextRejection -import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.model.{ElasticSearchFiles, ElasticSearchView, ElasticSearchViewEvent, contexts, schema => viewsSchemaId} +import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.model.{contexts, schema => viewsSchemaId, ElasticSearchFiles, ElasticSearchView, ElasticSearchViewEvent} import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.query.{DefaultViewsQuery, ElasticSearchQueryError} import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.routes._ import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary diff --git a/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchViewsQuery.scala b/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchViewsQuery.scala index 8a95691035..2a21964088 100644 --- a/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchViewsQuery.scala +++ b/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchViewsQuery.scala @@ -1,14 +1,17 @@ package ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch import akka.http.scaladsl.model.Uri -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ +import cats.effect.IO +import cats.syntax.all._ import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.client.{ElasticSearchClient, IndexLabel} import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.model.ElasticSearchViewRejection.{DifferentElasticSearchViewType, ViewIsDeprecated, WrappedElasticSearchClientError} import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.model.ElasticSearchViewValue.{AggregateElasticSearchViewValue, IndexingElasticSearchViewValue} import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.model._ +import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclCheck import ch.epfl.bluebrain.nexus.delta.sdk.acls.model.AclAddress.{Project => ProjectAcl} import ch.epfl.bluebrain.nexus.delta.sdk.error.ServiceError.AuthorizationFailed +import ch.epfl.bluebrain.nexus.delta.sdk.http.HttpClientError import ch.epfl.bluebrain.nexus.delta.sdk.identities.model.Caller import ch.epfl.bluebrain.nexus.delta.sdk.model.IdSegment import ch.epfl.bluebrain.nexus.delta.sdk.model.search.SortList @@ -17,10 +20,6 @@ import ch.epfl.bluebrain.nexus.delta.sdk.views.{View, ViewRef, ViewsStore} import ch.epfl.bluebrain.nexus.delta.sourcing.Transactors import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef import io.circe.{Json, JsonObject} -import cats.effect.IO -import cats.syntax.all._ -import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri -import ch.epfl.bluebrain.nexus.delta.sdk.http.HttpClientError /** * Allows operations on Elasticsearch views @@ -150,11 +149,10 @@ object ElasticSearchViewsQuery { new ElasticSearchViewsQueryImpl( ViewsStore[ElasticSearchViewRejection, ElasticSearchViewState]( ElasticSearchViewState.serializer, - views.fetchState(_, _).toBIO[ElasticSearchViewRejection], + views.fetchState, view => IO.raiseWhen(view.deprecated)(ViewIsDeprecated(view.id)) - .as(viewIriOrIndexingView(prefix, view)) - .toBIO[ElasticSearchViewRejection], + .as(viewIriOrIndexingView(prefix, view)), xas ), aclCheck, diff --git a/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/client/ElasticSearchClient.scala b/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/client/ElasticSearchClient.scala index f7c1bb1d0c..f666096fb0 100644 --- a/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/client/ElasticSearchClient.scala +++ b/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/client/ElasticSearchClient.scala @@ -10,7 +10,6 @@ import cats.effect.{ContextShift, IO, Timer} import cats.syntax.all._ import ch.epfl.bluebrain.nexus.delta.kernel.RetryStrategy import ch.epfl.bluebrain.nexus.delta.kernel.RetryStrategy.logError -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.kernel.search.Pagination import ch.epfl.bluebrain.nexus.delta.kernel.utils.UrlUtils import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.client.ElasticSearchClient.BulkResponse.MixedOutcomes.Outcome @@ -29,7 +28,6 @@ import ch.epfl.bluebrain.nexus.delta.sdk.syntax._ import com.typesafe.scalalogging.Logger import io.circe._ import io.circe.syntax._ -import monix.bio.{IO => BIO} import scala.concurrent.duration._ import scala.reflect.ClassTag @@ -104,8 +102,8 @@ class ElasticSearchClient(client: HttpClient, endpoint: Uri, maxIndexPathLength: */ def existsIndex(index: IndexLabel): IO[Boolean] = client.run(Head(endpoint / index.value).withHttpCredentials) { - case resp if resp.status == OK => BIO.pure(true) - case resp if resp.status == NotFound => BIO.pure(false) + case resp if resp.status == OK => IO.pure(true) + case resp if resp.status == NotFound => IO.pure(false) } /** diff --git a/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/projects/Projects.scala b/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/projects/Projects.scala index 85ba3630ce..8642c8cdde 100644 --- a/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/projects/Projects.scala +++ b/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/projects/Projects.scala @@ -1,7 +1,7 @@ package ch.epfl.bluebrain.nexus.delta.sdk.projects import cats.effect.{Clock, ContextShift, IO} -import cats.syntax.all._ +import cats.implicits.{catsSyntaxFlatMapOps, catsSyntaxMonadError} import ch.epfl.bluebrain.nexus.delta.kernel.search.Pagination.FromPagination import ch.epfl.bluebrain.nexus.delta.kernel.utils.{IOInstant, UUIDF} import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri @@ -16,10 +16,10 @@ import ch.epfl.bluebrain.nexus.delta.sdk.projects.model.ProjectEvent.{ProjectCre import ch.epfl.bluebrain.nexus.delta.sdk.projects.model.ProjectRejection.{IncorrectRev, ProjectAlreadyExists, ProjectIsDeprecated, ProjectIsMarkedForDeletion, ProjectNotFound, WrappedOrganizationRejection} import ch.epfl.bluebrain.nexus.delta.sdk.projects.model._ import ch.epfl.bluebrain.nexus.delta.sdk.syntax._ -import ch.epfl.bluebrain.nexus.delta.sourcing.{ScopedEntityDefinition, StateMachine} import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.Subject import ch.epfl.bluebrain.nexus.delta.sourcing.model.{ElemStream, EntityType, Label, ProjectRef} import ch.epfl.bluebrain.nexus.delta.sourcing.offset.Offset +import ch.epfl.bluebrain.nexus.delta.sourcing.{ScopedEntityDefinition, StateMachine} import fs2.Stream trait Projects { From 8b1693d45c085582ca386a68caefa3c44877655c Mon Sep 17 00:00:00 2001 From: Daniel Bell Date: Thu, 9 Nov 2023 16:11:22 +0100 Subject: [PATCH 05/18] Migrate away from BIOSuite --- .../indexing/GraphResourceToDocumentSuite.scala | 5 ++--- .../StorageStatisticsSerializationSuite.scala | 4 ++-- .../epfl/bluebrain/nexus/delta/sourcing/MD5Suite.scala | 10 +++++----- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/indexing/GraphResourceToDocumentSuite.scala b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/indexing/GraphResourceToDocumentSuite.scala index 43848b73c3..b708066a78 100644 --- a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/indexing/GraphResourceToDocumentSuite.scala +++ b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/indexing/GraphResourceToDocumentSuite.scala @@ -10,13 +10,12 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.offset.Offset import ch.epfl.bluebrain.nexus.delta.sourcing.state.GraphResource import ch.epfl.bluebrain.nexus.delta.sourcing.stream.Elem.SuccessElem import ch.epfl.bluebrain.nexus.testkit.mu.JsonAssertions -import ch.epfl.bluebrain.nexus.testkit.mu.bio.BioSuite -import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsIOValues +import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite import io.circe.Json import java.time.Instant -class GraphResourceToDocumentSuite extends BioSuite with Fixtures with JsonAssertions with CatsIOValues { +class GraphResourceToDocumentSuite extends CatsEffectSuite with Fixtures with JsonAssertions { private val entityType = EntityType("entityType") private val project = ProjectRef.unsafe("org", "project") diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/statistics/StorageStatisticsSerializationSuite.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/statistics/StorageStatisticsSerializationSuite.scala index 9a7301724a..8090474676 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/statistics/StorageStatisticsSerializationSuite.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/statistics/StorageStatisticsSerializationSuite.scala @@ -2,9 +2,9 @@ package ch.epfl.bluebrain.nexus.delta.plugins.storage.statistics import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageStatEntry import ch.epfl.bluebrain.nexus.testkit.TestHelpers.jsonContentOf -import ch.epfl.bluebrain.nexus.testkit.mu.bio.BioSuite +import munit.FunSuite -class StorageStatisticsSerializationSuite extends BioSuite { +class StorageStatisticsSerializationSuite extends FunSuite { test("Statistics responses are deserialized correctly") { val json = jsonContentOf("storages/statistics/single-storage-stats-response.json") diff --git a/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/MD5Suite.scala b/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/MD5Suite.scala index d571f94260..45e2680564 100644 --- a/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/MD5Suite.scala +++ b/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/MD5Suite.scala @@ -1,11 +1,11 @@ package ch.epfl.bluebrain.nexus.delta.sourcing +import cats.effect.IO import cats.effect.concurrent.Ref import cats.implicits._ -import ch.epfl.bluebrain.nexus.testkit.mu.bio.BioSuite -import monix.bio.Task +import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite -class MD5Suite extends BioSuite { +class MD5Suite extends CatsEffectSuite { test("a string should have the correct MD5 hash") { val input = "bbp/atlas" @@ -16,12 +16,12 @@ class MD5Suite extends BioSuite { test("MD5 implementation should be thread safe") { val projectRef = "organization/project" - val cache = Ref.unsafe[Task, Set[String]](Set.empty) + val cache = Ref.unsafe[IO, Set[String]](Set.empty) val xs = List.fill(100)(projectRef) val task = xs.parTraverse { x => cache.get.flatMap { c => val hash = MD5.hash(x) - if (c.contains(hash)) Task.unit + if (c.contains(hash)) IO.unit else cache.update(_ + hash) } } From 7b596aad543c939a6c3b197518a1577acc1d9508 Mon Sep 17 00:00:00 2001 From: Daniel Bell Date: Thu, 9 Nov 2023 16:14:25 +0100 Subject: [PATCH 06/18] Remove most BIOValues --- .../testkit/scalatest/bio/BIOValues.scala | 82 +------------------ .../nexus/testkit/scalatest/bio/BioSpec.scala | 6 -- 2 files changed, 1 insertion(+), 87 deletions(-) delete mode 100644 delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/bio/BioSpec.scala diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/bio/BIOValues.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/bio/BIOValues.scala index 0203eadd77..bf70db1269 100644 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/bio/BIOValues.scala +++ b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/bio/BIOValues.scala @@ -1,17 +1,10 @@ package ch.epfl.bluebrain.nexus.testkit.scalatest.bio -import monix.bio.{IO, Task, UIO} +import monix.bio.Task import monix.execution.Scheduler -import org.scalactic.source -import monix.bio.Cause.{Error, Termination} -import org.scalatest.matchers.should.Matchers.fail import org.scalatest.{Assertion, Assertions, Suite} -import java.io.{ByteArrayOutputStream, PrintStream} import scala.concurrent.Future -import scala.concurrent.duration.Duration -import scala.reflect.ClassTag -import scala.util.control.NonFatal trait BIOValues extends BIOValuesLowPrio { self: Suite => @@ -25,10 +18,6 @@ trait BIOValues extends BIOValuesLowPrio { future: Future[List[Assertion]] )(implicit s: Scheduler = Scheduler.global): Future[Assertion] = future.map(_ => succeed) - - implicit final def uioValuesSyntax[A](uio: UIO[A]): UIOValuesOps[A] = new UIOValuesOps(uio) - - implicit final def ioValuesSyntax[E: ClassTag, A](io: IO[E, A]): IOValuesOps[E, A] = new IOValuesOps(io) } trait BIOValuesLowPrio extends Assertions { @@ -37,72 +26,3 @@ trait BIOValuesLowPrio extends Assertions { )(implicit s: Scheduler = Scheduler.global): Future[Assertion] = task.runToFuture.map(_ => succeed) } - -final class UIOValuesOps[A](private val uio: UIO[A]) { - - def accepted(implicit s: Scheduler = Scheduler.global): A = - uio.runSyncUnsafe() -} - -final class IOValuesOps[E, A](private val io: IO[E, A])(implicit E: ClassTag[E]) { - - def accepted(implicit pos: source.Position, s: Scheduler = Scheduler.global): A = acceptedWithTimeout(Duration.Inf) - - def acceptedWithTimeout(timeout: Duration)(implicit pos: source.Position, s: Scheduler = Scheduler.global): A = - io.attempt.runSyncUnsafe(timeout) match { - case Left(NonFatal(err)) => - val baos = new ByteArrayOutputStream() - err.printStackTrace(new PrintStream(baos)) - val stack = new String(baos.toByteArray) - fail( - s"""Error caught of type '${err.getClass.getName}', expected a successful response - |Message: ${err.getMessage} - |Stack: - |$stack""".stripMargin, - err - ) - case Left(err) => - fail( - s"""Error caught of type '${E.runtimeClass.getName}', expected a successful response - |Message: ${err.toString}""".stripMargin - ) - case Right(value) => - value - } - - def rejected(implicit pos: source.Position, s: Scheduler = Scheduler.global): E = - rejectedWith[E] - - def rejectedWith[EE <: E](implicit pos: source.Position, EE: ClassTag[EE], s: Scheduler = Scheduler.global): EE = { - io.attempt.runSyncUnsafe() match { - case Left(EE(value)) => value - case Left(value) => - fail( - s"Wrong raised error type caught, expected: '${EE.runtimeClass.getName}', actual: '${value.getClass.getName}'" - ) - case Right(value) => - fail( - s"Expected raising error, but returned successful response with type '${value.getClass.getName}'" - ) - } - } - - def terminated[T <: Throwable](implicit T: ClassTag[T]): UIO[Unit] = - io.redeemCause( - { - case Error(err) => - fail( - s"Wrong raised error type caught, expected terminal: '${T.runtimeClass.getName}', actual typed: '${err.getClass.getName}'" - ) - case Termination(T(_)) => () - case Termination(t) => - fail( - s"Wrong raised error type caught, expected terminal: '${T.runtimeClass.getName}', actual terminal: '${t.getClass.getName}'" - ) - }, - a => - fail( - s"Expected raising error, but returned successful response with type '${a.getClass.getName}'" - ) - ) -} diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/bio/BioSpec.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/bio/BioSpec.scala deleted file mode 100644 index 57cdebaa31..0000000000 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/bio/BioSpec.scala +++ /dev/null @@ -1,6 +0,0 @@ -package ch.epfl.bluebrain.nexus.testkit.scalatest.bio - -import ch.epfl.bluebrain.nexus.testkit.clock.FixedClock -import ch.epfl.bluebrain.nexus.testkit.scalatest.BaseSpec - -trait BioSpec extends BaseSpec with BIOValues with FixedClock From 538413edfcca29fc6770d476f5077bca0165831f Mon Sep 17 00:00:00 2001 From: Daniel Bell Date: Thu, 9 Nov 2023 16:16:04 +0100 Subject: [PATCH 07/18] Remove BIOValues class --- .../statistics/StoragesStatisticsSuite.scala | 3 +- .../nexus/testkit/mu/bio/BIOValues.scala | 59 ------------------- .../nexus/testkit/mu/bio/BioSuite.scala | 1 - 3 files changed, 1 insertion(+), 62 deletions(-) delete mode 100644 delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BIOValues.scala diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/statistics/StoragesStatisticsSuite.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/statistics/StoragesStatisticsSuite.scala index 445c96ef50..f9fd047513 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/statistics/StoragesStatisticsSuite.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/statistics/StoragesStatisticsSuite.scala @@ -14,7 +14,7 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.stream.SupervisorSetup import ch.epfl.bluebrain.nexus.delta.sourcing.stream.SupervisorSetup.unapply import ch.epfl.bluebrain.nexus.testkit.TestHelpers import ch.epfl.bluebrain.nexus.testkit.bio.BioRunContext -import ch.epfl.bluebrain.nexus.testkit.mu.bio.{BIOValues, PatienceConfig} +import ch.epfl.bluebrain.nexus.testkit.mu.bio.PatienceConfig import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite import munit.AnyFixture @@ -24,7 +24,6 @@ class StoragesStatisticsSuite extends CatsEffectSuite with BioRunContext with ElasticSearchClientSetup.Fixture - with BIOValues with SupervisorSetup.Fixture with TestHelpers with Fixtures { diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BIOValues.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BIOValues.scala deleted file mode 100644 index c68770734c..0000000000 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BIOValues.scala +++ /dev/null @@ -1,59 +0,0 @@ -package ch.epfl.bluebrain.nexus.testkit.mu.bio - -import monix.bio.IO -import monix.execution.Scheduler -import munit.Assertions.fail -import munit.{Location, Suite} - -import java.io.{ByteArrayOutputStream, PrintStream} -import scala.concurrent.duration.Duration -import scala.reflect.ClassTag -import scala.util.control.NonFatal - -trait BIOValues { - self: Suite => - - implicit class IOValuesOps[E, A](private val io: IO[E, A])(implicit E: ClassTag[E]) { - - def accepted(implicit loc: Location, s: Scheduler = Scheduler.global): A = acceptedWithTimeout(Duration.Inf) - - def acceptedWithTimeout(timeout: Duration)(implicit loc: Location, s: Scheduler = Scheduler.global): A = - io.attempt.runSyncUnsafe(timeout) match { - case Left(NonFatal(err)) => - val baos = new ByteArrayOutputStream() - err.printStackTrace(new PrintStream(baos)) - val stack = new String(baos.toByteArray) - fail( - s"""Error caught of type '${err.getClass.getName}', expected a successful response - |Message: ${err.getMessage} - |Stack: - |$stack""".stripMargin, - err - ) - case Left(err) => - fail( - s"""Error caught of type '${E.runtimeClass.getName}', expected a successful response - |Message: ${err.toString}""".stripMargin - ) - case Right(value) => - value - } - - def rejected(implicit loc: Location, s: Scheduler = Scheduler.global): E = - rejectedWith[E] - - def rejectedWith[EE <: E](implicit loc: Location, EE: ClassTag[EE], s: Scheduler = Scheduler.global): EE = { - io.attempt.runSyncUnsafe() match { - case Left(EE(value)) => value - case Left(value) => - fail( - s"Wrong raised error type caught, expected: '${EE.runtimeClass.getName}', actual: '${value.getClass.getName}'" - ) - case Right(value) => - fail( - s"Expected raising error, but returned successful response with type '${value.getClass.getName}'" - ) - } - } - } -} diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BioSuite.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BioSuite.scala index 37d9786eaa..bc341c25b4 100644 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BioSuite.scala +++ b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BioSuite.scala @@ -12,7 +12,6 @@ abstract class BioSuite extends NexusSuite with BioRunContext with BioAssertions - with BIOValues with CatsIOValues with CollectionAssertions with EitherAssertions From 9239905ed98865c31c609966057e4e23dc0c24f7 Mon Sep 17 00:00:00 2001 From: Daniel Bell Date: Thu, 9 Nov 2023 16:18:19 +0100 Subject: [PATCH 08/18] Remove unused BioAssertions --- .../nexus/testkit/mu/bio/BioAssertions.scala | 70 ------------------- 1 file changed, 70 deletions(-) diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BioAssertions.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BioAssertions.scala index d604bd8d66..de1f1a74c7 100644 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BioAssertions.scala +++ b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BioAssertions.scala @@ -5,45 +5,11 @@ import monix.bio.{IO, UIO} import munit.{Assertions, Location} import java.io.{ByteArrayOutputStream, PrintStream} -import scala.concurrent.duration.FiniteDuration import scala.reflect.ClassTag import scala.util.control.NonFatal trait BioAssertions { self: Assertions => - def assertUIO[A](io: UIO[A], cond: A => Boolean, clue: => Any = "assertion failed")(implicit - loc: Location - ): UIO[Unit] = { - io.map(result => assert(cond(result), clue)) - } - - def assertEqualsIO[E, A, B]( - obtained: IO[E, A], - returns: B, - clue: => Any = "values are not the same" - )(implicit loc: Location, ev: B <:< A): IO[E, Unit] = - obtained.flatMap(a => UIO(assertEquals(a, returns, clue))) - - def assertError[E, A](obtained: IO[E, A], condition: E => Boolean, clue: E => Any = (_: E) => "assertion failed")( - implicit loc: Location - ): IO[E, Unit] = { - obtained.attempt.map { - case Left(err) => Assertions.assert(condition(err), clue(err)) - case Right(a) => - fail( - s"Expected a raised error, but returned successful response: $a" - ) - } - } - - implicit class UioAssertionsOps[A](uio: UIO[A])(implicit loc: Location) { - def assert(expected: A, clue: Any = "values are not the same"): UIO[Unit] = - uio.map(assertEquals(_, expected, clue)) - - def assert(expected: A, timeout: FiniteDuration): UIO[Unit] = - uio.timeout(timeout).assertSome(expected) - } - implicit class IoAssertionsOps[E, A](io: IO[E, A])(implicit E: ClassTag[E], loc: Location) { private def exceptionHandler(err: Throwable) = { @@ -73,23 +39,6 @@ trait BioAssertions { self: Assertions => a => assertEquals(a, expected, clue) ) - def assert(expected: A, timeout: FiniteDuration): UIO[Unit] = - io.timeout(timeout).assertSome(expected) - - def assertError(condition: E => Boolean, clue: => Any = "assertion failed")(implicit loc: Location): UIO[Unit] = { - io.attempt.map { - case Left(E(err)) => Assertions.assert(condition(err), clue) - case Left(err) => - fail( - s"Wrong raised error type caught, expected: '${E.runtimeClass.getName}', actual: '${err.getClass.getName}'" - ) - case Right(a) => - fail( - s"Expected a raised error, but returned successful response: $a" - ) - } - } - def error(expected: E): UIO[Unit] = io.attempt.map { case Left(E(err)) => assertEquals(err, expected) case Left(err) => @@ -102,25 +51,6 @@ trait BioAssertions { self: Assertions => ) } - def terminated[T <: Throwable](implicit T: ClassTag[T]): UIO[Unit] = - io.redeemCause( - { - case Error(err) => - fail( - s"Wrong raised error type caught, expected terminal: '${T.runtimeClass.getName}', actual typed: '${err.getClass.getName}'" - ) - case Termination(T(_)) => () - case Termination(t) => - fail( - s"Wrong raised error type caught, expected terminal: '${T.runtimeClass.getName}', actual terminal: '${t.getClass.getName}'" - ) - }, - a => - fail( - s"Expected raising error, but returned successful response with type '${a.getClass.getName}'" - ) - ) - def terminated[T <: Throwable](expectedMessage: String)(implicit T: ClassTag[T]): UIO[Unit] = io.redeemCause( { From 9a65797e107750113a9ed7baf9e016d70efb1a4d Mon Sep 17 00:00:00 2001 From: Daniel Bell Date: Thu, 9 Nov 2023 16:51:00 +0100 Subject: [PATCH 09/18] Remove some MigrateEffectSyntax --- .../nexus/delta/routes/UserPermissionsRoutes.scala | 4 +--- .../effect/migration/MigrateEffectSyntax.scala | 13 ------------- .../nexus/delta/kernel/syntax/IOSyntax.scala | 3 +-- .../delta/plugins/blazegraph/BlazegraphViews.scala | 3 +-- .../plugins/blazegraph/BlazegraphViewsQuery.scala | 3 +-- .../plugins/compositeviews/client/DeltaClient.scala | 6 ++---- .../remote/client/RemoteDiskStorageClient.scala | 3 +-- .../nexus/delta/sdk/auth/OpenIdAuthService.scala | 3 +-- 8 files changed, 8 insertions(+), 30 deletions(-) diff --git a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/UserPermissionsRoutes.scala b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/UserPermissionsRoutes.scala index 3eb2367b7d..69c3bb25bb 100644 --- a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/UserPermissionsRoutes.scala +++ b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/UserPermissionsRoutes.scala @@ -3,7 +3,6 @@ package ch.epfl.bluebrain.nexus.delta.routes import akka.http.scaladsl.model.StatusCodes import akka.http.scaladsl.server.Directives._ import akka.http.scaladsl.server.Route -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration.MigrateEffectSyntax import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclCheck import ch.epfl.bluebrain.nexus.delta.sdk.acls.model.AclAddress import ch.epfl.bluebrain.nexus.delta.sdk.circe.CirceUnmarshalling @@ -26,8 +25,7 @@ import ch.epfl.bluebrain.nexus.delta.sdk.permissions.model.Permission final class UserPermissionsRoutes(identities: Identities, aclCheck: AclCheck, storages: StoragePermissionProvider)( implicit baseUri: BaseUri ) extends AuthDirectives(identities, aclCheck) - with CirceUnmarshalling - with MigrateEffectSyntax { + with CirceUnmarshalling { def routes: Route = baseUriPrefix(baseUri.prefix) { diff --git a/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/effect/migration/MigrateEffectSyntax.scala b/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/effect/migration/MigrateEffectSyntax.scala index 486d12813c..e2e733eb55 100644 --- a/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/effect/migration/MigrateEffectSyntax.scala +++ b/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/effect/migration/MigrateEffectSyntax.scala @@ -1,7 +1,6 @@ package ch.epfl.bluebrain.nexus.delta.kernel.effect.migration import cats.effect.IO -import cats.~> import monix.bio.{IO => BIO, Task, UIO} import monix.execution.Scheduler.Implicits.global import shapeless.=:!= @@ -15,27 +14,15 @@ trait MigrateEffectSyntax { implicit def toCatsIO[E <: Throwable, A](io: BIO[E, A]): IO[A] = io.to[IO] implicit def uioToCatsIO[E <: Throwable, A](io: UIO[A]): IO[A] = io.to[IO] implicit def toCatsIOOps[E <: Throwable, A](io: BIO[E, A]): MonixBioToCatsIOOps[E, A] = new MonixBioToCatsIOOps(io) - implicit def toCatsIOEitherOps[E, A](io: BIO[E, A]): MonixBioToCatsIOEitherOps[E, A] = new MonixBioToCatsIOEitherOps( - io - ) implicit def toMonixBIOOps[A](io: IO[A]): CatsIOToBioOps[A] = new CatsIOToBioOps(io) - val taskToIoK: Task ~> IO = λ[Task ~> IO](toCatsIO(_)) - val uioToIoK: UIO ~> IO = λ[UIO ~> IO](uioToCatsIO(_)) - val ioToUioK: IO ~> UIO = λ[IO ~> UIO](_.toUIO) - val ioToTaskK: IO ~> Task = λ[IO ~> Task](Task.from(_)) - } final class MonixBioToCatsIOOps[E <: Throwable, A](private val io: BIO[E, A]) extends AnyVal { def toCatsIO: IO[A] = io.to[IO] } -final class MonixBioToCatsIOEitherOps[E, A](private val io: BIO[E, A]) extends AnyVal { - def toCatsIOEither: IO[Either[E, A]] = io.attempt.to[IO] -} - final class CatsIOToBioOps[A](private val io: IO[A]) extends AnyVal { /** diff --git a/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/syntax/IOSyntax.scala b/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/syntax/IOSyntax.scala index 90dc067585..3c2b68565c 100644 --- a/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/syntax/IOSyntax.scala +++ b/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/syntax/IOSyntax.scala @@ -4,7 +4,6 @@ import cats.effect.{IO, Timer} import cats.implicits.catsSyntaxApplicativeError import cats.syntax.functor._ import ch.epfl.bluebrain.nexus.delta.kernel.RetryStrategy -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import com.typesafe.scalalogging.Logger import monix.bio.{Task, UIO} import org.typelevel.log4cats.{Logger => Log4CatsLogger} @@ -29,7 +28,7 @@ final class IORetryStrategyOps[A](private val io: IO[A]) extends AnyVal { * Apply the retry strategy on the provided IO */ def retry[E <: Throwable](retryStrategy: RetryStrategy[E])(implicit E: ClassTag[E], timer: Timer[IO]): IO[A] = - RetryStrategy.use(io.toBIO[E], retryStrategy) + RetryStrategy.use(io, retryStrategy) } diff --git a/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphViews.scala b/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphViews.scala index 2397650b70..f3432435ba 100644 --- a/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphViews.scala +++ b/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphViews.scala @@ -2,7 +2,6 @@ package ch.epfl.bluebrain.nexus.delta.plugins.blazegraph import cats.effect.{Clock, ContextShift, IO, Timer} import cats.syntax.all._ -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.kernel.kamon.KamonMetricComponent import ch.epfl.bluebrain.nexus.delta.kernel.utils.{IOInstant, UUIDF} import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.BlazegraphViews._ @@ -492,7 +491,7 @@ object BlazegraphViews { entityType, StateMachine( None, - evaluate(validate)(_, _).toBIO[BlazegraphViewRejection], + evaluate(validate)(_, _), next ), BlazegraphViewEvent.serializer, diff --git a/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphViewsQuery.scala b/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphViewsQuery.scala index 1d36c8bd38..95d5f3b917 100644 --- a/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphViewsQuery.scala +++ b/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphViewsQuery.scala @@ -2,7 +2,6 @@ package ch.epfl.bluebrain.nexus.delta.plugins.blazegraph import cats.effect.IO import cats.syntax.all._ -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.kernel.search.Pagination.FromPagination import ch.epfl.bluebrain.nexus.delta.kernel.utils.ClasspathResourceUtils.ioContentOf import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.client.SparqlQueryResponseType.{Aux, SparqlResultsJson} @@ -109,7 +108,7 @@ object BlazegraphViewsQuery { outgoingScopedQuery <- ioContentOf("blazegraph/outgoing_scoped.txt") viewsStore = ViewsStore[BlazegraphViewRejection, BlazegraphViewState]( BlazegraphViewState.serializer, - views.fetchState(_, _).toBIO[BlazegraphViewRejection], + views.fetchState(_, _), view => IO.raiseWhen(view.deprecated)(ViewIsDeprecated(view.id)) .as { diff --git a/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/client/DeltaClient.scala b/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/client/DeltaClient.scala index 4f17f6a383..eec96c5b00 100644 --- a/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/client/DeltaClient.scala +++ b/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/client/DeltaClient.scala @@ -4,12 +4,11 @@ import akka.actor.typed.ActorSystem import akka.http.scaladsl.client.RequestBuilding.{Get, Head} import akka.http.scaladsl.model.ContentTypes.`application/json` import akka.http.scaladsl.model.Uri.Query -import akka.http.scaladsl.model.headers.{`Last-Event-ID`, Accept} +import akka.http.scaladsl.model.headers.{Accept, `Last-Event-ID`} import akka.http.scaladsl.model.{HttpRequest, HttpResponse, StatusCodes} import akka.stream.alpakka.sse.scaladsl.EventSource import cats.effect.{ContextShift, IO} import cats.implicits.{catsSyntaxApplicativeError, catsSyntaxFlatMapOps} -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration.MigrateEffectSyntax import ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.model.CompositeViewSource.RemoteProjectSource import ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.stream.CompositeBranch import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri @@ -87,8 +86,7 @@ object DeltaClient { )(implicit as: ActorSystem[Nothing], c: ContextShift[IO] - ) extends DeltaClient - with MigrateEffectSyntax { + ) extends DeltaClient { override def projectStatistics(source: RemoteProjectSource): IO[ProjectStatistics] = { for { diff --git a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/client/RemoteDiskStorageClient.scala b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/client/RemoteDiskStorageClient.scala index 05f9cc2007..1a5b91f284 100644 --- a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/client/RemoteDiskStorageClient.scala +++ b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/client/RemoteDiskStorageClient.scala @@ -9,7 +9,6 @@ import akka.http.scaladsl.model.StatusCodes._ import akka.http.scaladsl.model.Uri.Path import cats.effect.{ContextShift, IO, Timer} import cats.implicits.{catsSyntaxApplicativeError, catsSyntaxMonadError, toFunctorOps} -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration.MigrateEffectSyntax import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.StorageFileRejection.FetchFileRejection.UnexpectedFetchError import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.StorageFileRejection.MoveFileRejection.UnexpectedMoveError import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.StorageFileRejection.{FetchFileRejection, MoveFileRejection, SaveFileRejection} @@ -39,7 +38,7 @@ final class RemoteDiskStorageClient(client: HttpClient, getAuthToken: AuthTokenP as: ActorSystem, cs: ContextShift[IO], timer: Timer[IO] -) extends MigrateEffectSyntax { +) { import as.dispatcher private val serviceName = Name.unsafe("remoteStorage") diff --git a/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/auth/OpenIdAuthService.scala b/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/auth/OpenIdAuthService.scala index 18888dd4fe..968100b735 100644 --- a/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/auth/OpenIdAuthService.scala +++ b/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/auth/OpenIdAuthService.scala @@ -7,7 +7,6 @@ import akka.http.scaladsl.model.{HttpRequest, Uri} import cats.effect.IO import cats.implicits.catsSyntaxMonadError import ch.epfl.bluebrain.nexus.delta.kernel.Secret -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration.MigrateEffectSyntax import ch.epfl.bluebrain.nexus.delta.kernel.jwt.{AuthToken, ParsedToken} import ch.epfl.bluebrain.nexus.delta.sdk.auth.Credentials.ClientCredentials import ch.epfl.bluebrain.nexus.delta.sdk.error.AuthTokenError.{AuthTokenHttpError, AuthTokenNotFoundInResponse, RealmIsDeprecated} @@ -20,7 +19,7 @@ import io.circe.Json /** * Exchanges client credentials for an auth token with a remote OpenId service, as defined in the specified realm */ -class OpenIdAuthService(httpClient: HttpClient, realms: Realms) extends MigrateEffectSyntax { +class OpenIdAuthService(httpClient: HttpClient, realms: Realms) { /** * Exchanges client credentials for an auth token with a remote OpenId service, as defined in the specified realm From ace11462992332f916d3c750b4405af9a84939eb Mon Sep 17 00:00:00 2001 From: Daniel Bell Date: Thu, 9 Nov 2023 17:07:19 +0100 Subject: [PATCH 10/18] Migrated classpath utils --- .../nexus/delta/config/AppConfigSpec.scala | 4 +- .../CatsEffectsClasspathResourceUtils.scala | 125 ------------------ .../kernel/utils/ClasspathResourceUtils.scala | 39 ------ .../blazegraph/BlazegraphPluginModule.scala | 4 +- .../delta/plugins/blazegraph/Fixtures.scala | 4 +- .../compositeviews/client/DeltaClient.scala | 2 +- .../MigrateCompositeViewsSuite.scala | 6 +- .../model/ElasticSearchFiles.scala | 4 +- .../indexing/GraphAnalyticsView.scala | 29 ---- .../graph/analytics/indexing/package.scala | 8 +- .../indexing/GraphAnalyticsSinkSuite.scala | 22 ++- .../rdf/jsonld/context/ContextValue.scala | 4 +- .../delta/rdf/shacl/ShaclShapesGraph.scala | 2 +- .../bluebrain/nexus/testkit/TestHelpers.scala | 22 +-- 14 files changed, 29 insertions(+), 246 deletions(-) delete mode 100644 delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/utils/CatsEffectsClasspathResourceUtils.scala delete mode 100644 delta/plugins/graph-analytics/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/GraphAnalyticsView.scala diff --git a/delta/app/src/test/scala/ch/epfl/bluebrain/nexus/delta/config/AppConfigSpec.scala b/delta/app/src/test/scala/ch/epfl/bluebrain/nexus/delta/config/AppConfigSpec.scala index cc8c247841..60e4314b5f 100644 --- a/delta/app/src/test/scala/ch/epfl/bluebrain/nexus/delta/config/AppConfigSpec.scala +++ b/delta/app/src/test/scala/ch/epfl/bluebrain/nexus/delta/config/AppConfigSpec.scala @@ -1,6 +1,6 @@ package ch.epfl.bluebrain.nexus.delta.config -import ch.epfl.bluebrain.nexus.delta.kernel.utils.CatsEffectsClasspathResourceUtils +import ch.epfl.bluebrain.nexus.delta.kernel.utils.ClasspathResourceUtils import ch.epfl.bluebrain.nexus.testkit.scalatest.ce.CatsEffectSpec import com.typesafe.config.impl.ConfigImpl import org.scalatest.BeforeAndAfterAll @@ -26,7 +26,7 @@ class AppConfigSpec extends CatsEffectSpec with BeforeAndAfterAll { "AppConfig" should { - val externalConfigPath = CatsEffectsClasspathResourceUtils.absolutePath("/config/external.conf").accepted + val externalConfigPath = ClasspathResourceUtils.absolutePath("/config/external.conf").accepted "load conf" in { val (conf, _) = AppConfig.load().accepted diff --git a/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/utils/CatsEffectsClasspathResourceUtils.scala b/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/utils/CatsEffectsClasspathResourceUtils.scala deleted file mode 100644 index 199db4460f..0000000000 --- a/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/utils/CatsEffectsClasspathResourceUtils.scala +++ /dev/null @@ -1,125 +0,0 @@ -package ch.epfl.bluebrain.nexus.delta.kernel.utils - -import cats.effect.IO -import cats.syntax.all._ -import ch.epfl.bluebrain.nexus.delta.kernel.utils.CatsEffectsClasspathResourceUtilsStatic.handleBars -import ch.epfl.bluebrain.nexus.delta.kernel.utils.ClasspathResourceError.{InvalidJson, InvalidJsonObject, ResourcePathNotFound} -import com.github.jknack.handlebars.{EscapingStrategy, Handlebars} -import io.circe.parser.parse -import io.circe.{Json, JsonObject} - -import java.io.InputStream -import java.util.Properties -import scala.io.{Codec, Source} -import scala.jdk.CollectionConverters._ - -trait CatsEffectsClasspathResourceUtils { - - final def absolutePath(resourcePath: String)(implicit classLoader: ClassLoader): IO[String] = { - val fromResourceOrClassLoader = - Option(getClass.getResource(resourcePath)) orElse Option(classLoader.getResource(resourcePath)) - IO.fromOption(fromResourceOrClassLoader)(ResourcePathNotFound(resourcePath)).map(_.getPath) - } - - /** - * Loads the content of the argument classpath resource as an [[InputStream]]. - * - * @param resourcePath - * the path of a resource available on the classpath - * @return - * the content of the referenced resource as an [[InputStream]] or a [[ClasspathResourceError]] when the resource - * is not found - */ - def ioStreamOf(resourcePath: String)(implicit classLoader: ClassLoader): IO[InputStream] = - IO.defer { - lazy val fromClass = Option(getClass.getResourceAsStream(resourcePath)) - val fromClassLoader = Option(classLoader.getResourceAsStream(resourcePath)) - IO.fromOption(fromClass orElse fromClassLoader)(ResourcePathNotFound(resourcePath)) - } - - /** - * Loads the content of the argument classpath resource as a string and replaces all the key matches of the - * ''replacements'' with their values. - * - * @param resourcePath - * the path of a resource available on the classpath - * @return - * the content of the referenced resource as a string or a [[ClasspathResourceError]] when the resource is not - * found - */ - final def ioContentOf( - resourcePath: String, - attributes: (String, Any)* - )(implicit classLoader: ClassLoader): IO[String] = - resourceAsTextFrom(resourcePath).map { - case text if attributes.isEmpty => text - case text => handleBars.compileInline(text).apply(attributes.toMap.asJava) - } - - /** - * Loads the content of the argument classpath resource as a java Properties and transforms it into a Map of key - * property and property value. - * - * @param resourcePath - * the path of a resource available on the classpath - * @return - * the content of the referenced resource as a map of properties or a [[ClasspathResourceError]] when the resource - * is not found - */ - final def ioPropertiesOf(resourcePath: String)(implicit - classLoader: ClassLoader - ): IO[Map[String, String]] = - ioStreamOf(resourcePath).map { is => - val props = new Properties() - props.load(is) - props.asScala.toMap - } - - /** - * Loads the content of the argument classpath resource as a string and replaces all the key matches of the - * ''replacements'' with their values. The resulting string is parsed into a json value. - * - * @param resourcePath - * the path of a resource available on the classpath - * @return - * the content of the referenced resource as a json value or an [[ClasspathResourceError]] when the resource is not - * found or is not a Json - */ - final def ioJsonContentOf( - resourcePath: String, - attributes: (String, Any)* - )(implicit classLoader: ClassLoader): IO[Json] = - for { - text <- ioContentOf(resourcePath, attributes: _*) - json <- IO.fromEither(parse(text).leftMap(InvalidJson(resourcePath, text, _))) - } yield json - - /** - * Loads the content of the argument classpath resource as a string and replaces all the key matches of the - * ''replacements'' with their values. The resulting string is parsed into a json object. - * - * @param resourcePath - * the path of a resource available on the classpath - * @return - * the content of the referenced resource as a json value or an [[ClasspathResourceError]] when the resource is not - * found or is not a Json - */ - final def ioJsonObjectContentOf(resourcePath: String, attributes: (String, Any)*)(implicit - classLoader: ClassLoader - ): IO[JsonObject] = - for { - json <- ioJsonContentOf(resourcePath, attributes: _*) - jsonObj <- IO.fromOption(json.asObject)(InvalidJsonObject(resourcePath)) - } yield jsonObj - - private def resourceAsTextFrom(resourcePath: String)(implicit - classLoader: ClassLoader - ): IO[String] = - ioStreamOf(resourcePath).map(is => Source.fromInputStream(is)(Codec.UTF8).mkString) -} - -object CatsEffectsClasspathResourceUtilsStatic { - private[utils] val handleBars = new Handlebars().`with`(EscapingStrategy.NOOP) -} - -object CatsEffectsClasspathResourceUtils extends CatsEffectsClasspathResourceUtils diff --git a/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/utils/ClasspathResourceUtils.scala b/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/utils/ClasspathResourceUtils.scala index 3ee2eefc20..1afa5eea58 100644 --- a/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/utils/ClasspathResourceUtils.scala +++ b/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/utils/ClasspathResourceUtils.scala @@ -6,7 +6,6 @@ import ch.epfl.bluebrain.nexus.delta.kernel.utils.ClasspathResourceError.{Invali import com.github.jknack.handlebars.{EscapingStrategy, Handlebars} import io.circe.parser.parse import io.circe.{Json, JsonObject} -import monix.bio.{IO => BIO} import java.io.InputStream import java.util.Properties @@ -29,13 +28,6 @@ trait ClasspathResourceUtils { * the content of the referenced resource as an [[InputStream]] or a [[ClasspathResourceError]] when the resource * is not found */ - def bioStreamOf(resourcePath: String)(implicit classLoader: ClassLoader): BIO[ClasspathResourceError, InputStream] = - BIO.deferAction { _ => - lazy val fromClass = Option(getClass.getResourceAsStream(resourcePath)) - val fromClassLoader = Option(classLoader.getResourceAsStream(resourcePath)) - BIO.fromOption(fromClass orElse fromClassLoader, ResourcePathNotFound(resourcePath)) - } - def ioStreamOf(resourcePath: String)(implicit classLoader: ClassLoader): IO[InputStream] = IO.defer { lazy val fromClass = Option(getClass.getResourceAsStream(resourcePath)) @@ -53,15 +45,6 @@ trait ClasspathResourceUtils { * the content of the referenced resource as a string or a [[ClasspathResourceError]] when the resource is not * found */ - final def bioContentOf( - resourcePath: String, - attributes: (String, Any)* - )(implicit classLoader: ClassLoader): BIO[ClasspathResourceError, String] = - bioResourceAsTextFrom(resourcePath).map { - case text if attributes.isEmpty => text - case text => handleBars.compileInline(text).apply(attributes.toMap.asJava) - } - final def ioContentOf( resourcePath: String, attributes: (String, Any)* @@ -100,15 +83,6 @@ trait ClasspathResourceUtils { * the content of the referenced resource as a json value or an [[ClasspathResourceError]] when the resource is not * found or is not a Json */ - final def bioJsonContentOf( - resourcePath: String, - attributes: (String, Any)* - )(implicit classLoader: ClassLoader): BIO[ClasspathResourceError, Json] = - for { - text <- bioContentOf(resourcePath, attributes: _*) - json <- BIO.fromEither(parse(text)).mapError(InvalidJson(resourcePath, text, _)) - } yield json - final def ioJsonContentOf( resourcePath: String, attributes: (String, Any)* @@ -136,19 +110,6 @@ trait ClasspathResourceUtils { jsonObj <- IO.fromOption(json.asObject)(InvalidJsonObject(resourcePath)) } yield jsonObj - final def bioJsonObjectContentOf(resourcePath: String, attributes: (String, Any)*)(implicit - classLoader: ClassLoader - ): BIO[ClasspathResourceError, JsonObject] = - for { - json <- bioJsonContentOf(resourcePath, attributes: _*) - jsonObj <- BIO.fromOption(json.asObject, InvalidJsonObject(resourcePath)) - } yield jsonObj - - private def bioResourceAsTextFrom(resourcePath: String)(implicit - classLoader: ClassLoader - ): BIO[ClasspathResourceError, String] = - bioStreamOf(resourcePath).map(is => Source.fromInputStream(is)(Codec.UTF8).mkString) - private def resourceAsTextFrom(resourcePath: String)(implicit classLoader: ClassLoader ): IO[String] = diff --git a/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphPluginModule.scala b/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphPluginModule.scala index ffe2b1d32a..0a3c3ffe6f 100644 --- a/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphPluginModule.scala +++ b/delta/plugins/blazegraph/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphPluginModule.scala @@ -2,7 +2,7 @@ package ch.epfl.bluebrain.nexus.delta.plugins.blazegraph import akka.actor.typed.ActorSystem import cats.effect.{Clock, ContextShift, IO, Timer} -import ch.epfl.bluebrain.nexus.delta.kernel.utils.{CatsEffectsClasspathResourceUtils, UUIDF} +import ch.epfl.bluebrain.nexus.delta.kernel.utils.{ClasspathResourceUtils, UUIDF} import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.client.BlazegraphClient import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.config.BlazegraphViewsConfig import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.indexing.BlazegraphCoordinator @@ -47,7 +47,7 @@ class BlazegraphPluginModule(priority: Int) extends ModuleDef { make[BlazegraphViewsConfig].from { BlazegraphViewsConfig.load(_) } make[DefaultProperties].fromEffect { - CatsEffectsClasspathResourceUtils.ioPropertiesOf("blazegraph/index.properties").map(DefaultProperties) + ClasspathResourceUtils.ioPropertiesOf("blazegraph/index.properties").map(DefaultProperties) } make[HttpClient].named("http-indexing-client").from { diff --git a/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/Fixtures.scala b/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/Fixtures.scala index 717ca65a97..83f35e2c5c 100644 --- a/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/Fixtures.scala +++ b/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/Fixtures.scala @@ -1,7 +1,7 @@ package ch.epfl.bluebrain.nexus.delta.plugins.blazegraph import cats.effect.IO -import ch.epfl.bluebrain.nexus.delta.kernel.utils.CatsEffectsClasspathResourceUtils +import ch.epfl.bluebrain.nexus.delta.kernel.utils.ClasspathResourceUtils import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.model.BlazegraphViewValue import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.model.contexts.{blazegraph, blazegraphMetadata} import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary @@ -26,7 +26,7 @@ trait Fixtures { ) val defaultProperties: Map[String, String] = - CatsEffectsClasspathResourceUtils.ioPropertiesOf("blazegraph/index.properties").unsafeRunSync() + ClasspathResourceUtils.ioPropertiesOf("blazegraph/index.properties").unsafeRunSync() def alwaysValidate: ValidateBlazegraphView = (_: BlazegraphViewValue) => IO.unit } diff --git a/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/client/DeltaClient.scala b/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/client/DeltaClient.scala index eec96c5b00..186301b8b1 100644 --- a/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/client/DeltaClient.scala +++ b/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/client/DeltaClient.scala @@ -4,7 +4,7 @@ import akka.actor.typed.ActorSystem import akka.http.scaladsl.client.RequestBuilding.{Get, Head} import akka.http.scaladsl.model.ContentTypes.`application/json` import akka.http.scaladsl.model.Uri.Query -import akka.http.scaladsl.model.headers.{Accept, `Last-Event-ID`} +import akka.http.scaladsl.model.headers.{`Last-Event-ID`, Accept} import akka.http.scaladsl.model.{HttpRequest, HttpResponse, StatusCodes} import akka.stream.alpakka.sse.scaladsl.EventSource import cats.effect.{ContextShift, IO} diff --git a/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/migration/MigrateCompositeViewsSuite.scala b/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/migration/MigrateCompositeViewsSuite.scala index 2f2c037857..c4b886dee3 100644 --- a/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/migration/MigrateCompositeViewsSuite.scala +++ b/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/migration/MigrateCompositeViewsSuite.scala @@ -2,7 +2,7 @@ package ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.migration import cats.effect.IO import cats.syntax.all._ -import ch.epfl.bluebrain.nexus.delta.kernel.utils.CatsEffectsClasspathResourceUtils +import ch.epfl.bluebrain.nexus.delta.kernel.utils.ClasspathResourceUtils import ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.CompositeViews import ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.migration.MigrateCompositeViews.{eventsToMigrate, statesToMigrate} import ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.migration.MigrateCompositeViewsSuite.{loadEvent, loadState} @@ -24,7 +24,7 @@ import io.circe.JsonObject import java.time.Instant -class MigrateCompositeViewsSuite extends CatsEffectSuite with Doobie.Fixture with CatsEffectsClasspathResourceUtils { +class MigrateCompositeViewsSuite extends CatsEffectSuite with Doobie.Fixture with ClasspathResourceUtils { private val proj = ProjectRef.unsafe("myorg", "myproj") @@ -99,7 +99,7 @@ class MigrateCompositeViewsSuite extends CatsEffectSuite with Doobie.Fixture wit } } -object MigrateCompositeViewsSuite extends CatsEffectsClasspathResourceUtils { +object MigrateCompositeViewsSuite extends ClasspathResourceUtils { def extractIdentifiers(json: JsonObject) = IO.fromOption { for { diff --git a/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/model/ElasticSearchFiles.scala b/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/model/ElasticSearchFiles.scala index 0dac417038..e1fb6d74fa 100644 --- a/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/model/ElasticSearchFiles.scala +++ b/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/model/ElasticSearchFiles.scala @@ -1,7 +1,7 @@ package ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.model import cats.effect.IO -import ch.epfl.bluebrain.nexus.delta.kernel.utils.CatsEffectsClasspathResourceUtils +import ch.epfl.bluebrain.nexus.delta.kernel.utils.ClasspathResourceUtils import io.circe.syntax.EncoderOps import io.circe.{Json, JsonObject} @@ -35,7 +35,7 @@ object ElasticSearchFiles { implicit private val cl: ClassLoader = getClass.getClassLoader - private def fetchFile(resourcePath: String) = CatsEffectsClasspathResourceUtils.ioJsonObjectContentOf(resourcePath) + private def fetchFile(resourcePath: String) = ClasspathResourceUtils.ioJsonObjectContentOf(resourcePath) def mk(): IO[ElasticSearchFiles] = for { diff --git a/delta/plugins/graph-analytics/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/GraphAnalyticsView.scala b/delta/plugins/graph-analytics/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/GraphAnalyticsView.scala deleted file mode 100644 index fd84ced5b8..0000000000 --- a/delta/plugins/graph-analytics/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/GraphAnalyticsView.scala +++ /dev/null @@ -1,29 +0,0 @@ -package ch.epfl.bluebrain.nexus.delta.plugins.graph.analytics.indexing - -import ch.epfl.bluebrain.nexus.delta.kernel.utils.ClasspathResourceUtils.bioJsonObjectContentOf -import ch.epfl.bluebrain.nexus.delta.sdk.syntax._ -import com.typesafe.scalalogging.Logger -import io.circe.JsonObject -import monix.bio.UIO - -/** - * A graph analytics view information - * - * @param mapping - * the elasticsearch mapping to be used in order to create the graph analytics index - */ -final case class GraphAnalyticsView(mapping: JsonObject) - -object GraphAnalyticsView { - - implicit private val classLoader: ClassLoader = getClass.getClassLoader - - implicit private val logger: Logger = Logger[GraphAnalyticsView] - - private val mappings = bioJsonObjectContentOf("elasticsearch/mappings.json") - - val default: UIO[GraphAnalyticsView] = mappings - .map(GraphAnalyticsView(_)) - .logAndDiscardErrors("loading graph analytics mapping") - .memoize -} diff --git a/delta/plugins/graph-analytics/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/package.scala b/delta/plugins/graph-analytics/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/package.scala index 40c731fed7..a52b5c177b 100644 --- a/delta/plugins/graph-analytics/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/package.scala +++ b/delta/plugins/graph-analytics/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/package.scala @@ -3,8 +3,8 @@ package ch.epfl.bluebrain.nexus.delta.plugins.graph.analytics import cats.effect.IO import cats.implicits._ import ch.epfl.bluebrain.nexus.delta.kernel.Logger -import ch.epfl.bluebrain.nexus.delta.kernel.utils.CatsEffectsClasspathResourceUtils -import ch.epfl.bluebrain.nexus.delta.kernel.utils.CatsEffectsClasspathResourceUtils.ioJsonObjectContentOf +import ch.epfl.bluebrain.nexus.delta.kernel.utils.ClasspathResourceUtils +import ch.epfl.bluebrain.nexus.delta.kernel.utils.ClasspathResourceUtils.ioJsonObjectContentOf import ch.epfl.bluebrain.nexus.delta.plugins.graph.analytics.config.GraphAnalyticsConfig.TermAggregationsConfig import ch.epfl.bluebrain.nexus.delta.sdk.syntax._ import io.circe.JsonObject @@ -18,12 +18,12 @@ package object indexing { val updateRelationshipsScriptId = "updateRelationships" val scriptContent: IO[String] = - CatsEffectsClasspathResourceUtils + ClasspathResourceUtils .ioContentOf("elasticsearch/update_relationships_script.painless") .onError(e => logger.warn(e)("ElasticSearch script 'update_relationships_script.painless' template not found")) val graphAnalyticsMappings: IO[JsonObject] = - CatsEffectsClasspathResourceUtils + ClasspathResourceUtils .ioJsonObjectContentOf("elasticsearch/mappings.json") .onError(e => logger.warn(e)("ElasticSearch mapping 'mappings.json' template not found")) diff --git a/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/GraphAnalyticsSinkSuite.scala b/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/GraphAnalyticsSinkSuite.scala index b1ec3c9c20..4a3ad16cc1 100644 --- a/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/GraphAnalyticsSinkSuite.scala +++ b/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/GraphAnalyticsSinkSuite.scala @@ -70,21 +70,18 @@ class GraphAnalyticsSinkSuite // File linked by 'resource1', resolved after an update by query private val file1 = iri"http://localhost/file1" - private def loadExpanded(path: String): IO[ExpandedJsonLd] = - bioJsonContentOf(path) - .flatMap { json => - Task.fromEither(ExpandedJsonLd.expanded(json)) - } - .memoizeOnSuccess - .toCatsIO + private def loadExpanded(path: String): ExpandedJsonLd = + ioJsonContentOf(path).flatMap { json => + Task.fromEither(ExpandedJsonLd.expanded(json)) + }.accepted private def getTypes(expandedJsonLd: ExpandedJsonLd): IO[Set[Iri]] = IO.pure(expandedJsonLd.cursor.getTypes.getOrElse(Set.empty)) private val findRelationships: IO[Map[Iri, Set[Iri]]] = { for { - resource1Types <- expanded1.flatMap(getTypes) - resource2Types <- expanded2.flatMap(getTypes) + resource1Types <- getTypes(expanded1) + resource2Types <- getTypes(expanded2) } yield Map( resource1 -> resource1Types, resource2 -> resource2Types, @@ -105,11 +102,10 @@ class GraphAnalyticsSinkSuite SuccessElem(Resources.entityType, id, Some(project), Instant.EPOCH, Offset.start, result, 1) test("Push index results") { - def indexActive(id: Iri, io: IO[ExpandedJsonLd]) = { + def indexActive(id: Iri, expanded: ExpandedJsonLd) = { for { - expanded <- io - types <- getTypes(expanded) - doc <- JsonLdDocument.fromExpanded(expanded, _ => findRelationships) + types <- getTypes(expanded) + doc <- JsonLdDocument.fromExpanded(expanded, _ => findRelationships) } yield { val result = Index.active(project, id, remoteContexts, 1, types, Instant.EPOCH, Anonymous, Instant.EPOCH, Anonymous, doc) diff --git a/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/jsonld/context/ContextValue.scala b/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/jsonld/context/ContextValue.scala index 8698c603f0..9a36041fd9 100644 --- a/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/jsonld/context/ContextValue.scala +++ b/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/jsonld/context/ContextValue.scala @@ -1,7 +1,7 @@ package ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context import cats.effect.IO -import ch.epfl.bluebrain.nexus.delta.kernel.utils.CatsEffectsClasspathResourceUtils +import ch.epfl.bluebrain.nexus.delta.kernel.utils.ClasspathResourceUtils import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.contexts import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.ContextValue.{ContextObject, ContextRemoteIri} @@ -185,7 +185,7 @@ object ContextValue { * Loads a [[ContextValue]] form the passed ''resourcePath'' */ final def fromFile(resourcePath: String)(implicit cl: ClassLoader): IO[ContextValue] = - CatsEffectsClasspathResourceUtils.ioJsonContentOf(resourcePath).map(_.topContextValueOrEmpty) + ClasspathResourceUtils.ioJsonContentOf(resourcePath).map(_.topContextValueOrEmpty) /** * Constructs a [[ContextValue]] from a json. The value of the json must be the value of the @context key diff --git a/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/shacl/ShaclShapesGraph.scala b/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/shacl/ShaclShapesGraph.scala index 08dea068c0..bcf7d7618d 100644 --- a/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/shacl/ShaclShapesGraph.scala +++ b/delta/rdf/src/main/scala/ch/epfl/bluebrain/nexus/delta/rdf/shacl/ShaclShapesGraph.scala @@ -1,7 +1,7 @@ package ch.epfl.bluebrain.nexus.delta.rdf.shacl import cats.effect.IO -import ch.epfl.bluebrain.nexus.delta.kernel.utils.CatsEffectsClasspathResourceUtils.ioStreamOf +import ch.epfl.bluebrain.nexus.delta.kernel.utils.ClasspathResourceUtils.ioStreamOf import ch.epfl.bluebrain.nexus.delta.rdf.graph.Graph import org.apache.jena.graph.Factory.createDefaultGraph import org.apache.jena.query.DatasetFactory diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/TestHelpers.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/TestHelpers.scala index a558acc8cb..6edd7fa1da 100644 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/TestHelpers.scala +++ b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/TestHelpers.scala @@ -1,12 +1,9 @@ package ch.epfl.bluebrain.nexus.testkit import cats.effect.IO -import ch.epfl.bluebrain.nexus.delta.kernel.utils.{ClasspathResourceError, ClasspathResourceUtils} +import ch.epfl.bluebrain.nexus.delta.kernel.utils.ClasspathResourceUtils import io.circe.{Json, JsonObject} -import monix.bio.{IO => BIO} -import monix.execution.Scheduler -import java.io.InputStream import scala.annotation.tailrec import scala.util.Random @@ -35,17 +32,6 @@ trait TestHelpers extends ClasspathResourceUtils { inner("", length) } - /** - * Loads the content of the argument classpath resource as an [[InputStream]]. - * - * @param resourcePath - * the path of a resource available on the classpath - * @return - * the content of the referenced resource as an [[InputStream]] - */ - final def streamOf(resourcePath: String)(implicit s: Scheduler = Scheduler.global): InputStream = - bioRunAcceptOrThrow(bioStreamOf(resourcePath)) - /** * Loads the content of the argument classpath resource as a string and replaces all the key matches of the * ''replacements'' with their values. @@ -103,12 +89,6 @@ trait TestHelpers extends ClasspathResourceUtils { final def propertiesOf(resourcePath: String): Map[String, String] = runAcceptOrThrow(ioPropertiesOf(resourcePath)) - private def bioRunAcceptOrThrow[A](io: BIO[ClasspathResourceError, A])(implicit s: Scheduler): A = - io.attempt.runSyncUnsafe() match { - case Left(value) => throw new IllegalArgumentException(value.toString) - case Right(value) => value - } - private def runAcceptOrThrow[A](io: IO[A]): A = io.attempt.unsafeRunSync() match { case Left(value) => throw new IllegalArgumentException(value.toString) From 94abebffa2129cce0039e1986a32bdfb10f54be2 Mon Sep 17 00:00:00 2001 From: Daniel Bell Date: Thu, 9 Nov 2023 17:13:19 +0100 Subject: [PATCH 11/18] Remove MigrateEffectSyntax :party: --- .../migration/MigrateEffectSyntax.scala | 49 ------------------- .../kernel/effect/migration/package.scala | 3 -- .../routes/BlazegraphViewRoutesFixtures.scala | 8 +-- .../indexing/GraphAnalyticsSinkSuite.scala | 4 +- .../sdk/stream/GraphResourceStream.scala | 3 +- 5 files changed, 4 insertions(+), 63 deletions(-) delete mode 100644 delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/effect/migration/MigrateEffectSyntax.scala delete mode 100644 delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/effect/migration/package.scala diff --git a/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/effect/migration/MigrateEffectSyntax.scala b/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/effect/migration/MigrateEffectSyntax.scala deleted file mode 100644 index e2e733eb55..0000000000 --- a/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/effect/migration/MigrateEffectSyntax.scala +++ /dev/null @@ -1,49 +0,0 @@ -package ch.epfl.bluebrain.nexus.delta.kernel.effect.migration - -import cats.effect.IO -import monix.bio.{IO => BIO, Task, UIO} -import monix.execution.Scheduler.Implicits.global -import shapeless.=:!= - -import scala.annotation.nowarn - -import scala.reflect.ClassTag - -trait MigrateEffectSyntax { - - implicit def toCatsIO[E <: Throwable, A](io: BIO[E, A]): IO[A] = io.to[IO] - implicit def uioToCatsIO[E <: Throwable, A](io: UIO[A]): IO[A] = io.to[IO] - implicit def toCatsIOOps[E <: Throwable, A](io: BIO[E, A]): MonixBioToCatsIOOps[E, A] = new MonixBioToCatsIOOps(io) - - implicit def toMonixBIOOps[A](io: IO[A]): CatsIOToBioOps[A] = new CatsIOToBioOps(io) - -} - -final class MonixBioToCatsIOOps[E <: Throwable, A](private val io: BIO[E, A]) extends AnyVal { - def toCatsIO: IO[A] = io.to[IO] -} - -final class CatsIOToBioOps[A](private val io: IO[A]) extends AnyVal { - - /** - * Safe conversion between CE and Monix, forcing the user to specify a strict subtype of [[Throwable]]. If omitted, - * the compiler may infer [[Throwable]] and bypass any custom error handling. - */ - @SuppressWarnings(Array("UnusedMethodParameter")) - @nowarn - def toBIO[E <: Throwable](implicit E: ClassTag[E], ev: E =:!= Throwable): BIO[E, A] = - toBIOThrowable[E] - - /** - * Prefer [[toBIO]]. Only use this when we are sure there's no custom error handling logic. - */ - def toBIOThrowable[E <: Throwable](implicit E: ClassTag[E]): BIO[E, A] = - BIO.from(io).mapErrorPartialWith { - case E(e) => monix.bio.IO.raiseError(e) - case other => BIO.terminate(other) - } - - def toUIO: UIO[A] = BIO.from(io).hideErrors - - def toTask: Task[A] = Task.from(io) -} diff --git a/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/effect/migration/package.scala b/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/effect/migration/package.scala deleted file mode 100644 index 910f5b65b4..0000000000 --- a/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/effect/migration/package.scala +++ /dev/null @@ -1,3 +0,0 @@ -package ch.epfl.bluebrain.nexus.delta.kernel.effect - -package object migration extends MigrateEffectSyntax diff --git a/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/routes/BlazegraphViewRoutesFixtures.scala b/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/routes/BlazegraphViewRoutesFixtures.scala index 7d29de4e53..2e7980e9ea 100644 --- a/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/routes/BlazegraphViewRoutesFixtures.scala +++ b/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/routes/BlazegraphViewRoutesFixtures.scala @@ -15,20 +15,17 @@ import ch.epfl.bluebrain.nexus.delta.sdk.identities.IdentitiesDummy import ch.epfl.bluebrain.nexus.delta.sdk.identities.model.Caller import ch.epfl.bluebrain.nexus.delta.sdk.marshalling.{RdfExceptionHandler, RdfRejectionHandler} import ch.epfl.bluebrain.nexus.delta.sdk.model.search.ResultEntry.UnscoredResultEntry -import ch.epfl.bluebrain.nexus.delta.sdk.model.search.{PaginationConfig, SearchResults} import ch.epfl.bluebrain.nexus.delta.sdk.model.search.SearchResults.UnscoredSearchResults +import ch.epfl.bluebrain.nexus.delta.sdk.model.search.{PaginationConfig, SearchResults} import ch.epfl.bluebrain.nexus.delta.sdk.model.{BaseUri, ResourceF, ResourceUris} import ch.epfl.bluebrain.nexus.delta.sdk.projects.model.ApiMappings import ch.epfl.bluebrain.nexus.delta.sdk.syntax._ import ch.epfl.bluebrain.nexus.delta.sdk.utils.RouteHelpers -import ch.epfl.bluebrain.nexus.delta.sourcing.model.ResourceRef -import ch.epfl.bluebrain.nexus.delta.sourcing.model.Label -import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.{Authenticated, Group, User} +import ch.epfl.bluebrain.nexus.delta.sourcing.model.{Identity, Label, ResourceRef} import ch.epfl.bluebrain.nexus.delta.sourcing.postgres.DoobieScalaTestFixture import ch.epfl.bluebrain.nexus.testkit.ce.CatsRunContext import ch.epfl.bluebrain.nexus.testkit.clock.FixedClock -import ch.epfl.bluebrain.nexus.testkit.scalatest.bio.BIOValues import ch.epfl.bluebrain.nexus.testkit.scalatest.ce.CatsIOValues import ch.epfl.bluebrain.nexus.testkit.scalatest.{EitherValues, TestMatchers} import ch.epfl.bluebrain.nexus.testkit.{CirceEq, CirceLiteral, TestHelpers} @@ -47,7 +44,6 @@ trait BlazegraphViewRoutesFixtures with CirceEq with FixedClock with CatsRunContext - with BIOValues with OptionValues with TestMatchers with Inspectors diff --git a/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/GraphAnalyticsSinkSuite.scala b/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/GraphAnalyticsSinkSuite.scala index 4a3ad16cc1..e0c717e2a7 100644 --- a/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/GraphAnalyticsSinkSuite.scala +++ b/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/GraphAnalyticsSinkSuite.scala @@ -1,7 +1,6 @@ package ch.epfl.bluebrain.nexus.delta.plugins.graph.analytics.indexing import cats.effect.IO -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.ElasticSearchClientSetup import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.client.IndexLabel import ch.epfl.bluebrain.nexus.delta.plugins.graph.analytics.indexing.GraphAnalyticsResult.Index @@ -22,7 +21,6 @@ import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite import ch.epfl.bluebrain.nexus.testkit.{CirceLiteral, TestHelpers} import fs2.Chunk import io.circe.Json -import monix.bio.Task import munit.AnyFixture import java.time.Instant @@ -72,7 +70,7 @@ class GraphAnalyticsSinkSuite private def loadExpanded(path: String): ExpandedJsonLd = ioJsonContentOf(path).flatMap { json => - Task.fromEither(ExpandedJsonLd.expanded(json)) + IO.fromEither(ExpandedJsonLd.expanded(json)) }.accepted private def getTypes(expandedJsonLd: ExpandedJsonLd): IO[Set[Iri]] = diff --git a/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/stream/GraphResourceStream.scala b/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/stream/GraphResourceStream.scala index 4c21b8c638..60822cf326 100644 --- a/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/stream/GraphResourceStream.scala +++ b/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/stream/GraphResourceStream.scala @@ -1,7 +1,6 @@ package ch.epfl.bluebrain.nexus.delta.sdk.stream import cats.effect.{IO, Timer} -import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._ import ch.epfl.bluebrain.nexus.delta.sdk.ResourceShifts import ch.epfl.bluebrain.nexus.delta.sourcing.Transactors import ch.epfl.bluebrain.nexus.delta.sourcing.config.QueryConfig @@ -87,7 +86,7 @@ object GraphResourceStream { selectFilter, qc.copy(refreshStrategy = RefreshStrategy.Stop), xas, - shifts.decodeGraphResource(_, _).toTask + shifts.decodeGraphResource(_, _) ) override def remaining( From 6c6b0c369d65aff2e84345e624eacdeb95dd4570 Mon Sep 17 00:00:00 2001 From: Daniel Bell Date: Thu, 9 Nov 2023 17:15:35 +0100 Subject: [PATCH 12/18] remove logAndDiscardErrors --- .../nexus/delta/kernel/syntax/IOSyntax.scala | 15 --------------- .../sdk/deletion/ProjectDeletionCoordinator.scala | 1 - 2 files changed, 16 deletions(-) diff --git a/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/syntax/IOSyntax.scala b/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/syntax/IOSyntax.scala index 3c2b68565c..abed6a4e03 100644 --- a/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/syntax/IOSyntax.scala +++ b/delta/kernel/src/main/scala/ch/epfl/bluebrain/nexus/delta/kernel/syntax/IOSyntax.scala @@ -4,16 +4,12 @@ import cats.effect.{IO, Timer} import cats.implicits.catsSyntaxApplicativeError import cats.syntax.functor._ import ch.epfl.bluebrain.nexus.delta.kernel.RetryStrategy -import com.typesafe.scalalogging.Logger -import monix.bio.{Task, UIO} import org.typelevel.log4cats.{Logger => Log4CatsLogger} import scala.reflect.ClassTag trait IOSyntax { - implicit final def taskSyntaxLogErrors[A](task: Task[A]): TaskOps[A] = new TaskOps(task) - implicit final def ioSyntaxLogErrors[A](io: IO[A]): IOOps[A] = new IOOps(io) implicit final def ioRetryStrategyOps[A](io: IO[A]): IORetryStrategyOps[A] = @@ -32,17 +28,6 @@ final class IORetryStrategyOps[A](private val io: IO[A]) extends AnyVal { } -final class TaskOps[A](private val task: Task[A]) extends AnyVal { - - /** - * Log errors before hiding them - */ - def logAndDiscardErrors(action: String)(implicit logger: Logger): UIO[A] = - task.onErrorHandleWith { ex => - UIO.delay(logger.warn(s"A Task is hiding an error while '$action'", ex)) >> UIO.terminate(ex) - } -} - final class IOFunctorOps[A, F[_]: Functor](private val io: IO[F[A]]) { /** diff --git a/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/deletion/ProjectDeletionCoordinator.scala b/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/deletion/ProjectDeletionCoordinator.scala index 29b7c69fd2..472bb6b544 100644 --- a/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/deletion/ProjectDeletionCoordinator.scala +++ b/delta/sdk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/deletion/ProjectDeletionCoordinator.scala @@ -17,7 +17,6 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.offset.Offset import ch.epfl.bluebrain.nexus.delta.sourcing.stream._ import com.typesafe.scalalogging.Logger import fs2.Stream -//import monix.bio.Task /** * Stream to delete project from the system after those are marked as deleted From 736522e928539461180f3407fd236b8e2731b193 Mon Sep 17 00:00:00 2001 From: Daniel Bell Date: Thu, 9 Nov 2023 17:16:07 +0100 Subject: [PATCH 13/18] Remove BIOSuite --- .../nexus/testkit/mu/bio/BioSuite.scala | 42 ------------------- 1 file changed, 42 deletions(-) delete mode 100644 delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BioSuite.scala diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BioSuite.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BioSuite.scala deleted file mode 100644 index bc341c25b4..0000000000 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BioSuite.scala +++ /dev/null @@ -1,42 +0,0 @@ -package ch.epfl.bluebrain.nexus.testkit.mu.bio - -import ch.epfl.bluebrain.nexus.testkit.bio.BioRunContext -import ch.epfl.bluebrain.nexus.testkit.clock.FixedClock -import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsIOValues -import ch.epfl.bluebrain.nexus.testkit.mu.{CollectionAssertions, EitherAssertions, EitherValues, NexusSuite} -import monix.bio.IO - -import scala.concurrent.duration.{DurationInt, FiniteDuration} - -abstract class BioSuite - extends NexusSuite - with BioRunContext - with BioAssertions - with CatsIOValues - with CollectionAssertions - with EitherAssertions - with EitherValues - with FixedClock { - - protected val ioTimeout: FiniteDuration = 45.seconds - - override def munitValueTransforms: List[ValueTransform] = - super.munitValueTransforms ++ List(munitIOTransform) - - private val munitIOTransform: ValueTransform = - new ValueTransform( - "IO", - { case io: IO[_, _] => - io.timeout(ioTimeout) - .mapError { - case t: Throwable => t - case other => - fail( - s"""Error caught of type '${other.getClass.getName}', expected a successful response - |Error value: $other""".stripMargin - ) - } - .runToFuture - } - ) -} From 5877dc10e5d99256675114f0256feefc84d29a8d Mon Sep 17 00:00:00 2001 From: Daniel Bell Date: Thu, 9 Nov 2023 17:17:22 +0100 Subject: [PATCH 14/18] Remove BioAssertions --- .../EventMetricsDeletionTaskSuite.scala | 2 - .../delta/sourcing/ScopedEventLogSuite.scala | 3 +- .../nexus/testkit/mu/bio/BioAssertions.scala | 99 ------------------- 3 files changed, 1 insertion(+), 103 deletions(-) delete mode 100644 delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BioAssertions.scala diff --git a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/deletion/EventMetricsDeletionTaskSuite.scala b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/deletion/EventMetricsDeletionTaskSuite.scala index 5cdcdab246..4fe745fc5f 100644 --- a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/deletion/EventMetricsDeletionTaskSuite.scala +++ b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/deletion/EventMetricsDeletionTaskSuite.scala @@ -6,14 +6,12 @@ import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.{ElasticSearchClientS import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.{Anonymous, Subject} import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef import ch.epfl.bluebrain.nexus.testkit.bio.BioRunContext -import ch.epfl.bluebrain.nexus.testkit.mu.bio.BioAssertions import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite import ch.epfl.bluebrain.nexus.testkit.{CirceLiteral, TestHelpers} import munit.AnyFixture class EventMetricsDeletionTaskSuite extends CatsEffectSuite - with BioAssertions with BioRunContext with ElasticSearchClientSetup.Fixture with CirceLiteral diff --git a/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/ScopedEventLogSuite.scala b/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/ScopedEventLogSuite.scala index 22242ad469..3117dbccf0 100644 --- a/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/ScopedEventLogSuite.scala +++ b/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/ScopedEventLogSuite.scala @@ -20,7 +20,6 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.offset.Offset import ch.epfl.bluebrain.nexus.delta.sourcing.postgres.Doobie import ch.epfl.bluebrain.nexus.delta.sourcing.query.RefreshStrategy import ch.epfl.bluebrain.nexus.delta.sourcing.state.ScopedStateStore -import ch.epfl.bluebrain.nexus.testkit.mu.bio.BioAssertions import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite import doobie.implicits._ import doobie.postgres.implicits._ @@ -30,7 +29,7 @@ import munit.AnyFixture import java.time.Instant import scala.concurrent.duration._ -class ScopedEventLogSuite extends CatsEffectSuite with BioAssertions with Doobie.Fixture { +class ScopedEventLogSuite extends CatsEffectSuite with Doobie.Fixture { override def munitFixtures: Seq[AnyFixture[_]] = List(doobie) diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BioAssertions.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BioAssertions.scala deleted file mode 100644 index de1f1a74c7..0000000000 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/BioAssertions.scala +++ /dev/null @@ -1,99 +0,0 @@ -package ch.epfl.bluebrain.nexus.testkit.mu.bio - -import monix.bio.Cause.{Error, Termination} -import monix.bio.{IO, UIO} -import munit.{Assertions, Location} - -import java.io.{ByteArrayOutputStream, PrintStream} -import scala.reflect.ClassTag -import scala.util.control.NonFatal - -trait BioAssertions { self: Assertions => - - implicit class IoAssertionsOps[E, A](io: IO[E, A])(implicit E: ClassTag[E], loc: Location) { - - private def exceptionHandler(err: Throwable) = { - val baos = new ByteArrayOutputStream() - err.printStackTrace(new PrintStream(baos)) - val stack = new String(baos.toByteArray) - fail( - s"""Error caught of type '${err.getClass.getName}', expected a successful response - |Message: ${err.getMessage} - |Stack: - |$stack""".stripMargin, - err - ) - } - - def assert(expected: A, clue: Any = "values are not the same")(implicit loc: Location): UIO[Unit] = io.redeemCause( - { - case Error(NonFatal(err)) => - exceptionHandler(err) - case Error(err) => - fail( - s"""Error caught of type '${E.runtimeClass.getName}', expected a successful response - |Message: ${err.toString}""".stripMargin - ) - case Termination(err) => exceptionHandler(err) - }, - a => assertEquals(a, expected, clue) - ) - - def error(expected: E): UIO[Unit] = io.attempt.map { - case Left(E(err)) => assertEquals(err, expected) - case Left(err) => - fail( - s"Wrong raised error type caught, expected: '${E.runtimeClass.getName}', actual: '${err.getClass.getName}'" - ) - case Right(a) => - fail( - s"Expected raising error, but returned successful response with type '${a.getClass.getName}'" - ) - } - - def terminated[T <: Throwable](expectedMessage: String)(implicit T: ClassTag[T]): UIO[Unit] = - io.redeemCause( - { - case Error(err) => - fail( - s"Wrong raised error type caught, expected terminal: '${T.runtimeClass.getName}', actual typed: '${err.getClass.getName}'" - ) - case Termination(T(t)) => assertEquals(t.getMessage, expectedMessage) - case Termination(t) => - fail( - s"Wrong raised error type caught, expected terminal: '${T.runtimeClass.getName}', actual terminal: '${t.getClass.getName}'" - ) - }, - a => - fail( - s"Expected raising error, but returned successful response with type '${a.getClass.getName}'" - ) - ) - - def terminated[T <: Throwable](expected: T)(implicit T: ClassTag[T]): UIO[Unit] = - io.redeemCause( - { - case Error(err) => - fail( - s"Wrong raised error type caught, expected terminal: '${T.runtimeClass.getName}', actual typed: '${err.getClass.getName}'" - ) - case Termination(T(t)) => assertEquals(t, expected) - case Termination(t) => - fail( - s"Wrong raised error type caught, expected terminal: '${T.runtimeClass.getName}', actual terminal: '${t.getClass.getName}'" - ) - }, - a => - fail( - s"Expected raising error, but returned successful response with type '${a.getClass.getName}'" - ) - ) - } - - implicit class MonixBioAssertionsOptionOps[E, A](io: IO[E, Option[A]])(implicit E: ClassTag[E], loc: Location) { - def assertSome(expected: A): UIO[Unit] = io.assert(Some(expected)) - - def assertNone: UIO[Unit] = io.assert(None) - } - -} From 524df6d150cc8ed652a60d9e06a9029785ea2a3f Mon Sep 17 00:00:00 2001 From: Daniel Bell Date: Thu, 9 Nov 2023 17:20:49 +0100 Subject: [PATCH 15/18] Remove BioValues --- .../plugins/archive/ArchiveDownloadSpec.scala | 2 -- .../plugins/archive/ArchiveRoutesSpec.scala | 3 +- .../BlazegraphIndexingActionSuite.scala | 3 +- .../indexing/BlazegraphCoordinatorSuite.scala | 3 +- .../indexing/IndexingViewDefSuite.scala | 3 +- .../indexing/CompositeIndexingSuite.scala | 3 +- .../CompositeProjectionLifeCycleSuite.scala | 3 +- .../indexing/CompositeViewDefSuite.scala | 3 +- .../CompositeProjectionsSuite.scala | 3 +- .../ElasticSearchIndexingActionSuite.scala | 3 +- .../ElasticSearchCoordinatorSuite.scala | 3 +- .../indexing/IndexingViewDefSuite.scala | 3 +- .../metrics/EventMetricsProjectionSuite.scala | 3 +- .../ElasticSearchViewsDirectivesSpec.scala | 2 -- .../GraphAnalyticsCoordinatorSuite.scala | 3 +- .../indexing/GraphAnalyticsSinkSuite.scala | 3 +- .../ProjectDeletionRoutesSpec.scala | 2 -- .../delta/plugins/search/SearchSpec.scala | 2 -- .../statistics/StoragesStatisticsSuite.scala | 3 +- .../RemoteStorageSaveAndFetchFileSpec.scala | 2 -- .../sdk/directives/DeltaDirectivesSpec.scala | 2 -- .../sdk/directives/UriDirectivesSpec.scala | 2 -- .../stream/FailedElemPersistenceSuite.scala | 3 +- .../sourcing/stream/SupervisorSuite.scala | 3 +- .../testkit/mu/ce/CatsEffectAssertions.scala | 1 - .../mu/{bio => ce}/PatienceConfig.scala | 2 +- .../testkit/scalatest/bio/BIOValues.scala | 28 ------------------- 27 files changed, 18 insertions(+), 78 deletions(-) rename delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/{bio => ce}/PatienceConfig.scala (73%) delete mode 100644 delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/bio/BIOValues.scala diff --git a/delta/plugins/archive/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/archive/ArchiveDownloadSpec.scala b/delta/plugins/archive/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/archive/ArchiveDownloadSpec.scala index 8b3d3ea2db..b7f1e9cb08 100644 --- a/delta/plugins/archive/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/archive/ArchiveDownloadSpec.scala +++ b/delta/plugins/archive/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/archive/ArchiveDownloadSpec.scala @@ -43,7 +43,6 @@ import ch.epfl.bluebrain.nexus.testkit.TestHelpers import ch.epfl.bluebrain.nexus.testkit.archive.ArchiveHelpers import ch.epfl.bluebrain.nexus.testkit.ce.CatsRunContext import ch.epfl.bluebrain.nexus.testkit.scalatest.EitherValues -import ch.epfl.bluebrain.nexus.testkit.scalatest.bio.BIOValues import ch.epfl.bluebrain.nexus.testkit.scalatest.ce.CatsIOValues import io.circe.syntax.EncoderOps import org.scalatest.matchers.should.Matchers @@ -61,7 +60,6 @@ class ArchiveDownloadSpec with EitherValues with CatsRunContext with CatsIOValues - with BIOValues with OptionValues with TestHelpers with StorageFixtures diff --git a/delta/plugins/archive/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/archive/ArchiveRoutesSpec.scala b/delta/plugins/archive/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/archive/ArchiveRoutesSpec.scala index 080e1bd1ff..9260d11430 100644 --- a/delta/plugins/archive/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/archive/ArchiveRoutesSpec.scala +++ b/delta/plugins/archive/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/archive/ArchiveRoutesSpec.scala @@ -47,14 +47,13 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.Subject import ch.epfl.bluebrain.nexus.delta.sourcing.model.ResourceRef.Latest import ch.epfl.bluebrain.nexus.delta.sourcing.model.{Identity, Label, ProjectRef, ResourceRef} import ch.epfl.bluebrain.nexus.testkit.archive.ArchiveHelpers -import ch.epfl.bluebrain.nexus.testkit.scalatest.bio.BIOValues import io.circe.Json import io.circe.syntax.EncoderOps import java.util.UUID import scala.concurrent.duration._ -class ArchiveRoutesSpec extends BaseRouteSpec with BIOValues with StorageFixtures with ArchiveHelpers { +class ArchiveRoutesSpec extends BaseRouteSpec with StorageFixtures with ArchiveHelpers { private val uuid = UUID.fromString("8249ba90-7cc6-4de5-93a1-802c04200dcc") implicit private val uuidF: StatefulUUIDF = UUIDF.stateful(uuid).accepted diff --git a/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphIndexingActionSuite.scala b/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphIndexingActionSuite.scala index 57fef69076..ebced99a8d 100644 --- a/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphIndexingActionSuite.scala +++ b/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphIndexingActionSuite.scala @@ -20,8 +20,7 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.query.SelectFilter import ch.epfl.bluebrain.nexus.delta.sourcing.stream.Elem.{DroppedElem, FailedElem, SuccessElem} import ch.epfl.bluebrain.nexus.delta.sourcing.stream.ProjectionErr.CouldNotFindPipeErr import ch.epfl.bluebrain.nexus.delta.sourcing.stream.{NoopSink, PipeChain, PipeRef} -import ch.epfl.bluebrain.nexus.testkit.mu.bio.PatienceConfig -import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite +import ch.epfl.bluebrain.nexus.testkit.mu.ce.{CatsEffectSuite, PatienceConfig} import fs2.Stream import java.time.Instant diff --git a/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/indexing/BlazegraphCoordinatorSuite.scala b/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/indexing/BlazegraphCoordinatorSuite.scala index 442cc5ee39..a571cacb24 100644 --- a/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/indexing/BlazegraphCoordinatorSuite.scala +++ b/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/indexing/BlazegraphCoordinatorSuite.scala @@ -16,8 +16,7 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.stream.Elem.{DroppedElem, FailedEl import ch.epfl.bluebrain.nexus.delta.sourcing.stream.ProjectionErr.CouldNotFindPipeErr import ch.epfl.bluebrain.nexus.delta.sourcing.stream.SupervisorSetup.unapply import ch.epfl.bluebrain.nexus.delta.sourcing.stream._ -import ch.epfl.bluebrain.nexus.testkit.mu.bio.PatienceConfig -import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite +import ch.epfl.bluebrain.nexus.testkit.mu.ce.{CatsEffectSuite, PatienceConfig} import fs2.Stream import fs2.concurrent.SignallingRef import munit.AnyFixture diff --git a/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/indexing/IndexingViewDefSuite.scala b/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/indexing/IndexingViewDefSuite.scala index a0d61cc7ab..7a2443a1dd 100644 --- a/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/indexing/IndexingViewDefSuite.scala +++ b/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/indexing/IndexingViewDefSuite.scala @@ -21,8 +21,7 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.stream.ProjectionErr.CouldNotFindT import ch.epfl.bluebrain.nexus.delta.sourcing.stream._ import ch.epfl.bluebrain.nexus.delta.sourcing.stream.pipes.FilterByType.FilterByTypeConfig import ch.epfl.bluebrain.nexus.delta.sourcing.stream.pipes.{FilterByType, FilterDeprecated} -import ch.epfl.bluebrain.nexus.testkit.mu.bio.PatienceConfig -import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite +import ch.epfl.bluebrain.nexus.testkit.mu.ce.{CatsEffectSuite, PatienceConfig} import io.circe.Json import java.time.Instant diff --git a/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/indexing/CompositeIndexingSuite.scala b/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/indexing/CompositeIndexingSuite.scala index 1c3acdc722..44bee2e9e2 100644 --- a/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/indexing/CompositeIndexingSuite.scala +++ b/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/indexing/CompositeIndexingSuite.scala @@ -52,8 +52,7 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.stream._ import ch.epfl.bluebrain.nexus.delta.sourcing.stream.pipes.{DiscardMetadata, FilterByType, FilterDeprecated} import ch.epfl.bluebrain.nexus.testkit.TestHelpers import ch.epfl.bluebrain.nexus.testkit.bio.BioRunContext -import ch.epfl.bluebrain.nexus.testkit.mu.bio.PatienceConfig -import ch.epfl.bluebrain.nexus.testkit.mu.ce.{CatsEffectSuite, ResourceFixture} +import ch.epfl.bluebrain.nexus.testkit.mu.ce.{CatsEffectSuite, PatienceConfig, ResourceFixture} import ch.epfl.bluebrain.nexus.testkit.mu.{JsonAssertions, TextAssertions} import fs2.Stream import io.circe.generic.extras.Configuration diff --git a/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/indexing/CompositeProjectionLifeCycleSuite.scala b/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/indexing/CompositeProjectionLifeCycleSuite.scala index ae1f578ad8..37fd2b5785 100644 --- a/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/indexing/CompositeProjectionLifeCycleSuite.scala +++ b/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/indexing/CompositeProjectionLifeCycleSuite.scala @@ -13,8 +13,7 @@ import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.nxv import ch.epfl.bluebrain.nexus.delta.sdk.views.{IndexingRev, IndexingViewRef, ViewRef} import ch.epfl.bluebrain.nexus.delta.sourcing.config.BatchConfig import ch.epfl.bluebrain.nexus.delta.sourcing.stream._ -import ch.epfl.bluebrain.nexus.testkit.mu.bio.PatienceConfig -import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite +import ch.epfl.bluebrain.nexus.testkit.mu.ce.{CatsEffectSuite, PatienceConfig} import munit.Location import java.util.UUID diff --git a/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/indexing/CompositeViewDefSuite.scala b/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/indexing/CompositeViewDefSuite.scala index dd0d31c222..84b1746ba6 100644 --- a/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/indexing/CompositeViewDefSuite.scala +++ b/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/indexing/CompositeViewDefSuite.scala @@ -14,8 +14,7 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.offset.Offset import ch.epfl.bluebrain.nexus.delta.sourcing.state.GraphResource import ch.epfl.bluebrain.nexus.delta.sourcing.stream.pipes.FilterDeprecated import ch.epfl.bluebrain.nexus.delta.sourcing.stream.{NoopSink, RemainingElems, Source} -import ch.epfl.bluebrain.nexus.testkit.mu.bio.PatienceConfig -import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite +import ch.epfl.bluebrain.nexus.testkit.mu.ce.{CatsEffectSuite, PatienceConfig} import fs2.Stream import shapeless.Typeable diff --git a/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/projections/CompositeProjectionsSuite.scala b/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/projections/CompositeProjectionsSuite.scala index 3e61d8e922..017643ee4d 100644 --- a/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/projections/CompositeProjectionsSuite.scala +++ b/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/projections/CompositeProjectionsSuite.scala @@ -15,8 +15,7 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef import ch.epfl.bluebrain.nexus.delta.sourcing.offset.Offset import ch.epfl.bluebrain.nexus.delta.sourcing.postgres.Doobie import ch.epfl.bluebrain.nexus.delta.sourcing.stream.ProjectionProgress -import ch.epfl.bluebrain.nexus.testkit.mu.bio.PatienceConfig -import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite +import ch.epfl.bluebrain.nexus.testkit.mu.ce.{CatsEffectSuite, PatienceConfig} import fs2.Stream import munit.AnyFixture diff --git a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchIndexingActionSuite.scala b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchIndexingActionSuite.scala index 10bd96d924..4dd0638e6d 100644 --- a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchIndexingActionSuite.scala +++ b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchIndexingActionSuite.scala @@ -21,8 +21,7 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.stream.Elem.{DroppedElem, FailedEl import ch.epfl.bluebrain.nexus.delta.sourcing.stream.ProjectionErr.CouldNotFindPipeErr import ch.epfl.bluebrain.nexus.delta.sourcing.stream.{NoopSink, PipeChain, PipeRef} import ch.epfl.bluebrain.nexus.testkit.CirceLiteral -import ch.epfl.bluebrain.nexus.testkit.mu.bio.PatienceConfig -import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite +import ch.epfl.bluebrain.nexus.testkit.mu.ce.{CatsEffectSuite, PatienceConfig} import fs2.Stream import io.circe.Json diff --git a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/indexing/ElasticSearchCoordinatorSuite.scala b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/indexing/ElasticSearchCoordinatorSuite.scala index f94fa0b728..b490f38036 100644 --- a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/indexing/ElasticSearchCoordinatorSuite.scala +++ b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/indexing/ElasticSearchCoordinatorSuite.scala @@ -17,8 +17,7 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.stream.ProjectionErr.CouldNotFindP import ch.epfl.bluebrain.nexus.delta.sourcing.stream.SupervisorSetup.unapply import ch.epfl.bluebrain.nexus.delta.sourcing.stream._ import ch.epfl.bluebrain.nexus.testkit.CirceLiteral -import ch.epfl.bluebrain.nexus.testkit.mu.bio.PatienceConfig -import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite +import ch.epfl.bluebrain.nexus.testkit.mu.ce.{CatsEffectSuite, PatienceConfig} import fs2.Stream import fs2.concurrent.SignallingRef import io.circe.Json diff --git a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/indexing/IndexingViewDefSuite.scala b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/indexing/IndexingViewDefSuite.scala index dcd9addc8b..08189535b3 100644 --- a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/indexing/IndexingViewDefSuite.scala +++ b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/indexing/IndexingViewDefSuite.scala @@ -24,8 +24,7 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.stream._ import ch.epfl.bluebrain.nexus.delta.sourcing.stream.pipes.FilterByType.FilterByTypeConfig import ch.epfl.bluebrain.nexus.delta.sourcing.stream.pipes.{FilterByType, FilterDeprecated} import ch.epfl.bluebrain.nexus.testkit.CirceLiteral -import ch.epfl.bluebrain.nexus.testkit.mu.bio.PatienceConfig -import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite +import ch.epfl.bluebrain.nexus.testkit.mu.ce.{CatsEffectSuite, PatienceConfig} import io.circe.Json import java.time.Instant diff --git a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/metrics/EventMetricsProjectionSuite.scala b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/metrics/EventMetricsProjectionSuite.scala index 8616455056..2e273ed906 100644 --- a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/metrics/EventMetricsProjectionSuite.scala +++ b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/metrics/EventMetricsProjectionSuite.scala @@ -5,8 +5,7 @@ import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.metrics.MetricsStream import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.{EventMetricsProjection, Fixtures} import ch.epfl.bluebrain.nexus.delta.sourcing.offset.Offset import ch.epfl.bluebrain.nexus.delta.sourcing.stream.{CacheSink, ProjectionProgress, SupervisorSetup} -import ch.epfl.bluebrain.nexus.testkit.mu.bio.PatienceConfig -import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite +import ch.epfl.bluebrain.nexus.testkit.mu.ce.{CatsEffectSuite, PatienceConfig} import io.circe.Json import io.circe.syntax.EncoderOps import munit.AnyFixture diff --git a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/routes/ElasticSearchViewsDirectivesSpec.scala b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/routes/ElasticSearchViewsDirectivesSpec.scala index 3a2831146b..31a144eba3 100644 --- a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/routes/ElasticSearchViewsDirectivesSpec.scala +++ b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/routes/ElasticSearchViewsDirectivesSpec.scala @@ -21,7 +21,6 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.User import ch.epfl.bluebrain.nexus.delta.sourcing.model.Tag.UserTag import ch.epfl.bluebrain.nexus.delta.sourcing.model.{Label, ResourceRef} import ch.epfl.bluebrain.nexus.testkit.scalatest.TestMatchers -import ch.epfl.bluebrain.nexus.testkit.scalatest.bio.BIOValues import ch.epfl.bluebrain.nexus.testkit.{CirceLiteral, TestHelpers} import io.circe.generic.extras.Configuration import io.circe.Codec @@ -39,7 +38,6 @@ class ElasticSearchViewsDirectivesSpec with OptionValues with CirceLiteral with ElasticSearchViewsDirectives - with BIOValues with TestMatchers with TestHelpers with Inspectors { diff --git a/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/GraphAnalyticsCoordinatorSuite.scala b/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/GraphAnalyticsCoordinatorSuite.scala index 35593e4f7d..ded6f17c26 100644 --- a/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/GraphAnalyticsCoordinatorSuite.scala +++ b/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/GraphAnalyticsCoordinatorSuite.scala @@ -12,8 +12,7 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.offset.Offset import ch.epfl.bluebrain.nexus.delta.sourcing.stream.Elem.{DroppedElem, FailedElem, SuccessElem} import ch.epfl.bluebrain.nexus.delta.sourcing.stream.SupervisorSetup.unapply import ch.epfl.bluebrain.nexus.delta.sourcing.stream._ -import ch.epfl.bluebrain.nexus.testkit.mu.bio.PatienceConfig -import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite +import ch.epfl.bluebrain.nexus.testkit.mu.ce.{CatsEffectSuite, PatienceConfig} import fs2.Stream import fs2.concurrent.SignallingRef import munit.AnyFixture diff --git a/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/GraphAnalyticsSinkSuite.scala b/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/GraphAnalyticsSinkSuite.scala index e0c717e2a7..41670020f0 100644 --- a/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/GraphAnalyticsSinkSuite.scala +++ b/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/GraphAnalyticsSinkSuite.scala @@ -16,8 +16,7 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef import ch.epfl.bluebrain.nexus.delta.sourcing.offset.Offset import ch.epfl.bluebrain.nexus.delta.sourcing.stream.Elem.{FailedElem, SuccessElem} import ch.epfl.bluebrain.nexus.testkit.bio.BioRunContext -import ch.epfl.bluebrain.nexus.testkit.mu.bio.PatienceConfig -import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite +import ch.epfl.bluebrain.nexus.testkit.mu.ce.{CatsEffectSuite, PatienceConfig} import ch.epfl.bluebrain.nexus.testkit.{CirceLiteral, TestHelpers} import fs2.Chunk import io.circe.Json diff --git a/delta/plugins/project-deletion/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/projectdeletion/ProjectDeletionRoutesSpec.scala b/delta/plugins/project-deletion/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/projectdeletion/ProjectDeletionRoutesSpec.scala index 628f7e4faf..373742d6ec 100644 --- a/delta/plugins/project-deletion/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/projectdeletion/ProjectDeletionRoutesSpec.scala +++ b/delta/plugins/project-deletion/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/projectdeletion/ProjectDeletionRoutesSpec.scala @@ -10,7 +10,6 @@ import ch.epfl.bluebrain.nexus.delta.sdk.model.BaseUri import ch.epfl.bluebrain.nexus.delta.sdk.utils.RouteHelpers import ch.epfl.bluebrain.nexus.delta.sourcing.model.Label import ch.epfl.bluebrain.nexus.testkit.TestHelpers -import ch.epfl.bluebrain.nexus.testkit.scalatest.bio.BIOValues import org.scalatest.matchers.should.Matchers import scala.concurrent.duration.DurationInt @@ -19,7 +18,6 @@ class ProjectDeletionRoutesSpec extends RouteHelpers with CirceMarshalling with Matchers - with BIOValues with TestHelpers { implicit private val cl: ClassLoader = getClass.getClassLoader diff --git a/delta/plugins/search/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/search/SearchSpec.scala b/delta/plugins/search/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/search/SearchSpec.scala index df382b0949..47e66c5a81 100644 --- a/delta/plugins/search/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/search/SearchSpec.scala +++ b/delta/plugins/search/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/search/SearchSpec.scala @@ -34,7 +34,6 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.model.Label import ch.epfl.bluebrain.nexus.testkit._ import ch.epfl.bluebrain.nexus.testkit.elasticsearch.ElasticSearchDocker import ch.epfl.bluebrain.nexus.testkit.scalatest.EitherValues -import ch.epfl.bluebrain.nexus.testkit.scalatest.bio.BIOValues import ch.epfl.bluebrain.nexus.testkit.scalatest.ce.CatsIOValues import io.circe.{Json, JsonObject} import org.scalatest.concurrent.Eventually @@ -59,7 +58,6 @@ class SearchSpec with ScalaTestElasticSearchClientSetup with ConfigFixtures with CatsIOValues - with BIOValues with Eventually with Fixtures with ElasticSearchDocker { diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/statistics/StoragesStatisticsSuite.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/statistics/StoragesStatisticsSuite.scala index f9fd047513..6eb0f46cf1 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/statistics/StoragesStatisticsSuite.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/statistics/StoragesStatisticsSuite.scala @@ -14,8 +14,7 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.stream.SupervisorSetup import ch.epfl.bluebrain.nexus.delta.sourcing.stream.SupervisorSetup.unapply import ch.epfl.bluebrain.nexus.testkit.TestHelpers import ch.epfl.bluebrain.nexus.testkit.bio.BioRunContext -import ch.epfl.bluebrain.nexus.testkit.mu.bio.PatienceConfig -import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite +import ch.epfl.bluebrain.nexus.testkit.mu.ce.{CatsEffectSuite, PatienceConfig} import munit.AnyFixture import scala.concurrent.duration.DurationInt diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/RemoteStorageSaveAndFetchFileSpec.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/RemoteStorageSaveAndFetchFileSpec.scala index 9cd2814798..7e0f5d127f 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/RemoteStorageSaveAndFetchFileSpec.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/RemoteStorageSaveAndFetchFileSpec.scala @@ -23,7 +23,6 @@ import ch.epfl.bluebrain.nexus.delta.sdk.model.{BaseUri, Tags} import ch.epfl.bluebrain.nexus.delta.sdk.syntax._ import ch.epfl.bluebrain.nexus.delta.sourcing.model.{Label, ProjectRef} import ch.epfl.bluebrain.nexus.testkit.remotestorage.RemoteStorageDocker -import ch.epfl.bluebrain.nexus.testkit.scalatest.bio.BIOValues import ch.epfl.bluebrain.nexus.testkit.scalatest.ce.CatsEffectSpec import io.circe.Json import org.scalatest.concurrent.Eventually @@ -37,7 +36,6 @@ class RemoteStorageSaveAndFetchFileSpec(docker: RemoteStorageDocker) extends TestKit(ActorSystem("RemoteStorageSaveAndFetchFileSpec")) with CatsEffectSpec with AkkaSourceHelpers - with BIOValues with Eventually with BeforeAndAfterAll with StorageFixtures diff --git a/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/directives/DeltaDirectivesSpec.scala b/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/directives/DeltaDirectivesSpec.scala index 651ba50f60..d00ac9cd2e 100644 --- a/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/directives/DeltaDirectivesSpec.scala +++ b/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/directives/DeltaDirectivesSpec.scala @@ -33,7 +33,6 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.model.Tag.UserTag import ch.epfl.bluebrain.nexus.delta.sourcing.model.Label import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef import ch.epfl.bluebrain.nexus.testkit.scalatest.TestMatchers -import ch.epfl.bluebrain.nexus.testkit.scalatest.bio.BIOValues import ch.epfl.bluebrain.nexus.testkit.scalatest.ce.CatsIOValues import ch.epfl.bluebrain.nexus.testkit.{CirceLiteral, TestHelpers} import io.circe.syntax._ @@ -50,7 +49,6 @@ class DeltaDirectivesSpec with CirceMarshalling with CirceLiteral with CatsIOValues - with BIOValues with TestMatchers with TestHelpers with Inspectors { diff --git a/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/directives/UriDirectivesSpec.scala b/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/directives/UriDirectivesSpec.scala index d2b7b03d3d..a77e99482f 100644 --- a/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/directives/UriDirectivesSpec.scala +++ b/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/directives/UriDirectivesSpec.scala @@ -19,7 +19,6 @@ import ch.epfl.bluebrain.nexus.delta.sdk.{IndexingMode, OrderingFields} import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.{Anonymous, Group, Subject, User} import ch.epfl.bluebrain.nexus.delta.sourcing.model.{Label, ResourceRef} import ch.epfl.bluebrain.nexus.testkit.scalatest.TestMatchers -import ch.epfl.bluebrain.nexus.testkit.scalatest.bio.BIOValues import ch.epfl.bluebrain.nexus.testkit.{CirceLiteral, TestHelpers} import org.scalatest.matchers.should.Matchers import org.scalatest.{Inspectors, OptionValues} @@ -34,7 +33,6 @@ class UriDirectivesSpec with OptionValues with CirceLiteral with UriDirectives - with BIOValues with TestMatchers with TestHelpers with Inspectors { diff --git a/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/stream/FailedElemPersistenceSuite.scala b/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/stream/FailedElemPersistenceSuite.scala index c0a66b853d..0ae347782d 100644 --- a/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/stream/FailedElemPersistenceSuite.scala +++ b/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/stream/FailedElemPersistenceSuite.scala @@ -6,8 +6,7 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.config.BatchConfig import ch.epfl.bluebrain.nexus.delta.sourcing.model.EntityType import ch.epfl.bluebrain.nexus.delta.sourcing.offset.Offset import ch.epfl.bluebrain.nexus.delta.sourcing.stream.Elem._ -import ch.epfl.bluebrain.nexus.testkit.mu.bio.PatienceConfig -import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite +import ch.epfl.bluebrain.nexus.testkit.mu.ce.{CatsEffectSuite, PatienceConfig} import fs2.Stream import java.time.Instant diff --git a/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/stream/SupervisorSuite.scala b/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/stream/SupervisorSuite.scala index 36031bd64c..f6516dccc9 100644 --- a/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/stream/SupervisorSuite.scala +++ b/delta/sourcing-psql/src/test/scala/ch/epfl/bluebrain/nexus/delta/sourcing/stream/SupervisorSuite.scala @@ -14,8 +14,7 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.stream.ExecutionStrategy.{EveryNod import ch.epfl.bluebrain.nexus.delta.sourcing.stream.ProjectionProgress.NoProgress import ch.epfl.bluebrain.nexus.delta.sourcing.stream.SupervisorSetup.unapply import ch.epfl.bluebrain.nexus.delta.sourcing.stream.SupervisorSuite.UnstableDestroy -import ch.epfl.bluebrain.nexus.testkit.mu.bio.PatienceConfig -import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite +import ch.epfl.bluebrain.nexus.testkit.mu.ce.{CatsEffectSuite, PatienceConfig} import fs2.Stream import munit.AnyFixture diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/ce/CatsEffectAssertions.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/ce/CatsEffectAssertions.scala index d8a71d97c9..744ea1da29 100644 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/ce/CatsEffectAssertions.scala +++ b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/ce/CatsEffectAssertions.scala @@ -6,7 +6,6 @@ import cats.syntax.eq._ import ch.epfl.bluebrain.nexus.delta.kernel.RetryStrategy import ch.epfl.bluebrain.nexus.delta.kernel.RetryStrategyConfig.MaximumCumulativeDelayConfig import ch.epfl.bluebrain.nexus.testkit.ce.CatsRunContext -import ch.epfl.bluebrain.nexus.testkit.mu.bio.PatienceConfig import munit.{Assertions, Compare, FailException, Location} import scala.reflect.ClassTag diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/PatienceConfig.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/ce/PatienceConfig.scala similarity index 73% rename from delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/PatienceConfig.scala rename to delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/ce/PatienceConfig.scala index 4517354e84..4174950b8e 100644 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/bio/PatienceConfig.scala +++ b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/ce/PatienceConfig.scala @@ -1,4 +1,4 @@ -package ch.epfl.bluebrain.nexus.testkit.mu.bio +package ch.epfl.bluebrain.nexus.testkit.mu.ce import scala.concurrent.duration.FiniteDuration diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/bio/BIOValues.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/bio/BIOValues.scala deleted file mode 100644 index bf70db1269..0000000000 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/scalatest/bio/BIOValues.scala +++ /dev/null @@ -1,28 +0,0 @@ -package ch.epfl.bluebrain.nexus.testkit.scalatest.bio - -import monix.bio.Task -import monix.execution.Scheduler -import org.scalatest.{Assertion, Assertions, Suite} - -import scala.concurrent.Future - -trait BIOValues extends BIOValuesLowPrio { - self: Suite => - - implicit def taskToFutureAssertion( - task: Task[Assertion] - )(implicit s: Scheduler = Scheduler.global): Future[Assertion] = - task.runToFuture - - implicit def futureListToFutureAssertion( - future: Future[List[Assertion]] - )(implicit s: Scheduler = Scheduler.global): Future[Assertion] = - future.map(_ => succeed) -} - -trait BIOValuesLowPrio extends Assertions { - implicit def taskListToFutureAssertion( - task: Task[List[Assertion]] - )(implicit s: Scheduler = Scheduler.global): Future[Assertion] = - task.runToFuture.map(_ => succeed) -} From a2e9f4c59cf98fbcbfd089ccbc81155e7164c800 Mon Sep 17 00:00:00 2001 From: Daniel Bell Date: Thu, 9 Nov 2023 17:23:45 +0100 Subject: [PATCH 16/18] Remove BioRunContext --- .../blazegraph/BlazegraphClientSetup.scala | 3 +-- .../indexing/BlazegraphSinkSuite.scala | 2 -- .../indexing/CompositeIndexingSuite.scala | 3 +-- .../ElasticSearchClientSetup.scala | 3 +-- .../ElasticSearchViewsQuerySuite.scala | 2 -- .../EventMetricsDeletionTaskSuite.scala | 2 -- .../indexing/ElasticSearchSinkSuite.scala | 2 -- .../query/DefaultViewSearchSuite.scala | 2 -- .../indexing/GraphAnalyticsSinkSuite.scala | 2 -- .../plugins/storage/files/FilesSpec.scala | 2 -- .../statistics/StoragesStatisticsSuite.scala | 2 -- .../client/RemoteStorageClientSpec.scala | 2 -- .../nexus/testkit/bio/BioRunContext.scala | 7 ------ .../nexus/testkit/mu/ce/CatsEffectSuite.scala | 23 +------------------ 14 files changed, 4 insertions(+), 53 deletions(-) delete mode 100644 delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/bio/BioRunContext.scala diff --git a/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphClientSetup.scala b/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphClientSetup.scala index 8d09e21227..705cd6262c 100644 --- a/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphClientSetup.scala +++ b/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/BlazegraphClientSetup.scala @@ -4,7 +4,6 @@ import akka.actor.ActorSystem import cats.effect.{ContextShift, IO, Resource, Timer} import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.client.BlazegraphClient import ch.epfl.bluebrain.nexus.delta.sdk.http.HttpClientSetup -import ch.epfl.bluebrain.nexus.testkit.bio.BioRunContext import ch.epfl.bluebrain.nexus.testkit.blazegraph.BlazegraphContainer import ch.epfl.bluebrain.nexus.testkit.ce.CatsRunContext import ch.epfl.bluebrain.nexus.testkit.mu.ce.ResourceFixture @@ -38,7 +37,7 @@ object BlazegraphClientSetup extends Fixtures { )(implicit timer: Timer[IO], cs: ContextShift[IO]): IOFixture[BlazegraphClient] = ResourceFixture.suiteLocal(name, resource()) - trait Fixture { self: CatsRunContext with BioRunContext => + trait Fixture { self: CatsRunContext => val blazegraphClient: ResourceFixture.IOFixture[BlazegraphClient] = BlazegraphClientSetup.suiteLocalFixture("blazegraphClient") } diff --git a/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/indexing/BlazegraphSinkSuite.scala b/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/indexing/BlazegraphSinkSuite.scala index a495cffc2f..71721a18d7 100644 --- a/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/indexing/BlazegraphSinkSuite.scala +++ b/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/indexing/BlazegraphSinkSuite.scala @@ -13,7 +13,6 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.model.{EntityType, Label} import ch.epfl.bluebrain.nexus.delta.sourcing.offset.Offset import ch.epfl.bluebrain.nexus.delta.sourcing.stream.Elem.{DroppedElem, SuccessElem} import ch.epfl.bluebrain.nexus.testkit.TestHelpers -import ch.epfl.bluebrain.nexus.testkit.bio.BioRunContext import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite import fs2.Chunk import munit.AnyFixture @@ -23,7 +22,6 @@ import scala.concurrent.duration._ class BlazegraphSinkSuite extends CatsEffectSuite - with BioRunContext with BlazegraphClientSetup.Fixture with TestHelpers { diff --git a/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/indexing/CompositeIndexingSuite.scala b/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/indexing/CompositeIndexingSuite.scala index 44bee2e9e2..741fee1b09 100644 --- a/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/indexing/CompositeIndexingSuite.scala +++ b/delta/plugins/composite-views/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/indexing/CompositeIndexingSuite.scala @@ -51,7 +51,6 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.stream.Elem.SuccessElem import ch.epfl.bluebrain.nexus.delta.sourcing.stream._ import ch.epfl.bluebrain.nexus.delta.sourcing.stream.pipes.{DiscardMetadata, FilterByType, FilterDeprecated} import ch.epfl.bluebrain.nexus.testkit.TestHelpers -import ch.epfl.bluebrain.nexus.testkit.bio.BioRunContext import ch.epfl.bluebrain.nexus.testkit.mu.ce.{CatsEffectSuite, PatienceConfig, ResourceFixture} import ch.epfl.bluebrain.nexus.testkit.mu.{JsonAssertions, TextAssertions} import fs2.Stream @@ -69,7 +68,7 @@ import scala.concurrent.duration.DurationInt class SingleCompositeIndexingSuite extends CompositeIndexingSuite(SinkConfig.Single, singleQuery) class BatchCompositeIndexingSuite extends CompositeIndexingSuite(SinkConfig.Batch, batchQuery) -trait CompositeIndexingFixture extends CatsEffectSuite with BioRunContext { +trait CompositeIndexingFixture extends CatsEffectSuite { implicit private val baseUri: BaseUri = BaseUri("http://localhost", Label.unsafe("v1")) implicit private val rcr: RemoteContextResolution = RemoteContextResolution.never diff --git a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchClientSetup.scala b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchClientSetup.scala index 3854d52736..327574ef73 100644 --- a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchClientSetup.scala +++ b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchClientSetup.scala @@ -6,7 +6,6 @@ import cats.effect.{IO, Resource} import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.client.ElasticSearchClient import ch.epfl.bluebrain.nexus.delta.sdk.http.HttpClientSetup import ch.epfl.bluebrain.nexus.testkit.CirceLiteral -import ch.epfl.bluebrain.nexus.testkit.bio.BioRunContext import ch.epfl.bluebrain.nexus.testkit.ce.CatsRunContext import ch.epfl.bluebrain.nexus.testkit.elasticsearch.ElasticSearchContainer import ch.epfl.bluebrain.nexus.testkit.mu.ce.ResourceFixture @@ -48,7 +47,7 @@ object ElasticSearchClientSetup extends CirceLiteral with CatsRunContext with Fi def suiteLocalFixture(name: String): IOFixture[ElasticSearchClient] = ResourceFixture.suiteLocal(name, resource()) - trait Fixture { self: Suite with BioRunContext => + trait Fixture { self: Suite => val esClient: IOFixture[ElasticSearchClient] = ElasticSearchClientSetup.suiteLocalFixture("esclient") } diff --git a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchViewsQuerySuite.scala b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchViewsQuerySuite.scala index 5a3403ac89..3ae131d1b8 100644 --- a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchViewsQuerySuite.scala +++ b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/ElasticSearchViewsQuerySuite.scala @@ -31,7 +31,6 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.{Anonymous, Group, import ch.epfl.bluebrain.nexus.delta.sourcing.model.{Label, ResourceRef} import ch.epfl.bluebrain.nexus.delta.sourcing.postgres.Doobie import ch.epfl.bluebrain.nexus.delta.sourcing.stream.pipes.{DiscardMetadata, FilterDeprecated} -import ch.epfl.bluebrain.nexus.testkit.bio.BioRunContext import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite import ch.epfl.bluebrain.nexus.testkit.{CirceLiteral, TestHelpers} import io.circe.syntax.EncoderOps @@ -43,7 +42,6 @@ import java.time.Instant class ElasticSearchViewsQuerySuite extends CatsEffectSuite with Doobie.Fixture - with BioRunContext // to use ES client setup fixture with ElasticSearchClientSetup.Fixture with CirceLiteral with TestHelpers diff --git a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/deletion/EventMetricsDeletionTaskSuite.scala b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/deletion/EventMetricsDeletionTaskSuite.scala index 4fe745fc5f..772631c544 100644 --- a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/deletion/EventMetricsDeletionTaskSuite.scala +++ b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/deletion/EventMetricsDeletionTaskSuite.scala @@ -5,14 +5,12 @@ import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.client.{ElasticSearch import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.{ElasticSearchClientSetup, EventMetricsProjection, Fixtures} import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.{Anonymous, Subject} import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef -import ch.epfl.bluebrain.nexus.testkit.bio.BioRunContext import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite import ch.epfl.bluebrain.nexus.testkit.{CirceLiteral, TestHelpers} import munit.AnyFixture class EventMetricsDeletionTaskSuite extends CatsEffectSuite - with BioRunContext with ElasticSearchClientSetup.Fixture with CirceLiteral with TestHelpers diff --git a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/indexing/ElasticSearchSinkSuite.scala b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/indexing/ElasticSearchSinkSuite.scala index 9fcec163a3..93d5ab758d 100644 --- a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/indexing/ElasticSearchSinkSuite.scala +++ b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/indexing/ElasticSearchSinkSuite.scala @@ -13,7 +13,6 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.model.EntityType import ch.epfl.bluebrain.nexus.delta.sourcing.offset.Offset import ch.epfl.bluebrain.nexus.delta.sourcing.stream.Elem.{DroppedElem, FailedElem, SuccessElem} import ch.epfl.bluebrain.nexus.testkit.CirceLiteral -import ch.epfl.bluebrain.nexus.testkit.bio.BioRunContext import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite import fs2.Chunk import io.circe.Json @@ -24,7 +23,6 @@ import scala.concurrent.duration._ class ElasticSearchSinkSuite extends CatsEffectSuite - with BioRunContext with ElasticSearchClientSetup.Fixture with CirceLiteral { diff --git a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/query/DefaultViewSearchSuite.scala b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/query/DefaultViewSearchSuite.scala index 56403bf11b..f278355d96 100644 --- a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/query/DefaultViewSearchSuite.scala +++ b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/query/DefaultViewSearchSuite.scala @@ -24,7 +24,6 @@ import ch.epfl.bluebrain.nexus.delta.sdk.resources.model.Resource import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.{Anonymous, Subject, User} import ch.epfl.bluebrain.nexus.delta.sourcing.model.Tag.UserTag import ch.epfl.bluebrain.nexus.delta.sourcing.model.{Label, ProjectRef, ResourceRef} -import ch.epfl.bluebrain.nexus.testkit.bio.BioRunContext import ch.epfl.bluebrain.nexus.testkit.mu.ce.CatsEffectSuite import ch.epfl.bluebrain.nexus.testkit.{CirceLiteral, TestHelpers} import io.circe.syntax.EncoderOps @@ -35,7 +34,6 @@ import java.time.Instant class DefaultViewSearchSuite extends CatsEffectSuite - with BioRunContext with ElasticSearchClientSetup.Fixture with TestHelpers with CirceLiteral diff --git a/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/GraphAnalyticsSinkSuite.scala b/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/GraphAnalyticsSinkSuite.scala index 41670020f0..836b3d4719 100644 --- a/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/GraphAnalyticsSinkSuite.scala +++ b/delta/plugins/graph-analytics/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/graph/analytics/indexing/GraphAnalyticsSinkSuite.scala @@ -15,7 +15,6 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.Anonymous import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef import ch.epfl.bluebrain.nexus.delta.sourcing.offset.Offset import ch.epfl.bluebrain.nexus.delta.sourcing.stream.Elem.{FailedElem, SuccessElem} -import ch.epfl.bluebrain.nexus.testkit.bio.BioRunContext import ch.epfl.bluebrain.nexus.testkit.mu.ce.{CatsEffectSuite, PatienceConfig} import ch.epfl.bluebrain.nexus.testkit.{CirceLiteral, TestHelpers} import fs2.Chunk @@ -27,7 +26,6 @@ import scala.concurrent.duration._ class GraphAnalyticsSinkSuite extends CatsEffectSuite - with BioRunContext with ElasticSearchClientSetup.Fixture with CirceLiteral with TestHelpers { diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/files/FilesSpec.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/files/FilesSpec.scala index c61812b06b..404d8e4f26 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/files/FilesSpec.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/files/FilesSpec.scala @@ -38,7 +38,6 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.{Anonymous, Authent import ch.epfl.bluebrain.nexus.delta.sourcing.model.Tag.UserTag import ch.epfl.bluebrain.nexus.delta.sourcing.model.{Label, ProjectRef, ResourceRef} import ch.epfl.bluebrain.nexus.delta.sourcing.postgres.DoobieScalaTestFixture -import ch.epfl.bluebrain.nexus.testkit.bio.BioRunContext import ch.epfl.bluebrain.nexus.testkit.remotestorage.RemoteStorageDocker import ch.epfl.bluebrain.nexus.testkit.scalatest.ce.CatsEffectSpec import org.scalatest.concurrent.Eventually @@ -50,7 +49,6 @@ import java.net.URLDecoder class FilesSpec(docker: RemoteStorageDocker) extends TestKit(ActorSystem("FilesSpec")) with CatsEffectSpec - with BioRunContext with DoobieScalaTestFixture with ConfigFixtures with StorageFixtures diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/statistics/StoragesStatisticsSuite.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/statistics/StoragesStatisticsSuite.scala index 6eb0f46cf1..825e014a11 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/statistics/StoragesStatisticsSuite.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/statistics/StoragesStatisticsSuite.scala @@ -13,7 +13,6 @@ import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri import ch.epfl.bluebrain.nexus.delta.sourcing.stream.SupervisorSetup import ch.epfl.bluebrain.nexus.delta.sourcing.stream.SupervisorSetup.unapply import ch.epfl.bluebrain.nexus.testkit.TestHelpers -import ch.epfl.bluebrain.nexus.testkit.bio.BioRunContext import ch.epfl.bluebrain.nexus.testkit.mu.ce.{CatsEffectSuite, PatienceConfig} import munit.AnyFixture @@ -21,7 +20,6 @@ import scala.concurrent.duration.DurationInt class StoragesStatisticsSuite extends CatsEffectSuite - with BioRunContext with ElasticSearchClientSetup.Fixture with SupervisorSetup.Fixture with TestHelpers diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/client/RemoteStorageClientSpec.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/client/RemoteStorageClientSpec.scala index 8a434177d7..365c8f1011 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/client/RemoteStorageClientSpec.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/client/RemoteStorageClientSpec.scala @@ -16,7 +16,6 @@ import ch.epfl.bluebrain.nexus.delta.sdk.http.{HttpClient, HttpClientConfig} import ch.epfl.bluebrain.nexus.delta.sdk.model.ComponentDescription.ServiceDescription import ch.epfl.bluebrain.nexus.delta.sdk.model.{BaseUri, Name} import ch.epfl.bluebrain.nexus.delta.sourcing.model.Label -import ch.epfl.bluebrain.nexus.testkit.bio.BioRunContext import ch.epfl.bluebrain.nexus.testkit.remotestorage.RemoteStorageDocker import ch.epfl.bluebrain.nexus.testkit.remotestorage.RemoteStorageDocker.BucketName import ch.epfl.bluebrain.nexus.testkit.scalatest.ce.CatsEffectSpec @@ -27,7 +26,6 @@ import org.scalatest.{BeforeAndAfterAll, DoNotDiscover} class RemoteStorageClientSpec(docker: RemoteStorageDocker) extends TestKit(ActorSystem("RemoteStorageClientSpec")) with CatsEffectSpec - with BioRunContext with AkkaSourceHelpers with Eventually with BeforeAndAfterAll diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/bio/BioRunContext.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/bio/BioRunContext.scala deleted file mode 100644 index fd94c3649a..0000000000 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/bio/BioRunContext.scala +++ /dev/null @@ -1,7 +0,0 @@ -package ch.epfl.bluebrain.nexus.testkit.bio - -import monix.execution.Scheduler - -trait BioRunContext { - implicit protected val scheduler: Scheduler = Scheduler.global -} diff --git a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/ce/CatsEffectSuite.scala b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/ce/CatsEffectSuite.scala index 53822d14ef..01bfe504f9 100644 --- a/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/ce/CatsEffectSuite.scala +++ b/delta/testkit/src/main/scala/ch/epfl/bluebrain/nexus/testkit/mu/ce/CatsEffectSuite.scala @@ -4,8 +4,6 @@ import cats.effect.IO import ch.epfl.bluebrain.nexus.testkit.ce.CatsRunContext import ch.epfl.bluebrain.nexus.testkit.clock.FixedClock import ch.epfl.bluebrain.nexus.testkit.mu.{CollectionAssertions, EitherAssertions, EitherValues, NexusSuite} -import monix.bio.{IO => BIO} -import monix.execution.Scheduler import scala.concurrent.duration.{DurationInt, FiniteDuration} @@ -26,7 +24,7 @@ abstract class CatsEffectSuite protected val ioTimeout: FiniteDuration = 45.seconds override def munitValueTransforms: List[ValueTransform] = - super.munitValueTransforms ++ List(munitIOTransform, munitBIOTransform) + super.munitValueTransforms ++ List(munitIOTransform) private val munitIOTransform: ValueTransform = { new ValueTransform( @@ -36,23 +34,4 @@ abstract class CatsEffectSuite } ) } - - private val munitBIOTransform: ValueTransform = { - implicit val scheduler: Scheduler = Scheduler.global - new ValueTransform( - "BIO", - { case io: BIO[_, _] => - io.timeout(ioTimeout) - .mapError { - case t: Throwable => t - case other => - fail( - s"""Error caught of type '${other.getClass.getName}', expected a successful response - |Error value: $other""".stripMargin - ) - } - .runToFuture - } - ) - } } From 6795958c22fd66a0a835ae061a1347d9a4c18646 Mon Sep 17 00:00:00 2001 From: Daniel Bell Date: Thu, 9 Nov 2023 17:26:19 +0100 Subject: [PATCH 17/18] Remove monix as a dependency :D --- build.sbt | 9 --------- 1 file changed, 9 deletions(-) diff --git a/build.sbt b/build.sbt index c148a7e78b..fd46a2de7c 100755 --- a/build.sbt +++ b/build.sbt @@ -47,8 +47,6 @@ val log4catsVersion = "1.7.0" val logbackVersion = "1.4.11" val magnoliaVersion = "1.1.6" val mockitoVersion = "1.17.27" -val monixVersion = "3.4.1" -val monixBioVersion = "1.2.0" val munitVersion = "1.0.0-M10" val nimbusJoseJwtVersion = "9.37" val postgresJdbcVersion = "42.6.0" @@ -113,7 +111,6 @@ lazy val log4cats = "org.typelevel" %% "log4cats-slf4j" lazy val logback = "ch.qos.logback" % "logback-classic" % logbackVersion lazy val magnolia = "com.softwaremill.magnolia1_2" %% "magnolia" % magnoliaVersion lazy val mockito = "org.mockito" %% "mockito-scala" % mockitoVersion -lazy val monixBio = "io.monix" %% "monix-bio" % monixBioVersion lazy val munit = "org.scalameta" %% "munit" % munitVersion lazy val nimbusJoseJwt = "com.nimbusds" % "nimbus-jose-jwt" % nimbusJoseJwtVersion lazy val pureconfig = "com.github.pureconfig" %% "pureconfig" % pureconfigVersion @@ -212,7 +209,6 @@ lazy val kernel = project circeCore, circeParser, handleBars, - monixBio, nimbusJoseJwt, kamonCore, log4cats, @@ -242,7 +238,6 @@ lazy val testkit = project ), catsRetry, doobiePostgres, - monixBio, munit, scalaTest, testContainers @@ -267,7 +262,6 @@ lazy val sourcingPsql = project distageCore, fs2, fs2io, - monixBio, munit % Test, catsEffectLaws % Test, logback % Test @@ -295,7 +289,6 @@ lazy val rdf = project jenaArq, jsonldjava, magnolia, - monixBio, topBraidShacl, akkaSlf4j % Test, akkaTestKit % Test, @@ -325,7 +318,6 @@ lazy val sdk = project circeGenericExtras, distageCore, fs2, - monixBio, akkaTestKitTyped % Test, akkaHttpTestKit % Test, munit % Test, @@ -804,7 +796,6 @@ lazy val tests = project circeGenericExtras, fs2, logback, - monixBio, scalaLogging, akkaTestKit % Test, akkaHttpTestKit % Test, From eb376e12c20381543da38e848d18868285d1ddd6 Mon Sep 17 00:00:00 2001 From: Daniel Bell Date: Thu, 9 Nov 2023 17:26:45 +0100 Subject: [PATCH 18/18] scalafmt --- .../plugins/blazegraph/indexing/BlazegraphSinkSuite.scala | 5 +---- .../elasticsearch/indexing/ElasticSearchSinkSuite.scala | 5 +---- .../plugins/projectdeletion/ProjectDeletionRoutesSpec.scala | 6 +----- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/indexing/BlazegraphSinkSuite.scala b/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/indexing/BlazegraphSinkSuite.scala index 71721a18d7..6deb0be71a 100644 --- a/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/indexing/BlazegraphSinkSuite.scala +++ b/delta/plugins/blazegraph/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/blazegraph/indexing/BlazegraphSinkSuite.scala @@ -20,10 +20,7 @@ import munit.AnyFixture import java.time.Instant import scala.concurrent.duration._ -class BlazegraphSinkSuite - extends CatsEffectSuite - with BlazegraphClientSetup.Fixture - with TestHelpers { +class BlazegraphSinkSuite extends CatsEffectSuite with BlazegraphClientSetup.Fixture with TestHelpers { override def munitFixtures: Seq[AnyFixture[_]] = List(blazegraphClient) diff --git a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/indexing/ElasticSearchSinkSuite.scala b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/indexing/ElasticSearchSinkSuite.scala index 93d5ab758d..046842f969 100644 --- a/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/indexing/ElasticSearchSinkSuite.scala +++ b/delta/plugins/elasticsearch/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/indexing/ElasticSearchSinkSuite.scala @@ -21,10 +21,7 @@ import munit.AnyFixture import java.time.Instant import scala.concurrent.duration._ -class ElasticSearchSinkSuite - extends CatsEffectSuite - with ElasticSearchClientSetup.Fixture - with CirceLiteral { +class ElasticSearchSinkSuite extends CatsEffectSuite with ElasticSearchClientSetup.Fixture with CirceLiteral { override def munitFixtures: Seq[AnyFixture[_]] = List(esClient) diff --git a/delta/plugins/project-deletion/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/projectdeletion/ProjectDeletionRoutesSpec.scala b/delta/plugins/project-deletion/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/projectdeletion/ProjectDeletionRoutesSpec.scala index 373742d6ec..9e67e9b6dc 100644 --- a/delta/plugins/project-deletion/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/projectdeletion/ProjectDeletionRoutesSpec.scala +++ b/delta/plugins/project-deletion/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/projectdeletion/ProjectDeletionRoutesSpec.scala @@ -14,11 +14,7 @@ import org.scalatest.matchers.should.Matchers import scala.concurrent.duration.DurationInt -class ProjectDeletionRoutesSpec - extends RouteHelpers - with CirceMarshalling - with Matchers - with TestHelpers { +class ProjectDeletionRoutesSpec extends RouteHelpers with CirceMarshalling with Matchers with TestHelpers { implicit private val cl: ClassLoader = getClass.getClassLoader implicit private val ordering: JsonKeyOrdering = JsonKeyOrdering.default()