diff --git a/jvm/src/test/java/com/paulbutcher/test/JavaInterfaceWithOverloadedMethods.java b/jvm/src/test/java/com/paulbutcher/test/JavaInterfaceWithOverloadedMethods.java new file mode 100644 index 00000000..58b2fa24 --- /dev/null +++ b/jvm/src/test/java/com/paulbutcher/test/JavaInterfaceWithOverloadedMethods.java @@ -0,0 +1,8 @@ +package com.paulbutcher.test; + +import java.util.concurrent.Callable; + +public interface JavaInterfaceWithOverloadedMethods { + void send(T record); + void send(T record, Callable onComplete); +} diff --git a/jvm/src/test/scala/com.paulbutcher.test/mock/JavaMocksTest.scala b/jvm/src/test/scala/com.paulbutcher.test/mock/JavaMocksTest.scala index b8ae6619..548cfa13 100644 --- a/jvm/src/test/scala/com.paulbutcher.test/mock/JavaMocksTest.scala +++ b/jvm/src/test/scala/com.paulbutcher.test/mock/JavaMocksTest.scala @@ -20,7 +20,9 @@ package com.paulbutcher.test.mock -import com.paulbutcher.test._ +import com.paulbutcher.test.* + +import java.util.concurrent.Callable class JavaMocksTest extends IsolatedSpec { behavior of "ScalaMock while mocking Java classes and interfaces" @@ -123,5 +125,21 @@ class JavaMocksTest extends IsolatedSpec { m.overloadedGeneric(2) shouldBe "second" } + it should "mock a Java interface with an overloaded method (with type params)" in { + val m = mock[JavaInterfaceWithOverloadedMethods[String]] + + val callable: Callable[String] = () => "two" + (m.send(_: String)) + .expects("one") + .returning(()) + + (m.send(_: String, _: Callable[String])) + .expects("one", callable) + .returning(()) + + m.send("one") + m.send("one", callable) + } + override def newInstance = new JavaMocksTest } \ No newline at end of file