Skip to content

Small upgrades #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
style = defaultWithAlign

docstrings = JavaDoc
maxColumn = 140
maxColumn = 180
rewrite.rules = [RedundantBraces, RedundantParens, SortImports]
spaces.inImportCurlyBraces = true
indentOperator = spray
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ lazy val commonSettings =
source.close
version.get
},
crossScalaVersions := Seq("2.11.12", "2.12.8", currentScalaVersion),
crossScalaVersions := Seq("2.11.12", "2.12.9", currentScalaVersion),
scalafmtOnCompile := true,
scalacOptions ++= Seq(
"-unchecked",
Expand Down
31 changes: 11 additions & 20 deletions cats/src/main/scala/org/mockito/cats/CatsStubbing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,11 @@ case class CatsStubbing[F[_], T](delegate: OngoingStubbing[F[T]]) {
delegate thenAnswer functionToAnswer(f).andThen(F.pure)
def thenAnswer[P0, P1, P2, P3, P4, P5, P6, P7](f: (P0, P1, P2, P3, P4, P5, P6, P7) => T)(implicit F: Applicative[F]): CatsStubbing[F, T] =
delegate thenAnswer functionToAnswer(f).andThen(F.pure)
def thenAnswer[P0, P1, P2, P3, P4, P5, P6, P7, P8](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8) => T)(
implicit F: Applicative[F]): CatsStubbing[F, T] =
def thenAnswer[P0, P1, P2, P3, P4, P5, P6, P7, P8](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8) => T)(implicit F: Applicative[F]): CatsStubbing[F, T] =
delegate thenAnswer functionToAnswer(f).andThen(F.pure)
def thenAnswer[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) => T)(
implicit F: Applicative[F]): CatsStubbing[F, T] =
def thenAnswer[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) => T)(implicit F: Applicative[F]): CatsStubbing[F, T] =
delegate thenAnswer functionToAnswer(f).andThen(F.pure)
def thenAnswer[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) => T)(
implicit F: Applicative[F]): CatsStubbing[F, T] =
def thenAnswer[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) => T)(implicit F: Applicative[F]): CatsStubbing[F, T] =
delegate thenAnswer functionToAnswer(f).andThen(F.pure)

