From 92b72b8bf7a63f7cd7d86daddb65f8479f068c79 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sun, 8 Oct 2023 09:40:41 +0100 Subject: [PATCH] compile issues --- sqs/src/test/scala/docs/scaladsl/SqsAckSpec.scala | 14 +++++++++++--- .../test/scala/docs/scaladsl/SqsSourceSpec.scala | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/sqs/src/test/scala/docs/scaladsl/SqsAckSpec.scala b/sqs/src/test/scala/docs/scaladsl/SqsAckSpec.scala index 2751a01e2..7b9835fb4 100644 --- a/sqs/src/test/scala/docs/scaladsl/SqsAckSpec.scala +++ b/sqs/src/test/scala/docs/scaladsl/SqsAckSpec.scala @@ -15,7 +15,6 @@ package docs.scaladsl import java.util.concurrent.{ CompletableFuture, TimeUnit } import java.util.function.Supplier - import org.apache.pekko import pekko.Done import pekko.stream.connectors.sqs.scaladsl._ @@ -25,8 +24,10 @@ import pekko.stream.connectors.sqs.SqsAckResultEntry._ import pekko.stream.connectors.testkit.scaladsl.LogCapturing import pekko.stream.scaladsl.{ Sink, Source } import pekko.util.ccompat.JavaConverters._ +import org.mockito.Answers import org.mockito.ArgumentMatchers.any -import org.mockito.Mockito.{ spy, times, verify, when } +import org.mockito.Mockito.{ times, verify, when, withSettings } +import org.mockito.internal.MockitoCore import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers import org.scalatestplus.mockito.MockitoSugar.mock @@ -39,7 +40,14 @@ class SqsAckSpec extends AnyFlatSpec with Matchers with DefaultTestContext with trait IntegrationFixture { val queueUrl: String = randomQueueUrl() - implicit val awsSqsClient: SqsAsyncClient = spy(sqsClient) + implicit val awsSqsClient: SqsAsyncClient = spyInternal(sqsClient) + + // spyInternal was created due to compile problems using Mockito 4.11 in Scala 2.12 + private val mockitoCore = new MockitoCore + private def spyInternal[T](t: T): T = + mockitoCore.mock(t.getClass.asInstanceOf[Class[T]], + withSettings.spiedInstance(t) + .defaultAnswer(Answers.CALLS_REAL_METHODS)) def sendMessage(message: String): Unit = { def request = diff --git a/sqs/src/test/scala/docs/scaladsl/SqsSourceSpec.scala b/sqs/src/test/scala/docs/scaladsl/SqsSourceSpec.scala index 8677c6d25..6b2963dfe 100644 --- a/sqs/src/test/scala/docs/scaladsl/SqsSourceSpec.scala +++ b/sqs/src/test/scala/docs/scaladsl/SqsSourceSpec.scala @@ -48,7 +48,7 @@ class SqsSourceSpec extends AnyFlatSpec with ScalaFutures with Matchers with Def import SqsSourceSpec._ - implicit override val patienceConfig = PatienceConfig(timeout = 10.seconds, interval = 100.millis) + implicit override val patienceConfig: PatienceConfig = PatienceConfig(timeout = 10.seconds, interval = 100.millis) trait IntegrationFixture { val queueUrl: String = randomQueueUrl()