jmockit1 icon indicating copy to clipboard operation
jmockit1 copied to clipboard

@Capturing issue with generics in implemented interface

Open Saljack opened this issue 4 years ago • 0 comments

  • Version of JMockit that was used: 1.49

  • Description of the problem or enhancement request: I deeply play with code from #700 and where I wrote that it is issue in JMockit and I was right. The issue is not combination Spring Data (generating code) and generating code but it is an issue with generics. I updated the code and simplified it as much I was able to do. So the issue is only if you implements an interface with generics as a returned type (in this case it is Mono<String>). As you can see in tests it works without generics or if I use @Capturing on an implementation class. It thinks that I call the first method when I call the second one. Here is stacktrace:

Unexpected invocation to:
com.example.demo.data.repository.DemoRepository#testMethodOne()
   on mock instance: com.example.demo.data.repository.$Impl_DemoRepository@51d0ec6f
	at com.example.demo.service.TestService.callMonoMethods(TestService.java:18)
	at com.example.demo.DemoApplicationTests.testMono(DemoApplicationTests.java:36)
	Suppressed: Missing 1 invocation to:
com.example.demo.data.repository.DemoRepository#testMethodTwo()
   on mock instance: com.example.demo.data.repository.$Impl_DemoRepository@51d0ec6f
	Caused by: Missing invocations
		at com.example.demo.DemoApplicationTests$1.<init>(DemoApplicationTests.java:31)
		at com.example.demo.DemoApplicationTests.testMono(DemoApplicationTests.java:26)
Caused by: Unexpected invocation
	at com.example.demo.DemoApplicationTests$1.<init>(DemoApplicationTests.java:27)
	at com.example.demo.DemoApplicationTests.testMono(DemoApplicationTests.java:26)
  • Check the following:
  • [x] If a defect or unexpected result, JMockit project members should be able to reproduce it. For that, include an example test (perhaps accompanied by a Maven/Gradle build script) which can be executed without changes and reproduces the failure. My repo: https://github.com/Saljack/jmockit-reactive

  • [ ] If an enhancement or new feature request, it should be justified by an example test demonstrating the validity and usefulness of the desired enhancement or new feature.

  • [x] The issue does not fall outside the scope of the project (for example, attempting to use JMockit APIs from Groovy or Scala code, or with an Android runtime).

  • [x] The JDK where the problem occurs is a final release, not a development build.

Saljack avatar Mar 29 '21 11:03 Saljack