Skip to content

Commit

Permalink
Merge pull request #555 from goshacodes/issue225
Browse files Browse the repository at this point in the history
add tests for issue #225
  • Loading branch information
goshacodes authored Jan 2, 2025
2 parents c2e1c37 + fe9dfca commit 0497c8f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.paulbutcher.test;

import java.util.concurrent.Callable;

public interface JavaInterfaceWithOverloadedMethods<T> {
void send(T record);
void send(T record, Callable<T> onComplete);
}
20 changes: 19 additions & 1 deletion jvm/src/test/scala/com.paulbutcher.test/mock/JavaMocksTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

0 comments on commit 0497c8f

Please sign in to comment.