mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-10-30 10:07:06 +08:00
重构WxError相关代码,自动根据代码补充错误中文说明
This commit is contained in:
@ -1,8 +1,9 @@
|
||||
package me.chanjar.weixin.common.bean;
|
||||
package me.chanjar.weixin.common.error;
|
||||
|
||||
import me.chanjar.weixin.common.bean.result.WxError;
|
||||
import org.testng.*;
|
||||
import org.testng.annotations.*;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
@Test
|
||||
public class WxErrorTest {
|
||||
@ -10,26 +11,24 @@ public class WxErrorTest {
|
||||
public void testFromJson() {
|
||||
String json = "{ \"errcode\": 40003, \"errmsg\": \"invalid openid\" }";
|
||||
WxError wxError = WxError.fromJson(json);
|
||||
Assert.assertTrue(wxError.getErrorCode() == 40003);
|
||||
Assert.assertEquals(wxError.getErrorMsg(), "invalid openid");
|
||||
assertEquals(40003, wxError.getErrorCode());
|
||||
assertEquals(wxError.getErrorMsg(), "invalid openid");
|
||||
|
||||
}
|
||||
|
||||
public void testFromBadJson1() {
|
||||
|
||||
String json = "{ \"errcode\": 40003, \"errmsg\": \"invalid openid\", \"media_id\": \"12323423dsfafsf232f\" }";
|
||||
WxError wxError = WxError.fromJson(json);
|
||||
Assert.assertTrue(wxError.getErrorCode() == 40003);
|
||||
Assert.assertEquals(wxError.getErrorMsg(), "invalid openid");
|
||||
assertEquals(40003, wxError.getErrorCode());
|
||||
assertEquals(wxError.getErrorMsg(), "invalid openid");
|
||||
|
||||
}
|
||||
|
||||
public void testFromBadJson2() {
|
||||
|
||||
String json = "{\"access_token\":\"ACCESS_TOKEN\",\"expires_in\":7200}";
|
||||
WxError wxError = WxError.fromJson(json);
|
||||
Assert.assertTrue(wxError.getErrorCode() == 0);
|
||||
Assert.assertEquals(wxError.getErrorMsg(), null);
|
||||
assertEquals(0, wxError.getErrorCode());
|
||||
assertEquals(wxError.getErrorMsg(), null);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user