Skip to content
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

add tests for issue #225 #555

Merged
merged 1 commit into from
Jan 2, 2025
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
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
}
Loading