Skip to content

Commit 79bde87

Browse files
authored
Merge pull request #133 from mockito/small-upgrades
Small upgrades
2 parents ce44f0f + 0b9340a commit 79bde87

File tree

45 files changed

+683
-730
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+683
-730
lines changed

.scalafmt.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
style = defaultWithAlign
22

33
docstrings = JavaDoc
4-
maxColumn = 140
4+
maxColumn = 180
55
rewrite.rules = [RedundantBraces, RedundantParens, SortImports]
66
spaces.inImportCurlyBraces = true
77
indentOperator = spray

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ lazy val commonSettings =
2121
source.close
2222
version.get
2323
},
24-
crossScalaVersions := Seq("2.11.12", "2.12.8", currentScalaVersion),
24+
crossScalaVersions := Seq("2.11.12", "2.12.9", currentScalaVersion),
2525
scalafmtOnCompile := true,
2626
scalacOptions ++= Seq(
2727
"-unchecked",

cats/src/main/scala/org/mockito/cats/CatsStubbing.scala

+11-20
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,11 @@ case class CatsStubbing[F[_], T](delegate: OngoingStubbing[F[T]]) {
3333
delegate thenAnswer functionToAnswer(f).andThen(F.pure)
3434
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] =
3535
delegate thenAnswer functionToAnswer(f).andThen(F.pure)
36-
def thenAnswer[P0, P1, P2, P3, P4, P5, P6, P7, P8](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8) => T)(
37-
implicit F: Applicative[F]): CatsStubbing[F, T] =
36+
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] =
3837
delegate thenAnswer functionToAnswer(f).andThen(F.pure)
39-
def thenAnswer[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) => T)(
40-
implicit F: Applicative[F]): CatsStubbing[F, T] =
38+
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] =
4139
delegate thenAnswer functionToAnswer(f).andThen(F.pure)
42-
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)(
43-
implicit F: Applicative[F]): CatsStubbing[F, T] =
40+
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] =
4441
delegate thenAnswer functionToAnswer(f).andThen(F.pure)
4542

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

6663
def thenAnswer(f: => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
6764
delegate thenAnswer invocationToAnswer(_ => f).andThen(F.compose[G].pure)
68-
def thenAnswer[P0](
69-
f: P0 => T)(implicit classTag: ClassTag[P0] = defaultClassTag[P0], F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
65+
def thenAnswer[P0](f: P0 => T)(implicit classTag: ClassTag[P0] = defaultClassTag[P0], F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
7066
clazz[P0] match {
7167
case c if c == classOf[InvocationOnMock] =>
7268
delegate thenAnswer invocationToAnswer(i => f(i.asInstanceOf[P0])).andThen(F.compose[G].pure)
@@ -80,23 +76,18 @@ case class CatsStubbing2[F[_], G[_], T](delegate: OngoingStubbing[F[G[T]]]) {
8076
delegate thenAnswer functionToAnswer(f).andThen(F.compose[G].pure)
8177
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] =
8278
delegate thenAnswer functionToAnswer(f).andThen(F.compose[G].pure)
83-
def thenAnswer[P0, P1, P2, P3, P4, P5](f: (P0, P1, P2, P3, P4, P5) => T)(implicit F: Applicative[F],
84-
G: Applicative[G]): CatsStubbing2[F, G, T] =
79+
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] =
8580
delegate thenAnswer functionToAnswer(f).andThen(F.compose[G].pure)
86-
def thenAnswer[P0, P1, P2, P3, P4, P5, P6](f: (P0, P1, P2, P3, P4, P5, P6) => T)(implicit F: Applicative[F],
87-
G: Applicative[G]): CatsStubbing2[F, G, T] =
81+
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] =
8882
delegate thenAnswer functionToAnswer(f).andThen(F.compose[G].pure)
89-
def thenAnswer[P0, P1, P2, P3, P4, P5, P6, P7](f: (P0, P1, P2, P3, P4, P5, P6, P7) => T)(implicit F: Applicative[F],
90-
G: Applicative[G]): CatsStubbing2[F, G, T] =
83+
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] =
9184
delegate thenAnswer functionToAnswer(f).andThen(F.compose[G].pure)
92-
def thenAnswer[P0, P1, P2, P3, P4, P5, P6, P7, P8](
93-
f: (P0, P1, P2, P3, P4, P5, P6, P7, P8) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
85+
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] =
9486
delegate thenAnswer functionToAnswer(f).andThen(F.compose[G].pure)
95-
def thenAnswer[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9](
96-
f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
87+
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] =
9788
delegate thenAnswer functionToAnswer(f).andThen(F.compose[G].pure)
98-
def thenAnswer[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10](
99-
f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
89+
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],
90+
G: Applicative[G]): CatsStubbing2[F, G, T] =
10091
delegate thenAnswer functionToAnswer(f).andThen(F.compose[G].pure)
10192

