-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bba3620
commit 422c4cc
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
src/test/java/com/fasterxml/jackson/failing/GenericParameterTypeFactory1456Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.fasterxml.jackson.failing; | ||
|
||
import java.lang.reflect.Method; | ||
import java.lang.reflect.Type; | ||
|
||
import com.fasterxml.jackson.databind.*; | ||
import com.fasterxml.jackson.databind.introspect.AnnotatedClass; | ||
import com.fasterxml.jackson.databind.introspect.AnnotatedMethod; | ||
import com.fasterxml.jackson.databind.introspect.AnnotatedParameter; | ||
|
||
public class GenericParameterTypeFactory1456Test extends BaseMapTest | ||
{ | ||
public static class BaseController<Entity extends BaseEntity> { | ||
public void process(Entity entity) {} | ||
} | ||
|
||
public static class ImplController extends BaseController<ImplEntity> {} | ||
|
||
public static class BaseEntity {} | ||
|
||
public static class ImplEntity extends BaseEntity {} | ||
|
||
private final ObjectMapper MAPPER = new ObjectMapper(); | ||
|
||
public void testGenericParameterDirect() throws Exception | ||
{ | ||
Method proceed = BaseController.class.getMethod("process", BaseEntity.class); | ||
Type entityType = proceed.getGenericParameterTypes()[0]; | ||
|
||
JavaType resolvedType = MAPPER.getTypeFactory().constructType(entityType, ImplController.class); | ||
assertEquals(ImplEntity.class, resolvedType.getRawClass()); | ||
} | ||
|
||
public void testGenericParameterViaClass() throws Exception | ||
{ | ||
BeanDescription desc = MAPPER.getDeserializationConfig().introspect( | ||
MAPPER.constructType(ImplController.class)); | ||
AnnotatedClass ac = desc.getClassInfo(); | ||
AnnotatedMethod m = ac.findMethod("process", new Class<?>[] { BaseEntity.class }); | ||
assertNotNull(m); | ||
assertEquals(1, m.getParameterCount()); | ||
AnnotatedParameter param = m.getParameter(0); | ||
assertEquals(ImplEntity.class, param.getType().getRawClass()); | ||
} | ||
} |