djcrankypants / spock

Automatically exported from code.google.com/p/spock
0 stars 0 forks source link

Better generics support for mocks and stubs #307

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
For example, when a `Stub()`ed type has a method with return type 
`Holder<Integer>`, the auto-generated stub for `Holder` should return 
`Integer`s, not `Object`s. 

Original issue reported on code.google.com by pnied...@gmail.com on 30 Mar 2013 at 3:20

GoogleCodeExporter commented 8 years ago

Original comment by pnied...@gmail.com on 30 Mar 2013 at 7:15

GoogleCodeExporter commented 8 years ago
Hey Peter -
Where are using the 1.0 SNAPSHOT on an internal project and had some tests 
start failing on Friday after we got the latest snapshot and I think it's 
related to your fixes for this issue.

We are mocking the readValue method in Jackson Databind ObjectMapper class. 
It's signature looks like this:
public <T> T readValue(String content, Class<T> valueType)

This is now throwing an Exception on us from GenericTypeReflector.java:43 
because the 'type' argument being passed into the erase method is null.

When I debug into the code, I see that the call to 
GenericTypeReflector.mapTypeParameters receives these arguments:
toMapType = TypeVariableImpl ("T")
typeAndParams = class com.fasterxml.jackson.databind.ObjectMapper

The code inside mapTypeParameters returns null, because the type information 
isn't on the class, but on the second parameter of the method call.

Love the work you're doing. Let me know if I can provide you will any other 
information. Thanks!

John

Original comment by JEngel...@bloomhealthco.com on 7 Apr 2013 at 5:18

GoogleCodeExporter commented 8 years ago
Can you provide a reproducible example?

Original comment by pnied...@gmail.com on 7 Apr 2013 at 5:47

GoogleCodeExporter commented 8 years ago
Here you go Peter.

Original comment by JEngel...@bloomhealthco.com on 7 Apr 2013 at 7:09

Attachments:

GoogleCodeExporter commented 8 years ago
Fixed. If you find another problem of this kind, please create a new issue.

Original comment by pnied...@gmail.com on 9 Apr 2013 at 8:59