def thenFailWith[E](error: E)(implicit F: ApplicativeError[F, _ >: E]): CatsStubbing[F, T] =
Expand All @@ -65,8 +62,7 @@ case class CatsStubbing2[F[_], G[_], T](delegate: OngoingStubbing[F[G[T]]]) {

def thenAnswer(f: => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
delegate thenAnswer invocationToAnswer(_ => f).andThen(F.compose[G].pure)
def thenAnswer[P0](
f: P0 => T)(implicit classTag: ClassTag[P0] = defaultClassTag[P0], F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
def thenAnswer[P0](f: P0 => T)(implicit classTag: ClassTag[P0] = defaultClassTag[P0], F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
clazz[P0] match {
case c if c == classOf[InvocationOnMock] =>
delegate thenAnswer invocationToAnswer(i => f(i.asInstanceOf[P0])).andThen(F.compose[G].pure)
Expand All @@ -80,23 +76,18 @@ case class CatsStubbing2[F[_], G[_], T](delegate: OngoingStubbing[F[G[T]]]) {
delegate thenAnswer functionToAnswer(f).andThen(F.compose[G].pure)
def thenAnswer[P0, P1, P2, P3, P4](f: (P0, P1, P2, P3, P4) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
delegate thenAnswer functionToAnswer(f).andThen(F.compose[G].pure)
def thenAnswer[P0, P1, P2, P3, P4, P5](f: (P0, P1, P2, P3, P4, P5) => T)(implicit F: Applicative[F],
G: Applicative[G]): CatsStubbing2[F, G, T] =
def thenAnswer[P0, P1, P2, P3, P4, P5](f: (P0, P1, P2, P3, P4, P5) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
delegate thenAnswer functionToAnswer(f).andThen(F.compose[G].pure)
def thenAnswer[P0, P1, P2, P3, P4, P5, P6](f: (P0, P1, P2, P3, P4, P5, P6) => T)(implicit F: Applicative[F],
G: Applicative[G]): CatsStubbing2[F, G, T] =
def thenAnswer[P0, P1, P2, P3, P4, P5, P6](f: (P0, P1, P2, P3, P4, P5, P6) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
delegate thenAnswer functionToAnswer(f).andThen(F.compose[G].pure)
def thenAnswer[P0, P1, P2, P3, P4, P5, P6, P7](f: (P0, P1, P2, P3, P4, P5, P6, P7) => T)(implicit F: Applicative[F],
G: Applicative[G]): CatsStubbing2[F, G, T] =
def thenAnswer[P0, P1, P2, P3, P4, P5, P6, P7](f: (P0, P1, P2, P3, P4, P5, P6, P7) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
delegate thenAnswer functionToAnswer(f).andThen(F.compose[G].pure)
def thenAnswer[P0, P1, P2, P3, P4, P5, P6, P7, P8](
f: (P0, P1, P2, P3, P4, P5, P6, P7, P8) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
def thenAnswer[P0, P1, P2, P3, P4, P5, P6, P7, P8](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
delegate thenAnswer functionToAnswer(f).andThen(F.compose[G].pure)
def thenAnswer[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9](
f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
def thenAnswer[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
delegate thenAnswer functionToAnswer(f).andThen(F.compose[G].pure)
def thenAnswer[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10](
f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
def thenAnswer[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) => T)(implicit F: Applicative[F],
G: Applicative[G]): CatsStubbing2[F, G, T] =
delegate thenAnswer functionToAnswer(f).andThen(F.compose[G].pure)

def thenFailWith[E](error: E)(implicit ae: Applicative[F], ag: ApplicativeError[G, _ >: E]): CatsStubbing2[F, G, T] =
Expand Down
31 changes: 11 additions & 20 deletions cats/src/main/scala/org/mockito/cats/IdiomaticMockitoCats.scala
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,19 @@ object IdiomaticMockitoCats extends IdiomaticMockitoCats {
def apply[P0, P1, P2, P3, P4, P5, P6, P7](f: (P0, P1, P2, P3, P4, P5, P6, P7) => T)(implicit F: Applicative[F]): CatsStubbing[F, T] =
os thenAnswer f

def apply[P0, P1, P2, P3, P4, P5, P6, P7, P8](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8) => T)(
implicit F: Applicative[F]): CatsStubbing[F, T] = os thenAnswer f
def apply[P0, P1, P2, P3, P4, P5, P6, P7, P8](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8) => T)(implicit F: Applicative[F]): CatsStubbing[F, T] = os thenAnswer f

def apply[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) => T)(
implicit F: Applicative[F]): CatsStubbing[F, T] =
def apply[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) => T)(implicit F: Applicative[F]): CatsStubbing[F, T] =
os thenAnswer f

def apply[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) => T)(
implicit F: Applicative[F]): CatsStubbing[F, T] =
def apply[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) => T)(implicit F: Applicative[F]): CatsStubbing[F, T] =
os thenAnswer f
}

class AnswerActions2[F[_], G[_], T](os: CatsStubbing2[F, G, T]) {
def apply(f: => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] = os thenAnswer f

def apply[P0](
f: P0 => T)(implicit classTag: ClassTag[P0] = defaultClassTag[P0], F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
def apply[P0](f: P0 => T)(implicit classTag: ClassTag[P0] = defaultClassTag[P0], F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
os thenAnswer f

def apply[P0, P1](f: (P0, P1) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] = os thenAnswer f
Expand All @@ -207,27 +203,22 @@ object IdiomaticMockitoCats extends IdiomaticMockitoCats {
def apply[P0, P1, P2, P3, P4](f: (P0, P1, P2, P3, P4) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
os thenAnswer f

def apply[P0, P1, P2, P3, P4, P5](f: (P0, P1, P2, P3, P4, P5) => T)(implicit F: Applicative[F],
G: Applicative[G]): CatsStubbing2[F, G, T] = os thenAnswer f
def apply[P0, P1, P2, P3, P4, P5](f: (P0, P1, P2, P3, P4, P5) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] = os thenAnswer f

def apply[P0, P1, P2, P3, P4, P5, P6](f: (P0, P1, P2, P3, P4, P5, P6) => T)(implicit F: Applicative[F],
G: Applicative[G]): CatsStubbing2[F, G, T] =
def apply[P0, P1, P2, P3, P4, P5, P6](f: (P0, P1, P2, P3, P4, P5, P6) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
os thenAnswer f

def apply[P0, P1, P2, P3, P4, P5, P6, P7](f: (P0, P1, P2, P3, P4, P5, P6, P7) => T)(implicit F: Applicative[F],
G: Applicative[G]): CatsStubbing2[F, G, T] =
def apply[P0, P1, P2, P3, P4, P5, P6, P7](f: (P0, P1, P2, P3, P4, P5, P6, P7) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
os thenAnswer f

def apply[P0, P1, P2, P3, P4, P5, P6, P7, P8](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8) => T)(implicit F: Applicative[F],
G: Applicative[G]): CatsStubbing2[F, G, T] =
def apply[P0, P1, P2, P3, P4, P5, P6, P7, P8](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
os thenAnswer f

def apply[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9](
f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
def apply[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
os thenAnswer f

def apply[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10](
f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
def apply[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) => T)(implicit F: Applicative[F],
G: Applicative[G]): CatsStubbing2[F, G, T] =
os thenAnswer f
}
}
15 changes: 5 additions & 10 deletions cats/src/main/scala/org/mockito/cats/MockitoCats.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ trait MockitoCats extends ScalacticSerialisableHack {
Mockito.doAnswer(functionToAnswer(f).andThen(Applicative[F].pure))
def doAnswerF[F[_]: Applicative, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, R](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) => R): Stubber =
Mockito.doAnswer(functionToAnswer(f).andThen(Applicative[F].pure))
def doAnswerF[F[_]: Applicative, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, R](
f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) => R): Stubber =
def doAnswerF[F[_]: Applicative, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, R](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) => R): Stubber =
Mockito.doAnswer(functionToAnswer(f).andThen(Applicative[F].pure))

def doAnswerFG[F[_]: Applicative, G[_]: Applicative, R](l: => R): Stubber =
Expand Down Expand Up @@ -103,17 +102,13 @@ trait MockitoCats extends ScalacticSerialisableHack {
Mockito.doAnswer(functionToAnswer(f).andThen(Applicative[F].compose[G].pure))
def doAnswerFG[F[_]: Applicative, G[_]: Applicative, P0, P1, P2, P3, P4, P5, P6, R](f: (P0, P1, P2, P3, P4, P5, P6) => R): Stubber =
Mockito.doAnswer(functionToAnswer(f).andThen(Applicative[F].compose[G].pure))
def doAnswerFG[F[_]: Applicative, G[_]: Applicative, P0, P1, P2, P3, P4, P5, P6, P7, R](
f: (P0, P1, P2, P3, P4, P5, P6, P7) => R): Stubber =
def doAnswerFG[F[_]: Applicative, G[_]: Applicative, P0, P1, P2, P3, P4, P5, P6, P7, R](f: (P0, P1, P2, P3, P4, P5, P6, P7) => R): Stubber =
Mockito.doAnswer(functionToAnswer(f).andThen(Applicative[F].compose[G].pure))
def doAnswerFG[F[_]: Applicative, G[_]: Applicative, P0, P1, P2, P3, P4, P5, P6, P7, P8, R](
f: (P0, P1, P2, P3, P4, P5, P6, P7, P8) => R): Stubber =
def doAnswerFG[F[_]: Applicative, G[_]: Applicative, P0, P1, P2, P3, P4, P5, P6, P7, P8, R](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8) => R): Stubber =
Mockito.doAnswer(functionToAnswer(f).andThen(Applicative[F].compose[G].pure))
def doAnswerFG[F[_]: Applicative, G[_]: Applicative, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, R](
f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) => R): Stubber =
def doAnswerFG[F[_]: Applicative, G[_]: Applicative, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, R](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) => R): Stubber =
Mockito.doAnswer(functionToAnswer(f).andThen(Applicative[F].compose[G].pure))
def doAnswerFG[F[_]: Applicative, G[_]: Applicative, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, R](
f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) => R): Stubber =
def doAnswerFG[F[_]: Applicative, G[_]: Applicative, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, R](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) => R): Stubber =
Mockito.doAnswer(functionToAnswer(f).andThen(Applicative[F].compose[G].pure))

implicit def catsEquality[T: Eq]: Equality[T] = new EqToEquality[T]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class DoSomethingCatsTest

"mocked!" willBe answeredF by aMock.returnsOptionString("hello")
((s: String) => s + " mocked!") willBe answeredF by aMock.returnsOptionString("hi")
((i: InvocationOnMock) => i.getArgument[String](0) + " invocation mocked!") willBe answeredF by aMock.returnsOptionString("hola")
((i: InvocationOnMock) => i.arg[String](0) + " invocation mocked!") willBe answeredF by aMock.returnsOptionString("hola")
((i: Int, b: Boolean) => s"$i, $b") willBe answeredF by aMock.returnsOptionFrom(42, true)

aMock.returnsOptionString("hello").value shouldBe "mocked!"
Expand All @@ -120,7 +120,7 @@ class DoSomethingCatsTest

ValueClass("mocked!") willBe answeredFG by aMock.returnsFutureEither("hello")
((s: String) => ValueClass(s + " mocked!")) willBe answeredFG by aMock.returnsFutureEither("hi")
((i: InvocationOnMock) => ValueClass(i.getArgument[String](0) + " invocation mocked!")) willBe answeredFG by aMock
((i: InvocationOnMock) => ValueClass(i.arg[String](0) + " invocation mocked!")) willBe answeredFG by aMock
.returnsFutureEither("hola")
((i: Int, b: Boolean) => s"$i, $b") willBe answeredFG by aMock.returnsFutureOptionFrom(42, true)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class IdiomaticMockitoCatsTest

aMock.returnsOptionString("hello") answersF "mocked!"
aMock.returnsOptionString("hi") answersF ((s: String) => s + " mocked!")
aMock.returnsOptionString("hola") answersF ((i: InvocationOnMock) => i.getArgument[String](0) + " invocation mocked!")
aMock.returnsOptionString("hola") answersF ((i: InvocationOnMock) => i.arg[String](0) + " invocation mocked!")
aMock.returnsOptionFrom(42, true) answersF ((i: Int, b: Boolean) => s"$i, $b")

aMock.returnsOptionString("hello").value shouldBe "mocked!"
Expand All @@ -156,7 +156,7 @@ class IdiomaticMockitoCatsTest

aMock.returnsFutureEither("hello") answersFG ValueClass("mocked!")
aMock.returnsFutureEither("hi") answersFG ((s: String) => ValueClass(s + " mocked!"))
aMock.returnsFutureEither("hola") answersFG ((i: InvocationOnMock) => ValueClass(i.getArgument[String](0) + " invocation mocked!"))
aMock.returnsFutureEither("hola") answersFG ((i: InvocationOnMock) => ValueClass(i.arg[String](0) + " invocation mocked!"))
aMock.returnsFutureOptionFrom(42, true) answersFG ((i: Int, b: Boolean) => s"$i, $b")

whenReady(aMock.returnsFutureEither("hello"))(_.right.value shouldBe ValueClass("mocked!"))
Expand Down
19 changes: 5 additions & 14 deletions cats/src/test/scala/org/mockito/cats/MockitoCatsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,7 @@ import org.scalatest.{ EitherValues, Matchers, OptionValues, WordSpec }
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

class MockitoCatsTest
extends WordSpec
with Matchers
with MockitoSugar
with ArgumentMatchersSugar
with MockitoCats
with EitherValues
with OptionValues
with ScalaFutures {
class MockitoCatsTest extends WordSpec with Matchers with MockitoSugar with ArgumentMatchersSugar with MockitoCats with EitherValues with OptionValues with ScalaFutures {

"when - return" should {
"stub full applicative" in {
Expand Down Expand Up @@ -128,7 +120,7 @@ class MockitoCatsTest

whenF(aMock.returnsOptionString("hello")) thenAnswer "mocked!"
whenF(aMock.returnsOptionString("hi")) thenAnswer ((s: String) => s + " mocked!")
whenF(aMock.returnsOptionString("hola")) thenAnswer ((i: InvocationOnMock) => i.getArgument[String](0) + " invocation mocked!")
whenF(aMock.returnsOptionString("hola")) thenAnswer ((i: InvocationOnMock) => i.arg[String](0) + " invocation mocked!")
whenF(aMock.returnsOptionFrom(42, true)) thenAnswer ((i: Int, b: Boolean) => s"$i, $b")

aMock.returnsOptionString("hello").value shouldBe "mocked!"
Expand All @@ -142,8 +134,7 @@ class MockitoCatsTest

whenFG(aMock.returnsFutureEither("hello")) thenAnswer ValueClass("mocked!")
whenFG(aMock.returnsFutureEither("hi")) thenAnswer ((s: String) => ValueClass(s + " mocked!"))
whenFG(aMock.returnsFutureEither("hola")) thenAnswer ((i: InvocationOnMock) =>
ValueClass(i.getArgument[String](0) + " invocation mocked!"))
whenFG(aMock.returnsFutureEither("hola")) thenAnswer ((i: InvocationOnMock) => ValueClass(i.arg[String](0) + " invocation mocked!"))
whenFG(aMock.returnsFutureOptionFrom(42, true)) thenAnswer ((i: Int, b: Boolean) => s"$i, $b")

whenReady(aMock.returnsFutureEither("hello"))(_.right.value shouldBe ValueClass("mocked!"))
Expand Down Expand Up @@ -243,7 +234,7 @@ class MockitoCatsTest

doAnswerF[Option, String]("mocked!").when(aMock).returnsOptionString("hello")
doAnswerF[Option, String, String]((s: String) => s + " mocked!").when(aMock).returnsOptionString("hi")
doAnswerF[Option, InvocationOnMock, String]((i: InvocationOnMock) => i.getArgument[String](0) + " invocation mocked!")
doAnswerF[Option, InvocationOnMock, String]((i: InvocationOnMock) => i.arg[String](0) + " invocation mocked!")
.when(aMock)
.returnsOptionString("hola")
doAnswerF[Option, Int, Boolean, String]((i: Int, b: Boolean) => s"$i, $b").when(aMock).returnsOptionFrom(42, true)
Expand All @@ -260,7 +251,7 @@ class MockitoCatsTest
doAnswerFG[Future, ErrorOr, ValueClass](ValueClass("mocked!")).when(aMock).returnsFutureEither("hello")
doAnswerFG[Future, ErrorOr, String, ValueClass]((s: String) => ValueClass(s + " mocked!")).when(aMock).returnsFutureEither("hi")
doAnswerFG[Future, ErrorOr, InvocationOnMock, ValueClass] { i: InvocationOnMock =>
ValueClass(i.getArgument[String](0) + " invocation mocked!")
ValueClass(i.arg[String](0) + " invocation mocked!")
}.when(aMock)
.returnsFutureEither("hola")
doAnswerFG[Future, Option, Int, Boolean, String]((i: Int, b: Boolean) => s"$i, $b").when(aMock).returnsFutureOptionFrom(42, true)
Expand Down
Loading