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

@Capturing issue with generics in implemented interface #708

Open
3 of 4 tasks
Saljack opened this issue Mar 29, 2021 · 0 comments · May be fixed by #712
Open
3 of 4 tasks

@Capturing issue with generics in implemented interface #708

Saljack opened this issue Mar 29, 2021 · 0 comments · May be fixed by #712

Comments

@Saljack
Copy link

Saljack commented Mar 29, 2021

  • Version of JMockit that was used:
    1.49

  • Description of the problem or enhancement request:
    I deeply play with code from [question] how to mock reactive stack #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:
  • 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.

  • 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).

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant