Skip to content

Commit b6b8c28

Browse files
committed
add test
1 parent 8fd770f commit b6b8c28

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package cn.hutool.json;
2+
3+
import cn.hutool.json.serialize.GlobalSerializeMapping;
4+
import cn.hutool.json.serialize.JSONObjectSerializer;
5+
import org.junit.jupiter.api.Assertions;
6+
import org.junit.jupiter.api.Test;
7+
8+
public class IssueIB9MH0Test {
9+
10+
@Test
11+
void parseTest() {
12+
GlobalSerializeMapping.put(TabTypeEnum.class, (JSONObjectSerializer<TabTypeEnum>) (json, bean) -> json.set("code", bean.getCode())
13+
.set("title", bean.getTitle()));
14+
final JSON parse = JSONUtil.parse(TabTypeEnum._01);
15+
Assertions.assertEquals("{\"code\":\"tab_people_home\",\"title\":\"首页\"}", parse.toString());
16+
}
17+
18+
public enum TabTypeEnum {
19+
_01("tab_people_home","首页"),
20+
_02("tab_people_hospital","医院");
21+
22+
private String code;
23+
private String title;
24+
25+
TabTypeEnum(String code, String title) {
26+
this.code = code;
27+
this.title = title;
28+
}
29+
30+
public String getCode() {
31+
return code;
32+
}
33+
34+
public String getTitle() {
35+
return title;
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)