From 54d07a6d6647898ffde7970292e83b0d8d2de30f Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 4 Feb 2025 01:34:24 +0000 Subject: [PATCH 1/3] Update scalafmt-core to 3.8.6 --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 5d93115d..088bffb0 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -7,5 +7,5 @@ rewrite.rules = [RedundantBraces, RedundantParens, SortImports] spaces.inImportCurlyBraces = true indentOperator.preset = spray -version=3.8.2 +version=3.8.6 From c038644e07f224e668b7be8c53f9038cfd2275cf Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 4 Feb 2025 01:34:49 +0000 Subject: [PATCH 2/3] Reformat with scalafmt 3.8.6 Executed command: scalafmt --non-interactive --- .../scala/org/mockito/ReflectionUtils.scala | 5 +- .../org/mockito/IdiomaticStubbingTest.scala | 32 +- .../scala/user/org/mockito/Issue256.scala | 15 +- .../org/mockito/MockitoScalaSessionTest.scala | 306 ++++++++---------- .../user/org/mockito/MockitoSugarTest.scala | 8 +- .../mockito/PostfixVerificationsTest.scala | 9 +- .../org/mockito/PrefixExpectationsTest.scala | 9 +- .../org/mockito/captor/ArgCaptorTest.scala | 6 +- .../mockito/matchers/ThatMatchersTest.scala | 5 +- .../mockito/stubbing/DefaultAnswerTest.scala | 6 +- .../mockito/specs2/MockitoSpecs2Support.scala | 41 ++- 11 files changed, 211 insertions(+), 231 deletions(-) diff --git a/common/src/main/scala/org/mockito/ReflectionUtils.scala b/common/src/main/scala/org/mockito/ReflectionUtils.scala index 64057f9b..8f33e11e 100644 --- a/common/src/main/scala/org/mockito/ReflectionUtils.scala +++ b/common/src/main/scala/org/mockito/ReflectionUtils.scala @@ -20,9 +20,8 @@ object ReflectionUtils { private val mirror = runtimeMirror(getClass.getClassLoader) private val customMirror = mirror.asInstanceOf[{ - def methodToJava(sym: Symbols#MethodSymbol): Method - } - ] + def methodToJava(sym: Symbols#MethodSymbol): Method + }] def listToTuple(l: List[Object]): Any = l match { diff --git a/scalatest/src/test/scala/user/org/mockito/IdiomaticStubbingTest.scala b/scalatest/src/test/scala/user/org/mockito/IdiomaticStubbingTest.scala index a9da2fe2..3cf6cb91 100644 --- a/scalatest/src/test/scala/user/org/mockito/IdiomaticStubbingTest.scala +++ b/scalatest/src/test/scala/user/org/mockito/IdiomaticStubbingTest.scala @@ -236,9 +236,8 @@ class IdiomaticStubbingTest extends AnyWordSpec with Matchers with ArgumentMatch org.doSomethingWithThisIntAndStringAndBoolean(1, "2", v3 = false) - an[IllegalArgumentException] should be thrownBy { - org.doSomethingWithThisIntAndStringAndBoolean(1, "2", v3 = true) - } + an[IllegalArgumentException] should be thrownBy + org.doSomethingWithThisIntAndStringAndBoolean(1, "2", v3 = true) """"some value" willBe thrown by org.bar""" shouldNot compile } @@ -258,9 +257,8 @@ class IdiomaticStubbingTest extends AnyWordSpec with Matchers with ArgumentMatch aSpy.iBlowUp(1, "ok") shouldBe "mocked!" aSpy.iBlowUp(2, "ok") shouldBe "mocked!" - an[IllegalArgumentException] should be thrownBy { - aSpy.iBlowUp(2, "not ok") - } + an[IllegalArgumentException] should be thrownBy + aSpy.iBlowUp(2, "not ok") } "stub a function with an answer" in { @@ -316,12 +314,11 @@ class IdiomaticStubbingTest extends AnyWordSpec with Matchers with ArgumentMatch } "be thread safe" when { - "always stubbing object methods" in { - immutable.ParSeq.range(1, 100).foreach { i => - withObjectSpied[FooObject.type] { - FooObject.simpleMethod returns s"spied!-$i" - FooObject.simpleMethod shouldBe s"spied!-$i" - } + "always stubbing object methods" in + immutable.ParSeq.range(1, 100).foreach { i => + withObjectSpied[FooObject.type] { + FooObject.simpleMethod returns s"spied!-$i" + FooObject.simpleMethod shouldBe s"spied!-$i" } } @@ -357,12 +354,11 @@ class IdiomaticStubbingTest extends AnyWordSpec with Matchers with ArgumentMatch FooObject.simpleMethod shouldBe "not mocked!" } - "object stubbing should be thread safe" in { - immutable.ParSeq.range(1, 100).foreach { i => - withObjectMocked[FooObject.type] { - FooObject.simpleMethod returns s"mocked!-$i" - FooObject.simpleMethod shouldBe s"mocked!-$i" - } + "object stubbing should be thread safe" in + immutable.ParSeq.range(1, 100).foreach { i => + withObjectMocked[FooObject.type] { + FooObject.simpleMethod returns s"mocked!-$i" + FooObject.simpleMethod shouldBe s"mocked!-$i" } } diff --git a/scalatest/src/test/scala/user/org/mockito/Issue256.scala b/scalatest/src/test/scala/user/org/mockito/Issue256.scala index 6c1b97c9..00e19dc6 100644 --- a/scalatest/src/test/scala/user/org/mockito/Issue256.scala +++ b/scalatest/src/test/scala/user/org/mockito/Issue256.scala @@ -13,15 +13,14 @@ class Issue256 extends AnyWordSpec with Matchers { } "mockito" should { - "allow stubbing the same method multiple times" in { - MockitoScalaSession().run { - val foo = mock[Foo] - foo.test[String](argThat((s: String) => s.startsWith("foo"))) returns "foo" - foo.test[Int](argThat((n: Int) => n > 10)) returns 42 + "allow stubbing the same method multiple times" in + MockitoScalaSession().run { + val foo = mock[Foo] + foo.test[String](argThat((s: String) => s.startsWith("foo"))) returns "foo" + foo.test[Int](argThat((n: Int) => n > 10)) returns 42 - foo.test("fooSSS") shouldBe "foo" - foo.test(11) shouldBe 42 - } + foo.test("fooSSS") shouldBe "foo" + foo.test(11) shouldBe 42 } } } diff --git a/scalatest/src/test/scala/user/org/mockito/MockitoScalaSessionTest.scala b/scalatest/src/test/scala/user/org/mockito/MockitoScalaSessionTest.scala index f2357f87..569eefff 100644 --- a/scalatest/src/test/scala/user/org/mockito/MockitoScalaSessionTest.scala +++ b/scalatest/src/test/scala/user/org/mockito/MockitoScalaSessionTest.scala @@ -63,78 +63,71 @@ class MockitoScalaSessionTest extends AnyWordSpec with IdiomaticMockito with Mat forAll(scenarios) { (testDouble, foo, parametrisedFoo, fooBar) => s"MockitoScalaSession - $testDouble" should { - "don't check unexpected calls for lenient methods (set at the beginning)" in { - MockitoScalaSession().run { - val aFoo = foo() + "don't check unexpected calls for lenient methods (set at the beginning)" in + MockitoScalaSession().run { + val aFoo = foo() - aFoo.bar(*).isLenient() + aFoo.bar(*).isLenient() - aFoo.bar("paco") shouldBe fooBar - } + aFoo.bar("paco") shouldBe fooBar } - "don't check unexpected calls for lenient methods (set at the end)" in { - MockitoScalaSession().run { - val aFoo = foo() + "don't check unexpected calls for lenient methods (set at the end)" in + MockitoScalaSession().run { + val aFoo = foo() - aFoo.bar("paco") shouldBe fooBar + aFoo.bar("paco") shouldBe fooBar - aFoo.bar(*).isLenient() - } + aFoo.bar(*).isLenient() } - "don't check unused stubs for lenient methods (set at the beginning)" in { - MockitoScalaSession().run { - val aFoo = foo() + "don't check unused stubs for lenient methods (set at the beginning)" in + MockitoScalaSession().run { + val aFoo = foo() - aFoo.bar(*).isLenient() + aFoo.bar(*).isLenient() - aFoo.bar("pepe") returns "mocked" - } + aFoo.bar("pepe") returns "mocked" } - "don't check unused stubs for lenient methods (set at the end)" in { - MockitoScalaSession().run { - val aFoo = foo() + "don't check unused stubs for lenient methods (set at the end)" in + MockitoScalaSession().run { + val aFoo = foo() - aFoo.bar("pepe") returns "mocked" + aFoo.bar("pepe") returns "mocked" - aFoo.bar(*).isLenient() - } + aFoo.bar(*).isLenient() } "check unused stubs" in { - an[UnnecessaryStubbingException] should be thrownBy { - MockitoScalaSession().run { - val aFoo = foo() + an[UnnecessaryStubbingException] should be thrownBy + MockitoScalaSession().run { + val aFoo = foo() - aFoo.bar(*) returns "mocked" - } + aFoo.bar(*) returns "mocked" } - an[UnnecessaryStubbingException] should be thrownBy { - MockitoScalaSession().run { - val aFoo = foo() + an[UnnecessaryStubbingException] should be thrownBy + MockitoScalaSession().run { + val aFoo = foo() - aFoo.unit().doesNothing() - } + aFoo.unit().doesNothing() } } "check incorrect stubs" in { - an[UnnecessaryStubbingException] should be thrownBy { - MockitoScalaSession().run { - val aFoo = foo() + an[UnnecessaryStubbingException] should be thrownBy + MockitoScalaSession().run { + val aFoo = foo() - aFoo.bar("pepe") returns "mocked" + aFoo.bar("pepe") returns "mocked" - aFoo.bar("paco").toLowerCase - } + aFoo.bar("paco").toLowerCase } } "check incorrect stubs after the expected one was called" in { - val thrown = the[UnexpectedInvocationException] thrownBy { + val thrown = the[UnexpectedInvocationException] thrownBy MockitoScalaSession().run { val aFoo = foo() @@ -144,109 +137,87 @@ class MockitoScalaSessionTest extends AnyWordSpec with IdiomaticMockito with Mat aFoo.bar("paco").toLowerCase } - } thrown.getMessage should startWith("Unexpected invocations found") } "check unexpected invocations" in { - (the[UnexpectedInvocationException] thrownBy { + (the[UnexpectedInvocationException] thrownBy MockitoScalaSession().run { val aFoo = foo() aFoo.bar("pepe") - } - }).getMessage should startWith("Unexpected invocations found") + }).getMessage should startWith("Unexpected invocations found") - (the[UnexpectedInvocationException] thrownBy { + (the[UnexpectedInvocationException] thrownBy MockitoScalaSession().run { val aFoo = foo() aFoo.unit() - } - }).getMessage should startWith("Unexpected invocations found") + }).getMessage should startWith("Unexpected invocations found") } - "not check unexpected invocations if the call was verified" in { - MockitoScalaSession().run { - val aFoo = foo() + "not check unexpected invocations if the call was verified" in + MockitoScalaSession().run { + val aFoo = foo() - aFoo.bar("pepe") + aFoo.bar("pepe") - aFoo.bar("pepe") was called - } + aFoo.bar("pepe") was called } "check incorrect stubs with default arguments" in { - an[UnnecessaryStubbingException] should be thrownBy { - MockitoScalaSession().run { - val aFoo = foo() - - aFoo.baz("pepe") returns "mocked" - - aFoo.baz().toLowerCase - } - } - } - - "work with default arguments" in { + an[UnnecessaryStubbingException] should be thrownBy MockitoScalaSession().run { val aFoo = foo() - aFoo.baz() returns "mocked" + aFoo.baz("pepe") returns "mocked" - aFoo.baz() shouldBe "mocked" + aFoo.baz().toLowerCase } } - "work with default arguments when passing an argument" in { - MockitoScalaSession().run { - val aFoo = foo() + "work with default arguments" in + MockitoScalaSession().run { + val aFoo = foo() - aFoo.baz("papa") returns "mocked" + aFoo.baz() returns "mocked" - aFoo.baz("papa") shouldBe "mocked" - } + aFoo.baz() shouldBe "mocked" } - "work with default arguments when passing an argument but production code doesn't" in { - MockitoScalaSession().run { - val aFoo = foo() + "work with default arguments when passing an argument" in + MockitoScalaSession().run { + val aFoo = foo() - aFoo.baz("default") returns "mocked" + aFoo.baz("papa") returns "mocked" - aFoo.baz() shouldBe "mocked" - } + aFoo.baz("papa") shouldBe "mocked" } - "don't check unexpected calls for lenient mocks" in { - MockitoScalaSession().run { - val aFoo = parametrisedFoo(withSettings.lenient()) - - aFoo.bar("pepe") returns "mocked" + "work with default arguments when passing an argument but production code doesn't" in + MockitoScalaSession().run { + val aFoo = foo() - aFoo.bar("pepe") + aFoo.baz("default") returns "mocked" - aFoo.bar("paco") - } + aFoo.baz() shouldBe "mocked" } - "check unexpected invocations for normal mocks" in { - a[UnexpectedInvocationException] should be thrownBy { - MockitoScalaSession().run { - val aFoo = foo() + "don't check unexpected calls for lenient mocks" in + MockitoScalaSession().run { + val aFoo = parametrisedFoo(withSettings.lenient()) - aFoo.bar("pepe") returns "mocked" + aFoo.bar("pepe") returns "mocked" - aFoo.bar("pepe") + aFoo.bar("pepe") - aFoo.bar("paco") - } - } + aFoo.bar("paco") } - "don't check unexpected invocations in lenient setting" in { - MockitoScalaSession(strictness = Strictness.LENIENT).run { + "check unexpected invocations for normal mocks" in { + a[UnexpectedInvocationException] should be thrownBy + MockitoScalaSession().run { val aFoo = foo() aFoo.bar("pepe") returns "mocked" @@ -257,154 +228,151 @@ class MockitoScalaSessionTest extends AnyWordSpec with IdiomaticMockito with Mat } } - "don't check unused stubs for lenient" in { - MockitoScalaSession().run { - val aFoo = parametrisedFoo(withSettings.lenient()) + "don't check unexpected invocations in lenient setting" in + MockitoScalaSession(strictness = Strictness.LENIENT).run { + val aFoo = foo() - aFoo.bar("pepe") returns "mocked" - } + aFoo.bar("pepe") returns "mocked" + + aFoo.bar("pepe") + + aFoo.bar("paco") } - "check unused stubs for not lenient mocks" in { - a[UnnecessaryStubbingException] should be thrownBy { - MockitoScalaSession().run { - val aFoo = foo() - aFoo.bar("pepe") returns "mocked" - } - } + "don't check unused stubs for lenient" in + MockitoScalaSession().run { + val aFoo = parametrisedFoo(withSettings.lenient()) + + aFoo.bar("pepe") returns "mocked" } - "don't check unused stubs in lenient setting" in { - MockitoScalaSession(strictness = Strictness.LENIENT).run { + "check unused stubs for not lenient mocks" in { + a[UnnecessaryStubbingException] should be thrownBy + MockitoScalaSession().run { val aFoo = foo() aFoo.bar("pepe") returns "mocked" } } + "don't check unused stubs in lenient setting" in + MockitoScalaSession(strictness = Strictness.LENIENT).run { + val aFoo = foo() + aFoo.bar("pepe") returns "mocked" + } + "check unused stubs in not lenient setting" in { - a[UnnecessaryStubbingException] should be thrownBy { - MockitoScalaSession(strictness = Strictness.STRICT_STUBS).run { - val aFoo = foo() - aFoo.bar("pepe") returns "mocked" - } + a[UnnecessaryStubbingException] should be thrownBy + MockitoScalaSession(strictness = Strictness.STRICT_STUBS).run { + val aFoo = foo() + aFoo.bar("pepe") returns "mocked" } } } } "MockitoScalaSession" should { - "don't fail if equals calls on an internal method" in { - MockitoScalaSession().run { - val aFoo = mock[Foo] + "don't fail if equals calls on an internal method" in + MockitoScalaSession().run { + val aFoo = mock[Foo] - aFoo.finalFinalEqualsAndHashcode + aFoo.finalFinalEqualsAndHashcode - aFoo.finalFinalEqualsAndHashcode was called - } + aFoo.finalFinalEqualsAndHashcode was called } "re-throw an exception produced by the test" in { - an[IllegalArgumentException] should be thrownBy { - MockitoScalaSession().run { - throw new IllegalArgumentException - } + an[IllegalArgumentException] should be thrownBy + MockitoScalaSession().run { + throw new IllegalArgumentException } } "re-throw an real NPE produced by the test (an NPE not related to an un-stubbed mock call)" in { - an[NullPointerException] should be thrownBy { - MockitoScalaSession().run { - throw new NullPointerException - } + an[NullPointerException] should be thrownBy + MockitoScalaSession().run { + throw new NullPointerException } } - "work with nested deep stubs" in { - MockitoScalaSession().run { - val aFoo = mock[Foo](DefaultAnswers.ReturnsDeepStubs) + "work with nested deep stubs" in + MockitoScalaSession().run { + val aFoo = mock[Foo](DefaultAnswers.ReturnsDeepStubs) - aFoo.userClass.callMeMaybe.callMe returns Some("my number") + aFoo.userClass.callMeMaybe.callMe returns Some("my number") - aFoo.userClass.callMeMaybe.callMe.value shouldBe "my number" - } + aFoo.userClass.callMeMaybe.callMe.value shouldBe "my number" } - "not fail if a final deep stub is called in a non stubbed method" in { - MockitoScalaSession().run { - val aFoo = mock[Foo](DefaultAnswers.ReturnsDeepStubs) + "not fail if a final deep stub is called in a non stubbed method" in + MockitoScalaSession().run { + val aFoo = mock[Foo](DefaultAnswers.ReturnsDeepStubs) - aFoo.userClass.callMeMaybe.callMe returns Some("my number") + aFoo.userClass.callMeMaybe.callMe returns Some("my number") - aFoo.userClass.callMeMaybe.callMe.value shouldBe "my number" + aFoo.userClass.callMeMaybe.callMe.value shouldBe "my number" - aFoo.userClass.callMeMaybe.dontCallMe - } + aFoo.userClass.callMeMaybe.dontCallMe } - "not fail if a nested deep stub is called in a non stubbed method" in { - MockitoScalaSession().run { - val aFoo = mock[Foo](DefaultAnswers.ReturnsDeepStubs) + "not fail if a nested deep stub is called in a non stubbed method" in + MockitoScalaSession().run { + val aFoo = mock[Foo](DefaultAnswers.ReturnsDeepStubs) - aFoo.userClass.callMeMaybe.callMe returns Some("my number") + aFoo.userClass.callMeMaybe.callMe returns Some("my number") - aFoo.userClass.callMeMaybe.callMe.value shouldBe "my number" + aFoo.userClass.callMeMaybe.callMe.value shouldBe "my number" - aFoo.userClass.dontCallMe - } + aFoo.userClass.dontCallMe } "fail if a nested deep stub is stubbed but not used" in { - val thrown = the[UnnecessaryStubbingException] thrownBy { + val thrown = the[UnnecessaryStubbingException] thrownBy MockitoScalaSession().run { val aFoo = mock[Foo](DefaultAnswers.ReturnsDeepStubs) aFoo.userClass.callMeMaybe.callMe returns Some("my number") } - } thrown.getMessage should startWith("Unnecessary stubbings detected") } "check incorrect stubs after the expected one was called on a final class" in { - val thrown = the[UnexpectedInvocationException] thrownBy { + val thrown = the[UnexpectedInvocationException] thrownBy MockitoScalaSession().run { val aFoo = mock[Foo] aFoo.userClassFinal.callMeMaybe } - } thrown.getMessage should startWith("A NullPointerException was thrown, check if maybe related to") } "check SmartNull" in { - val thrown = the[SmartNullPointerException] thrownBy { + val thrown = the[SmartNullPointerException] thrownBy MockitoScalaSession().run { val aFoo = mock[Foo] aFoo.userClass.callMeMaybe } - } thrown.getMessage should include("You have a NullPointerException here:") } "verify object spies" when { - "successfully for uncalled lenient stubs" in { - MockitoScalaSession().run { - import org.mockito.leniency.lenient + "successfully for uncalled lenient stubs" in + MockitoScalaSession().run { + import org.mockito.leniency.lenient - withObjectSpied[FooObject.type] { - FooObject.stateDependantMethod returns 1234L - FooObject.simpleMethod returns s"spied!" - FooObject.simpleMethod shouldBe s"spied!" - } + withObjectSpied[FooObject.type] { + FooObject.stateDependantMethod returns 1234L + FooObject.simpleMethod returns s"spied!" + FooObject.simpleMethod shouldBe s"spied!" } } "unsuccessfully for uncalled strict stubs" in { - val thrown = the[UnnecessaryStubbingException] thrownBy { + val thrown = the[UnnecessaryStubbingException] thrownBy MockitoScalaSession().run { import org.mockito.leniency.strict @@ -414,14 +382,13 @@ class MockitoScalaSessionTest extends AnyWordSpec with IdiomaticMockito with Mat FooObject.simpleMethod shouldBe s"spied!" } } - } thrown.getMessage should include("Unnecessary stubbings detected") } "unsuccessfully by default (strict) for uncalled stubs" in { - val thrown = the[UnnecessaryStubbingException] thrownBy { + val thrown = the[UnnecessaryStubbingException] thrownBy MockitoScalaSession().run { withObjectSpied[FooObject.type] { FooObject.stateDependantMethod returns 1234L @@ -429,7 +396,6 @@ class MockitoScalaSessionTest extends AnyWordSpec with IdiomaticMockito with Mat FooObject.simpleMethod shouldBe s"spied!" } } - } thrown.getMessage should include("Unnecessary stubbings detected") } diff --git a/scalatest/src/test/scala/user/org/mockito/MockitoSugarTest.scala b/scalatest/src/test/scala/user/org/mockito/MockitoSugarTest.scala index d73e7d63..d78231bb 100644 --- a/scalatest/src/test/scala/user/org/mockito/MockitoSugarTest.scala +++ b/scalatest/src/test/scala/user/org/mockito/MockitoSugarTest.scala @@ -295,9 +295,8 @@ class MockitoSugarTest extends AnyWordSpec with MockitoSugar with Matchers with aMock.baz(42, Baz2(69, "hola")) - val e = the[ArgumentsAreDifferent] thrownBy { + val e = the[ArgumentsAreDifferent] thrownBy verify(aMock).baz(42, Baz2(69, "chau")) - } e.getMessage should include("Argument(s) are different! Wanted:") e.getMessage should include("foo.baz(42, PrettifiedBaz(hola));") @@ -408,9 +407,8 @@ class MockitoSugarTest extends AnyWordSpec with MockitoSugar with Matchers with } "stop the user passing traits in the settings" in { - a[IllegalArgumentException] should be thrownBy { - mock[Foo](withSettings.extraInterfaces(classOf[Baz])) - } + a[IllegalArgumentException] should be thrownBy + mock[Foo](withSettings.extraInterfaces(classOf[Baz])) } "work when getting varargs from collections" in { diff --git a/scalatest/src/test/scala/user/org/mockito/PostfixVerificationsTest.scala b/scalatest/src/test/scala/user/org/mockito/PostfixVerificationsTest.scala index 9d25a17f..7789cc58 100644 --- a/scalatest/src/test/scala/user/org/mockito/PostfixVerificationsTest.scala +++ b/scalatest/src/test/scala/user/org/mockito/PostfixVerificationsTest.scala @@ -251,11 +251,10 @@ class PostfixVerificationsTest extends AnyWordSpec with IdiomaticMockitoTestSetu mock1.bar mock2.iHaveDefaultArgs() - a[VerificationInOrderFailure] should be thrownBy { - InOrder(mock1, mock2) { implicit order => - mock2.iHaveDefaultArgs() was called - mock1.bar was called - } + a[VerificationInOrderFailure] should be thrownBy + InOrder(mock1, mock2) { implicit order => + mock2.iHaveDefaultArgs() was called + mock1.bar was called } InOrder(mock1, mock2) { implicit order => diff --git a/scalatest/src/test/scala/user/org/mockito/PrefixExpectationsTest.scala b/scalatest/src/test/scala/user/org/mockito/PrefixExpectationsTest.scala index bfbdbe8a..e9521a2f 100644 --- a/scalatest/src/test/scala/user/org/mockito/PrefixExpectationsTest.scala +++ b/scalatest/src/test/scala/user/org/mockito/PrefixExpectationsTest.scala @@ -275,11 +275,10 @@ class PrefixExpectationsTest extends AnyWordSpec with Matchers with ArgumentMatc mock1.bar mock2.iHaveDefaultArgs() - a[VerificationInOrderFailure] should be thrownBy { - InOrder(mock1, mock2) { implicit order => - expect a call to mock2.iHaveDefaultArgs() - expect a call to mock1.bar - } + a[VerificationInOrderFailure] should be thrownBy + InOrder(mock1, mock2) { implicit order => + expect a call to mock2.iHaveDefaultArgs() + expect a call to mock1.bar } InOrder(mock1, mock2) { implicit order => diff --git a/scalatest/src/test/scala/user/org/mockito/captor/ArgCaptorTest.scala b/scalatest/src/test/scala/user/org/mockito/captor/ArgCaptorTest.scala index 8cd38ded..6e03958a 100644 --- a/scalatest/src/test/scala/user/org/mockito/captor/ArgCaptorTest.scala +++ b/scalatest/src/test/scala/user/org/mockito/captor/ArgCaptorTest.scala @@ -145,9 +145,8 @@ class ArgCaptorTest extends AnyWordSpec with MockitoSugar with Matchers { captor.values.should(contain).only("it worked again!") - val error = the[MockitoAssertionError] thrownBy { + val error = the[MockitoAssertionError] thrownBy captor.hasCaptured("it worked!", "it worked again!") - } error.getMessage should ( include("Got [it worked again!] instead of [it worked!]") and @@ -166,9 +165,8 @@ class ArgCaptorTest extends AnyWordSpec with MockitoSugar with Matchers { captor.values.should(contain).only("it worked!", "it worked again!") - val error = the[MockitoAssertionError] thrownBy { + val error = the[MockitoAssertionError] thrownBy captor.hasCaptured("it worked again!") - } error.getMessage should ( include("Got [it worked!] instead of [it worked again!]") and diff --git a/scalatest/src/test/scala/user/org/mockito/matchers/ThatMatchersTest.scala b/scalatest/src/test/scala/user/org/mockito/matchers/ThatMatchersTest.scala index 8b9b2a90..23090c1c 100644 --- a/scalatest/src/test/scala/user/org/mockito/matchers/ThatMatchersTest.scala +++ b/scalatest/src/test/scala/user/org/mockito/matchers/ThatMatchersTest.scala @@ -25,9 +25,8 @@ class ThatMatchersTest extends AnyFlatSpec with MockitoSugar with Matchers with verify(aMock).baz(argMatching { case Baz("Hello", _) => }) verify(aMock).baz(argMatching { case Baz(_, _) => }) - an[WantedButNotInvoked] should be thrownBy { - verify(aMock).baz(argMatching { case Baz("", _) => }) - } + an[WantedButNotInvoked] should be thrownBy + verify(aMock).baz(argMatching { case Baz("", _) => }) } "argThat[T]" should "work with AnyRef" in { diff --git a/scalatest/src/test/scala/user/org/mockito/stubbing/DefaultAnswerTest.scala b/scalatest/src/test/scala/user/org/mockito/stubbing/DefaultAnswerTest.scala index cdcef2a6..f502711e 100644 --- a/scalatest/src/test/scala/user/org/mockito/stubbing/DefaultAnswerTest.scala +++ b/scalatest/src/test/scala/user/org/mockito/stubbing/DefaultAnswerTest.scala @@ -50,9 +50,8 @@ class DefaultAnswerTest extends AnyWordSpec with should.Matchers with IdiomaticM smartNull should not be null - val throwable = the[SmartNullPointerException] thrownBy { + val throwable = the[SmartNullPointerException] thrownBy smartNull.callMeMaybe() - } throwable.getMessage should include("You have a NullPointerException here:") } @@ -62,9 +61,8 @@ class DefaultAnswerTest extends AnyWordSpec with should.Matchers with IdiomaticM smartNull should not be null - val throwable: SmartNullPointerException = the[SmartNullPointerException] thrownBy { + val throwable: SmartNullPointerException = the[SmartNullPointerException] thrownBy smartNull.isEmpty - } throwable.getMessage should include("You have a NullPointerException here:") } diff --git a/specs2/src/main/scala/org/mockito/specs2/MockitoSpecs2Support.scala b/specs2/src/main/scala/org/mockito/specs2/MockitoSpecs2Support.scala index 3646fa19..64615ede 100644 --- a/specs2/src/main/scala/org/mockito/specs2/MockitoSpecs2Support.scala +++ b/specs2/src/main/scala/org/mockito/specs2/MockitoSpecs2Support.scala @@ -85,8 +85,17 @@ trait FunctionArguments extends FunctionArgumentsLowImplicits { implicit def matcherToFunctionCall7[T1, T2, T3, T4, T5, T6, T7, R](values: ((T1, T2, T3, T4, T5, T6, T7), Matcher[R])): Function7[T1, T2, T3, T4, T5, T6, T7, R] = callMatching7(values._1._1, values._1._2, values._1._3, values._1._4, values._1._5, values._1._6, values._1._7, values._2) - def callMatching8[T1, T2, T3, T4, T5, T6, T7, T8, R](t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, m: Matcher[R]) - : Function8[T1, T2, T3, T4, T5, T6, T7, T8, R] = + def callMatching8[T1, T2, T3, T4, T5, T6, T7, T8, R]( + t1: T1, + t2: T2, + t3: T3, + t4: T4, + t5: T5, + t6: T6, + t7: T7, + t8: T8, + m: Matcher[R] + ): Function8[T1, T2, T3, T4, T5, T6, T7, T8, R] = argThat(m ^^ { (f: Function8[T1, T2, T3, T4, T5, T6, T7, T8, R]) => f(t1, t2, t3, t4, t5, t6, t7, t8) }) def functionCall8[T1, T2, T3, T4, T5, T6, T7, T8, R](t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, r: R): Function8[T1, T2, T3, T4, T5, T6, T7, T8, R] = callMatching8(t1, t2, t3, t4, t5, t6, t7, t8, new BeEqualTo(r)) @@ -95,11 +104,31 @@ trait FunctionArguments extends FunctionArgumentsLowImplicits { implicit def matcherToFunctionCall8[T1, T2, T3, T4, T5, T6, T7, T8, R](values: ((T1, T2, T3, T4, T5, T6, T7, T8), Matcher[R])): Function8[T1, T2, T3, T4, T5, T6, T7, T8, R] = callMatching8(values._1._1, values._1._2, values._1._3, values._1._4, values._1._5, values._1._6, values._1._7, values._1._8, values._2) - def callMatching9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R](t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9, m: Matcher[R]) - : Function9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R] = + def callMatching9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R]( + t1: T1, + t2: T2, + t3: T3, + t4: T4, + t5: T5, + t6: T6, + t7: T7, + t8: T8, + t9: T9, + m: Matcher[R] + ): Function9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R] = argThat(m ^^ { (f: Function9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R]) => f(t1, t2, t3, t4, t5, t6, t7, t8, t9) }) - def functionCall9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R](t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9, r: R) - : Function9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R] = callMatching9(t1, t2, t3, t4, t5, t6, t7, t8, t9, new BeEqualTo(r)) + def functionCall9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R]( + t1: T1, + t2: T2, + t3: T3, + t4: T4, + t5: T5, + t6: T6, + t7: T7, + t8: T8, + t9: T9, + r: R + ): Function9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R] = callMatching9(t1, t2, t3, t4, t5, t6, t7, t8, t9, new BeEqualTo(r)) implicit def toFunctionCall9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R](values: ((T1, T2, T3, T4, T5, T6, T7, T8, T9), R)): Function9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R] = functionCall9(values._1._1, values._1._2, values._1._3, values._1._4, values._1._5, values._1._6, values._1._7, values._1._8, values._1._9, values._2) implicit def matcherToFunctionCall9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R]( From 110eff7a45607b84b6ee91fa335f8486540d3f2f Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 4 Feb 2025 01:34:49 +0000 Subject: [PATCH 3/3] Add 'Reformat with scalafmt 3.8.6' to .git-blame-ignore-revs --- .git-blame-ignore-revs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index c9f79efb..3eb0fb64 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -3,3 +3,6 @@ ff8ca52d610ca63ee0ab4fcfb5d79da13a1250b1 # Scala Steward: Reformat with scalafmt 3.7.15 8fa2251b493a78759fc04a2f74189b9f8bdc07c4 + +# Scala Steward: Reformat with scalafmt 3.8.6 +c038644e07f224e668b7be8c53f9038cfd2275cf