-
Notifications
You must be signed in to change notification settings - Fork 484
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
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
fastjson1-compatible/src/test/java/com/alibaba/fastjson/v2issues/Issue1676.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,51 @@ | ||
package com.alibaba.fastjson.v2issues; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.lang.reflect.ParameterizedType; | ||
import java.lang.reflect.Type; | ||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertSame; | ||
|
||
public class Issue1676 { | ||
@Test | ||
public void test() { | ||
ParameterizedType parameterizedType = new ParameterizedType() { | ||
@Override | ||
public Type[] getActualTypeArguments() { | ||
return new Type[] {Bean.class}; | ||
} | ||
|
||
@Override | ||
public Type getRawType() { | ||
return Page.class; | ||
} | ||
|
||
@Override | ||
public Type getOwnerType() { | ||
return null; | ||
} | ||
}; | ||
|
||
String s = "{\"current\":1,\"hitCount\":false,\"optimizeCountSql\":true,\"orders\":[],\"pages\":1,\"records\":[{\"name\": \"test\"}],\"searchCount\":true,\"size\":10,\"total\":1}"; | ||
Page fastJson2PageObject = JSON.parseObject(s, parameterizedType); | ||
assertSame(Bean.class, fastJson2PageObject.getRecords().get(0).getClass()); | ||
} | ||
|
||
public static class Bean { | ||
} | ||
|
||
public static class Page<T> { | ||
private List<T> records; | ||
|
||
public List<T> getRecords() { | ||
return records; | ||
} | ||
|
||
public void setRecords(List<T> records) { | ||
this.records = records; | ||
} | ||
} | ||
} |