mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -14,12 +14,12 @@ public class Issue488Test {
|
||||
@Test
|
||||
public void toBeanTest() {
|
||||
String jsonStr = ResourceUtil.readUtf8Str("issue488.json");
|
||||
|
||||
|
||||
ResultSuccess<List<EmailAddress>> result = JSONUtil.toBean(jsonStr,
|
||||
new TypeReference<ResultSuccess<List<EmailAddress>>>() {}, false);
|
||||
|
||||
|
||||
Assert.assertEquals("https://graph.microsoft.com/beta/$metadata#Collection(microsoft.graph.emailAddress)", result.getContext());
|
||||
|
||||
|
||||
List<EmailAddress> adds = result.getValue();
|
||||
Assert.assertEquals("会议室101", adds.get(0).getName());
|
||||
Assert.assertEquals("MeetingRoom101@abc.com", adds.get(0).getAddress());
|
||||
|
@@ -10,31 +10,31 @@ import cn.hutool.core.lang.TypeReference;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
|
||||
public class IssueIVMD5Test {
|
||||
|
||||
|
||||
/**
|
||||
* 测试泛型对象中有泛型字段的转换成功与否
|
||||
*/
|
||||
@Test
|
||||
public void toBeanTest() {
|
||||
String jsonStr = ResourceUtil.readUtf8Str("issueIVMD5.json");
|
||||
|
||||
|
||||
TypeReference<BaseResult<StudentInfo>> typeReference = new TypeReference<BaseResult<StudentInfo>>() {};
|
||||
BaseResult<StudentInfo> bean = JSONUtil.toBean(jsonStr, typeReference.getType(), false);
|
||||
|
||||
|
||||
StudentInfo data2 = bean.getData2();
|
||||
Assert.assertEquals("B4DDF491FDF34074AE7A819E1341CB6C", data2.getAccountId());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 测试泛型对象中有包含泛型字段的类型的转换成功与否,比如List<T> list
|
||||
*/
|
||||
@Test
|
||||
public void toBeanTest2() {
|
||||
String jsonStr = ResourceUtil.readUtf8Str("issueIVMD5.json");
|
||||
|
||||
|
||||
TypeReference<BaseResult<StudentInfo>> typeReference = new TypeReference<BaseResult<StudentInfo>>() {};
|
||||
BaseResult<StudentInfo> bean = JSONUtil.toBean(jsonStr, typeReference.getType(), false);
|
||||
|
||||
|
||||
List<StudentInfo> data = bean.getData();
|
||||
StudentInfo studentInfo = data.get(0);
|
||||
Assert.assertEquals("B4DDF491FDF34074AE7A819E1341CB6C", studentInfo.getAccountId());
|
||||
|
Reference in New Issue
Block a user