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

class java.util.LinkedHashMap cannot be cast to class org.unlogged.demo.models.abstraction.PropertyDetails #81

Open
TheAmg opened this issue Jun 21, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@TheAmg
Copy link
Contributor

TheAmg commented Jun 21, 2024

Describe the bug

The above Exception is seen when running saved replays in unit mode/with mocks enabled on unlogged-spring-maven-demo.
The methods where this is seen are -
All the methods except the findAll method in PropertyControllerImpl.

Stack trace -

java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class org.unlogged.demo.models.abstraction.PropertyDetails (java.util.LinkedHashMap is in module java.base of loader 'bootstrap'; org.unlogged.demo.models.abstraction.PropertyDetails is in unnamed module of loader 'app')
	at org.unlogged.demo.controller.abstractions.PropertyControllerImpl.findById(PropertyControllerImpl.java:15)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.unlogged.AgentCommandExecutorImpl.executeCommandRaw(AgentCommandExecutorImpl.java:407)
	at io.unlogged.runner.UnloggedTestRunner.executeCandidate(UnloggedTestRunner.java:542)
	at io.unlogged.runner.UnloggedTestRunner.executeAndVerify(UnloggedTestRunner.java:472)
	at io.unlogged.runner.UnloggedTestRunner.fireTest(UnloggedTestRunner.java:254)
	at io.unlogged.runner.UnloggedTestRunner.executeByDescription(UnloggedTestRunner.java:145)
	at io.unlogged.runner.UnloggedTestRunner.executeByDescription(UnloggedTestRunner.java:153)
	at io.unlogged.runner.UnloggedTestRunner.run(UnloggedTestRunner.java:135)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
	at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class org.unlogged.demo.models.abstraction.PropertyDetails (java.util.LinkedHashMap is in module java.base of loader 'bootstrap'; org.unlogged.demo.models.abstraction.PropertyDetails is in unnamed module of loader 'app')
	at org.unlogged.demo.controller.abstractions.PropertyControllerImpl.findById(PropertyControllerImpl.java:15)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.unlogged.AgentCommandExecutorImpl.executeCommandRaw(AgentCommandExecutorImpl.java:407)
	at io.unlogged.runner.UnloggedTestRunner.executeCandidate(UnloggedTestRunner.java:542)
	at io.unlogged.runner.UnloggedTestRunner.executeAndVerify(UnloggedTestRunner.java:472)
	at io.unlogged.runner.UnloggedTestRunner.fireTest(UnloggedTestRunner.java:254)
	at io.unlogged.runner.UnloggedTestRunner.executeByDescription(UnloggedTestRunner.java:145)
	at io.unlogged.runner.UnloggedTestRunner.executeByDescription(UnloggedTestRunner.java:153)
	at io.unlogged.runner.UnloggedTestRunner.run(UnloggedTestRunner.java:135)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
	at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)

java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class org.unlogged.demo.models.abstraction.PropertyDetails (java.util.LinkedHashMap is in module java.base of loader 'bootstrap'; org.unlogged.demo.models.abstraction.PropertyDetails is in unnamed module of loader 'app')

	at org.unlogged.demo.controller.abstractions.PropertyControllerImpl.findById(PropertyControllerImpl.java:15)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.unlogged.AgentCommandExecutorImpl.executeCommandRaw(AgentCommandExecutorImpl.java:407)
	at io.unlogged.runner.UnloggedTestRunner.executeCandidate(UnloggedTestRunner.java:542)
	at io.unlogged.runner.UnloggedTestRunner.executeAndVerify(UnloggedTestRunner.java:472)
	at io.unlogged.runner.UnloggedTestRunner.fireTest(UnloggedTestRunner.java:254)
	at io.unlogged.runner.UnloggedTestRunner.executeByDescription(UnloggedTestRunner.java:145)
	at io.unlogged.runner.UnloggedTestRunner.executeByDescription(UnloggedTestRunner.java:153)
	at io.unlogged.runner.UnloggedTestRunner.run(UnloggedTestRunner.java:135)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
	at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)

Reproduction steps

  1. Clone and run the test runner on unlogged-spring-maven-demo
  2. The replay cases from PropertyControllerImpl will fail except findAll

Look for cases named as PropertyControllerImpl.{methodname} - normal mocked
...

Expected behavior

For the cases to pass with mocks being correctly picked up.

Additional context

No response

@TheAmg TheAmg added the bug Something isn't working label Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant