From 770381346ceda363ee2490cb79a58fb1a26942fb Mon Sep 17 00:00:00 2001 From: Dmitry Spikhalskiy Date: Wed, 16 Nov 2016 16:53:16 +0300 Subject: [PATCH] Provide a failing test for the issue #1456 --- .../GenericParameterTypeFactory1456Test.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/test/java/com/fasterxml/jackson/failing/GenericParameterTypeFactory1456Test.java diff --git a/src/test/java/com/fasterxml/jackson/failing/GenericParameterTypeFactory1456Test.java b/src/test/java/com/fasterxml/jackson/failing/GenericParameterTypeFactory1456Test.java new file mode 100644 index 0000000000..b1507ac49f --- /dev/null +++ b/src/test/java/com/fasterxml/jackson/failing/GenericParameterTypeFactory1456Test.java @@ -0,0 +1,32 @@ +package com.fasterxml.jackson.failing; + + +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.Test; + +import java.lang.reflect.Method; +import java.lang.reflect.Type; + +import static org.junit.Assert.assertEquals; + +public class GenericParameterTypeFactory1456Test { + public static class BaseController { + public void process(Entity entity) {} + } + + public static class ImplController extends BaseController {} + + public static class BaseEntity {} + + public static class ImplEntity extends BaseEntity {} + + @Test + public void testGenericParameterHierarchy() throws NoSuchMethodException { + Method proceed = BaseController.class.getMethod("process", BaseEntity.class); + Type entityType = proceed.getGenericParameterTypes()[0]; + + JavaType resolvedType = new ObjectMapper().getTypeFactory().constructType(entityType, ImplController.class); + assertEquals(ImplEntity.class, resolvedType.getRawClass()); + } +}