From 538413edfcca29fc6770d476f5077bca0165831f Mon Sep 17 00:00:00 2001 From: Daniel Bell Date: Thu, 9 Nov 2023 16:16:04 +0100 Subject: [PATCH] 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