10293
def thenFailWith[E](error: E)(implicit ae: Applicative[F], ag: ApplicativeError[G, _ >: E]): CatsStubbing2[F, G, T] =

cats/src/main/scala/org/mockito/cats/IdiomaticMockitoCats.scala

+11-20
Original file line numberDiff line numberDiff line change
@@ -178,23 +178,19 @@ object IdiomaticMockitoCats extends IdiomaticMockitoCats {
178178
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] =
179179
os thenAnswer f
180180

181-
def apply[P0, P1, P2, P3, P4, P5, P6, P7, P8](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8) => T)(
182-
implicit F: Applicative[F]): CatsStubbing[F, T] = os thenAnswer f
181+
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
183182

184-
def apply[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9](f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) => T)(
185-
implicit F: Applicative[F]): CatsStubbing[F, T] =
183+
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] =
186184
os thenAnswer f
187185

188-
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)(
189-
implicit F: Applicative[F]): CatsStubbing[F, T] =
186+
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] =
190187
os thenAnswer f
191188
}
192189

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

196-
def apply[P0](
197-
f: P0 => T)(implicit classTag: ClassTag[P0] = defaultClassTag[P0], F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
193+
def apply[P0](f: P0 => T)(implicit classTag: ClassTag[P0] = defaultClassTag[P0], F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
198194
os thenAnswer f
199195

200196
def apply[P0, P1](f: (P0, P1) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] = os thenAnswer f
@@ -207,27 +203,22 @@ object IdiomaticMockitoCats extends IdiomaticMockitoCats {
207203
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] =
208204
os thenAnswer f
209205

210-
def apply[P0, P1, P2, P3, P4, P5](f: (P0, P1, P2, P3, P4, P5) => T)(implicit F: Applicative[F],
211-
G: Applicative[G]): CatsStubbing2[F, G, T] = os thenAnswer f
206+
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
212207

213-
def apply[P0, P1, P2, P3, P4, P5, P6](f: (P0, P1, P2, P3, P4, P5, P6) => T)(implicit F: Applicative[F],
214-
G: Applicative[G]): CatsStubbing2[F, G, T] =
208+
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] =
215209
os thenAnswer f
216210

217-
def apply[P0, P1, P2, P3, P4, P5, P6, P7](f: (P0, P1, P2, P3, P4, P5, P6, P7) => T)(implicit F: Applicative[F],
218-
G: Applicative[G]): CatsStubbing2[F, G, T] =
211+
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] =
219212
os thenAnswer f
220213

221-
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],
222-
G: Applicative[G]): CatsStubbing2[F, G, T] =
214+
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] =
223215
os thenAnswer f
224216

225-
def apply[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9](
226-
f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
217+
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] =
227218
os thenAnswer f
228219

229-
def apply[P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10](
230-
f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) => T)(implicit F: Applicative[F], G: Applicative[G]): CatsStubbing2[F, G, T] =
220+
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],
221+
G: Applicative[G]): CatsStubbing2[F, G, T] =
231222
os thenAnswer f
232223
}
233224
}

cats/src/main/scala/org/mockito/cats/MockitoCats.scala

+5-10
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ trait MockitoCats extends ScalacticSerialisableHack {
7171
Mockito.doAnswer(functionToAnswer(f).andThen(Applicative[F].pure))
7272
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 =
7373
Mockito.doAnswer(functionToAnswer(f).andThen(Applicative[F].pure))
74-
def doAnswerF[F[_]: Applicative, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, R](
75-
f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) => R): Stubber =
74+
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 =
7675
Mockito.doAnswer(functionToAnswer(f).andThen(Applicative[F].pure))
7776

