diff --git a/article-api/src/test/scala/no/ndla/articleapi/TestEnvironment.scala b/article-api/src/test/scala/no/ndla/articleapi/TestEnvironment.scala index 1b74dcabb8..3db6b7fe66 100644 --- a/article-api/src/test/scala/no/ndla/articleapi/TestEnvironment.scala +++ b/article-api/src/test/scala/no/ndla/articleapi/TestEnvironment.scala @@ -26,7 +26,7 @@ import no.ndla.network.NdlaClient import no.ndla.network.clients.{FeideApiClient, RedisClient} import no.ndla.network.scalatra.{NdlaControllerBase, NdlaSwaggerSupport} import no.ndla.search.{BaseIndexService, Elastic4sClient, NdlaE4sClient} -import org.mockito.scalatest.MockitoSugar +import org.scalatestplus.mockito.MockitoSugar trait TestEnvironment extends Elastic4sClient diff --git a/oembed-proxy/src/test/scala/no/ndla/oembedproxy/TestEnvironment.scala b/oembed-proxy/src/test/scala/no/ndla/oembedproxy/TestEnvironment.scala index cbb6676f5d..ae095d9b1a 100644 --- a/oembed-proxy/src/test/scala/no/ndla/oembedproxy/TestEnvironment.scala +++ b/oembed-proxy/src/test/scala/no/ndla/oembedproxy/TestEnvironment.scala @@ -14,7 +14,8 @@ import no.ndla.oembedproxy.caching.MemoizeHelpers import no.ndla.oembedproxy.controller.{HealthController, OEmbedProxyController} import no.ndla.oembedproxy.model.ErrorHelpers import no.ndla.oembedproxy.service.{OEmbedServiceComponent, ProviderService} -import org.mockito.scalatest.MockitoSugar +import org.mockito.Mockito.reset +import org.scalatestplus.mockito.MockitoSugar trait TestEnvironment extends OEmbedProxyController diff --git a/oembed-proxy/src/test/scala/no/ndla/oembedproxy/UnitSuite.scala b/oembed-proxy/src/test/scala/no/ndla/oembedproxy/UnitSuite.scala index 337f839144..38782134cf 100644 --- a/oembed-proxy/src/test/scala/no/ndla/oembedproxy/UnitSuite.scala +++ b/oembed-proxy/src/test/scala/no/ndla/oembedproxy/UnitSuite.scala @@ -8,10 +8,10 @@ package no.ndla.oembedproxy -import org.mockito.scalatest.MockitoSugar import org.scalatest._ import org.scalatest.funsuite.AnyFunSuite import org.scalatest.matchers.should.Matchers +import org.scalatestplus.mockito.MockitoSugar abstract class UnitSuite extends AnyFunSuite diff --git a/oembed-proxy/src/test/scala/no/ndla/oembedproxy/caching/MemoizeTest.scala b/oembed-proxy/src/test/scala/no/ndla/oembedproxy/caching/MemoizeTest.scala index ba74f2ec2d..90bdcdaef1 100644 --- a/oembed-proxy/src/test/scala/no/ndla/oembedproxy/caching/MemoizeTest.scala +++ b/oembed-proxy/src/test/scala/no/ndla/oembedproxy/caching/MemoizeTest.scala @@ -10,6 +10,7 @@ package no.ndla.oembedproxy.caching import no.ndla.oembedproxy.UnitSuite import no.ndla.oembedproxy.model.DoNotUpdateMemoizeException +import org.mockito.Mockito._ class MemoizeTest extends UnitSuite { @@ -62,7 +63,7 @@ class MemoizeTest extends UnitSuite { when(targetMock.targetMethod()) .thenReturn("Hello from mock") - .andThenThrow(new DoNotUpdateMemoizeException("Woop")) + .thenThrow(new DoNotUpdateMemoizeException("Woop")) memoizedTarget() should equal("Hello from mock") Thread.sleep(cacheMaxAgeInMs) diff --git a/oembed-proxy/src/test/scala/no/ndla/oembedproxy/controller/OEmbedProxyControllerTest.scala b/oembed-proxy/src/test/scala/no/ndla/oembedproxy/controller/OEmbedProxyControllerTest.scala index 430ec7c9a4..13ddabca11 100644 --- a/oembed-proxy/src/test/scala/no/ndla/oembedproxy/controller/OEmbedProxyControllerTest.scala +++ b/oembed-proxy/src/test/scala/no/ndla/oembedproxy/controller/OEmbedProxyControllerTest.scala @@ -11,7 +11,8 @@ package no.ndla.oembedproxy.controller import no.ndla.network.model.HttpRequestException import no.ndla.oembedproxy.model.OEmbed import no.ndla.oembedproxy.{TestEnvironment, UnitSuite} -import org.mockito.ArgumentMatchers.anyString +import org.mockito.ArgumentMatchers.{any, anyString} +import org.mockito.Mockito.when import org.scalatra.test.scalatest.ScalatraFunSuite import scala.util.{Failure, Success} diff --git a/oembed-proxy/src/test/scala/no/ndla/oembedproxy/service/OEmbedServiceTest.scala b/oembed-proxy/src/test/scala/no/ndla/oembedproxy/service/OEmbedServiceTest.scala index 9fee9c993e..233f7529bc 100644 --- a/oembed-proxy/src/test/scala/no/ndla/oembedproxy/service/OEmbedServiceTest.scala +++ b/oembed-proxy/src/test/scala/no/ndla/oembedproxy/service/OEmbedServiceTest.scala @@ -12,6 +12,8 @@ import no.ndla.network.model.{HttpRequestException, NdlaRequest} import no.ndla.oembedproxy.caching.Memoize import no.ndla.oembedproxy.model._ import no.ndla.oembedproxy.{TestEnvironment, UnitSuite} +import org.mockito.ArgumentMatchers.any +import org.mockito.Mockito._ import org.scalatest.TryValues._ import scala.util.{Failure, Success} diff --git a/oembed-proxy/src/test/scala/no/ndla/oembedproxy/service/ProviderServiceTest.scala b/oembed-proxy/src/test/scala/no/ndla/oembedproxy/service/ProviderServiceTest.scala index 5e05501c97..74d7cb7d06 100644 --- a/oembed-proxy/src/test/scala/no/ndla/oembedproxy/service/ProviderServiceTest.scala +++ b/oembed-proxy/src/test/scala/no/ndla/oembedproxy/service/ProviderServiceTest.scala @@ -11,6 +11,8 @@ package no.ndla.oembedproxy.service import no.ndla.network.model.{HttpRequestException, NdlaRequest} import no.ndla.oembedproxy.model._ import no.ndla.oembedproxy.{TestEnvironment, UnitSuite} +import org.mockito.ArgumentMatchers.any +import org.mockito.Mockito.when import sttp.client3.quick._ import scala.util.{Failure, Success} diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 9c6de5f9f2..7ccaeb1a9c 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -56,18 +56,18 @@ object Dependencies { hikari ) - private lazy val scalaTestAndMockitoBase: Seq[ModuleID] = Seq( - "org.scalatest" %% "scalatest" % ScalaTestV, - "org.mockito" %% "mockito-scala" % MockitoV, - "org.mockito" %% "mockito-scala-scalatest" % MockitoV - ) - /** This should only be used if we want to include scalatest and mockito in the main build (not only tests). * Otherwise use [[scalaTestAndMockito]] */ - lazy val scalaTestAndMockitoInMain = scalaTestAndMockitoBase.map(_ cross CrossVersion.for3Use2_13) + lazy val scalaTestAndMockitoInMain = Seq( + "org.scalatest" %% "scalatest" % ScalaTestV, + "org.scalatestplus" %% "mockito-4-6" % "3.2.15.0" + ) - lazy val scalaTestAndMockito = scalaTestAndMockitoInMain.map(_ % "test" cross CrossVersion.for3Use2_13) + lazy val scalaTestAndMockito = Seq( + "org.scalatest" %% "scalatest" % ScalaTestV % "test", + "org.scalatestplus" %% "mockito-4-6" % "3.2.15.0" % "test" + ) lazy val scalaTsi = "com.scalatsi" %% "scala-tsi" % ScalaTsiV diff --git a/scalatestsuite/src/main/scala/no/ndla/scalatestsuite/UnitTestSuite.scala b/scalatestsuite/src/main/scala/no/ndla/scalatestsuite/UnitTestSuite.scala index 82515805e6..195e9b0424 100644 --- a/scalatestsuite/src/main/scala/no/ndla/scalatestsuite/UnitTestSuite.scala +++ b/scalatestsuite/src/main/scala/no/ndla/scalatestsuite/UnitTestSuite.scala @@ -7,15 +7,15 @@ package no.ndla.scalatestsuite -import org.mockito.scalatest.MockitoSugar import org.scalatest._ import org.scalatest.funsuite.AnyFunSuite import org.scalatest.matchers.should.Matchers +import org.scalatestplus.mockito.MockitoSugar import java.io.IOException import java.net.ServerSocket import scala.util.Properties.{propOrNone, setProp} -import scala.util.{Try, Success, Failure} +import scala.util.{Failure, Success, Try} abstract class UnitTestSuite extends AnyFunSuite