mirror of
https://gitee.com/dromara/hutool.git
synced 2026-02-09 09:16:26 +08:00
add test
This commit is contained in:
32
hutool-json/src/test/java/cn/hutool/json/Issue4214Test.java
Normal file
32
hutool-json/src/test/java/cn/hutool/json/Issue4214Test.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package cn.hutool.json;
|
||||
|
||||
import lombok.Data;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class Issue4214Test {
|
||||
|
||||
@Test
|
||||
void toBeanTest(){
|
||||
LicenseInfo licenseInfo = new LicenseInfo();
|
||||
licenseInfo.setAuthTypeEnum(AuthTypeEnum.OFFICIAL);
|
||||
|
||||
String jsonStr = JSONUtil.toJsonStr(licenseInfo);
|
||||
assertEquals("{\"authTypeEnum\":\"OFFICIAL\"}", jsonStr);
|
||||
|
||||
// 这里反序列化会报错
|
||||
LicenseInfo bean = JSONUtil.toBean(jsonStr, LicenseInfo.class);
|
||||
assertEquals(AuthTypeEnum.OFFICIAL, bean.getAuthTypeEnum());
|
||||
}
|
||||
|
||||
@Data
|
||||
static class LicenseInfo{
|
||||
private AuthTypeEnum authTypeEnum;
|
||||
}
|
||||
|
||||
enum AuthTypeEnum{
|
||||
OFFICIAL,
|
||||
SELF_BUILD
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user