7877
def doAnswerFG[F[_]: Applicative, G[_]: Applicative, R](l: => R): Stubber =
@@ -103,17 +102,13 @@ trait MockitoCats extends ScalacticSerialisableHack {
103102
Mockito.doAnswer(functionToAnswer(f).andThen(Applicative[F].compose[G].pure))
104103
def doAnswerFG[F[_]: Applicative, G[_]: Applicative, P0, P1, P2, P3, P4, P5, P6, R](f: (P0, P1, P2, P3, P4, P5, P6) => R): Stubber =
105104
Mockito.doAnswer(functionToAnswer(f).andThen(Applicative[F].compose[G].pure))
106-
def doAnswerFG[F[_]: Applicative, G[_]: Applicative, P0, P1, P2, P3, P4, P5, P6, P7, R](
107-
f: (P0, P1, P2, P3, P4, P5, P6, P7) => R): Stubber =
105+
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 =
108106
Mockito.doAnswer(functionToAnswer(f).andThen(Applicative[F].compose[G].pure))
109-
def doAnswerFG[F[_]: Applicative, G[_]: Applicative, P0, P1, P2, P3, P4, P5, P6, P7, P8, R](
110-
f: (P0, P1, P2, P3, P4, P5, P6, P7, P8) => R): Stubber =
107+
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 =
111108
Mockito.doAnswer(functionToAnswer(f).andThen(Applicative[F].compose[G].pure))
112-
def doAnswerFG[F[_]: Applicative, G[_]: Applicative, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, R](
113-
f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) => R): Stubber =
109+
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 =
114110
Mockito.doAnswer(functionToAnswer(f).andThen(Applicative[F].compose[G].pure))
115-
def doAnswerFG[F[_]: Applicative, G[_]: Applicative, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, R](
116-
f: (P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) => R): Stubber =
111+
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 =
117112
Mockito.doAnswer(functionToAnswer(f).andThen(Applicative[F].compose[G].pure))
118113

119114
implicit def catsEquality[T: Eq]: Equality[T] = new EqToEquality[T]

cats/src/test/scala/org/mockito/cats/DoSomethingCatsTest.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class DoSomethingCatsTest
106106

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

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

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

cats/src/test/scala/org/mockito/cats/IdiomaticMockitoCatsTest.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class IdiomaticMockitoCatsTest
142142

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

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

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

162162
whenReady(aMock.returnsFutureEither("hello"))(_.right.value shouldBe ValueClass("mocked!"))

cats/src/test/scala/org/mockito/cats/MockitoCatsTest.scala

+5-14
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,7 @@ import org.scalatest.{ EitherValues, Matchers, OptionValues, WordSpec }
1111
import scala.concurrent.ExecutionContext.Implicits.global
1212
import scala.concurrent.Future
1313

14-
class MockitoCatsTest
15-
extends WordSpec
16-
with Matchers
17-
with MockitoSugar
18-
with ArgumentMatchersSugar
19-
with MockitoCats
20-
with EitherValues
21-
with OptionValues
22-
with ScalaFutures {
14+
class MockitoCatsTest extends WordSpec with Matchers with MockitoSugar with ArgumentMatchersSugar with MockitoCats with EitherValues with OptionValues with ScalaFutures {
2315

2416
"when - return" should {
2517
"stub full applicative" in {
@@ -128,7 +120,7 @@ class MockitoCatsTest
128120

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

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

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

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

244235
doAnswerF[Option, String]("mocked!").when(aMock).returnsOptionString("hello")
245236
doAnswerF[Option, String, String]((s: String) => s + " mocked!").when(aMock).returnsOptionString("hi")
246-
doAnswerF[Option, InvocationOnMock, String]((i: InvocationOnMock) => i.getArgument[String](0) + " invocation mocked!")
237+
doAnswerF[Option, InvocationOnMock, String]((i: InvocationOnMock) => i.arg[String](0) + " invocation mocked!")
247238
.when(aMock)
248239
.returnsOptionString("hola")
249240
doAnswerF[Option, Int, Boolean, String]((i: Int, b: Boolean) => s"$i, $b").when(aMock).returnsOptionFrom(42, true)
@@ -260,7 +251,7 @@ class MockitoCatsTest
260251
doAnswerFG[Future, ErrorOr, ValueClass](ValueClass("mocked!")).when(aMock).returnsFutureEither("hello")
261252
doAnswerFG[Future, ErrorOr, String, ValueClass]((s: String) => ValueClass(s + " mocked!")).when(aMock).returnsFutureEither("hi")
262253
doAnswerFG[Future, ErrorOr, InvocationOnMock, ValueClass] { i: InvocationOnMock =>
263-
ValueClass(i.getArgument[String](0) + " invocation mocked!")
254+
ValueClass(i.arg[String](0) + " invocation mocked!")
264255
}.when(aMock)
265256
.returnsFutureEither("hola")
266257
doAnswerFG[Future, Option, Int, Boolean, String]((i: Int, b: Boolean) => s"$i, $b").when(aMock).returnsFutureOptionFrom(42, true)

0 commit comments

Comments
 (0)