66import org .testng .Assert ;
77import org .testng .annotations .Test ;
88
9+ import static org .testng .Assert .assertEquals ;
10+
911@ Test
1012public class WxCpMessageTest {
1113
@@ -14,38 +16,38 @@ public void testTextReply() {
1416 reply .setToUser ("OPENID" );
1517 reply .setMsgType (WxConsts .CUSTOM_MSG_TEXT );
1618 reply .setContent ("sfsfdsdf" );
17- Assert . assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" text\" ,\" text\" :{\" content\" :\" sfsfdsdf\" }}" );
19+ assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" text\" ,\" text\" :{\" content\" :\" sfsfdsdf\" }}" );
1820 }
1921
2022 public void testTextBuild () {
2123 WxCpMessage reply = WxCpMessage .TEXT ().toUser ("OPENID" ).content ("sfsfdsdf" ).build ();
22- Assert . assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" text\" ,\" text\" :{\" content\" :\" sfsfdsdf\" }}" );
24+ assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" text\" ,\" text\" :{\" content\" :\" sfsfdsdf\" }}" );
2325 }
2426
2527 public void testImageReply () {
2628 WxCpMessage reply = new WxCpMessage ();
2729 reply .setToUser ("OPENID" );
2830 reply .setMsgType (WxConsts .CUSTOM_MSG_IMAGE );
2931 reply .setMediaId ("MEDIA_ID" );
30- Assert . assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" image\" ,\" image\" :{\" media_id\" :\" MEDIA_ID\" }}" );
32+ assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" image\" ,\" image\" :{\" media_id\" :\" MEDIA_ID\" }}" );
3133 }
3234
3335 public void testImageBuild () {
3436 WxCpMessage reply = WxCpMessage .IMAGE ().toUser ("OPENID" ).mediaId ("MEDIA_ID" ).build ();
35- Assert . assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" image\" ,\" image\" :{\" media_id\" :\" MEDIA_ID\" }}" );
37+ assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" image\" ,\" image\" :{\" media_id\" :\" MEDIA_ID\" }}" );
3638 }
3739
3840 public void testVoiceReply () {
3941 WxCpMessage reply = new WxCpMessage ();
4042 reply .setToUser ("OPENID" );
4143 reply .setMsgType (WxConsts .CUSTOM_MSG_VOICE );
4244 reply .setMediaId ("MEDIA_ID" );
43- Assert . assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" voice\" ,\" voice\" :{\" media_id\" :\" MEDIA_ID\" }}" );
45+ assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" voice\" ,\" voice\" :{\" media_id\" :\" MEDIA_ID\" }}" );
4446 }
4547
4648 public void testVoiceBuild () {
4749 WxCpMessage reply = WxCpMessage .VOICE ().toUser ("OPENID" ).mediaId ("MEDIA_ID" ).build ();
48- Assert . assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" voice\" ,\" voice\" :{\" media_id\" :\" MEDIA_ID\" }}" );
50+ assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" voice\" ,\" voice\" :{\" media_id\" :\" MEDIA_ID\" }}" );
4951 }
5052
5153 public void testVideoReply () {
@@ -56,12 +58,12 @@ public void testVideoReply() {
5658 reply .setThumbMediaId ("MEDIA_ID" );
5759 reply .setTitle ("TITLE" );
5860 reply .setDescription ("DESCRIPTION" );
59- Assert . assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" video\" ,\" video\" :{\" media_id\" :\" MEDIA_ID\" ,\" thumb_media_id\" :\" MEDIA_ID\" ,\" title\" :\" TITLE\" ,\" description\" :\" DESCRIPTION\" }}" );
61+ assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" video\" ,\" video\" :{\" media_id\" :\" MEDIA_ID\" ,\" thumb_media_id\" :\" MEDIA_ID\" ,\" title\" :\" TITLE\" ,\" description\" :\" DESCRIPTION\" }}" );
6062 }
6163
6264 public void testVideoBuild () {
6365 WxCpMessage reply = WxCpMessage .VIDEO ().toUser ("OPENID" ).title ("TITLE" ).mediaId ("MEDIA_ID" ).thumbMediaId ("MEDIA_ID" ).description ("DESCRIPTION" ).build ();
64- Assert . assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" video\" ,\" video\" :{\" media_id\" :\" MEDIA_ID\" ,\" thumb_media_id\" :\" MEDIA_ID\" ,\" title\" :\" TITLE\" ,\" description\" :\" DESCRIPTION\" }}" );
66+ assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" video\" ,\" video\" :{\" media_id\" :\" MEDIA_ID\" ,\" thumb_media_id\" :\" MEDIA_ID\" ,\" title\" :\" TITLE\" ,\" description\" :\" DESCRIPTION\" }}" );
6567 }
6668
6769 public void testNewsReply () {
@@ -84,7 +86,7 @@ public void testNewsReply() {
8486 reply .getArticles ().add (article2 );
8587
8688
87- Assert . assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" news\" ,\" news\" :{\" articles\" :[{\" title\" :\" Happy Day\" ,\" description\" :\" Is Really A Happy Day\" ,\" url\" :\" URL\" ,\" picurl\" :\" PIC_URL\" },{\" title\" :\" Happy Day\" ,\" description\" :\" Is Really A Happy Day\" ,\" url\" :\" URL\" ,\" picurl\" :\" PIC_URL\" }]}}" );
89+ assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" news\" ,\" news\" :{\" articles\" :[{\" title\" :\" Happy Day\" ,\" description\" :\" Is Really A Happy Day\" ,\" url\" :\" URL\" ,\" picurl\" :\" PIC_URL\" },{\" title\" :\" Happy Day\" ,\" description\" :\" Is Really A Happy Day\" ,\" url\" :\" URL\" ,\" picurl\" :\" PIC_URL\" }]}}" );
8890 }
8991
9092 public void testNewsBuild () {
@@ -102,7 +104,7 @@ public void testNewsBuild() {
102104
103105 WxCpMessage reply = WxCpMessage .NEWS ().toUser ("OPENID" ).addArticle (article1 ).addArticle (article2 ).build ();
104106
105- Assert . assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" news\" ,\" news\" :{\" articles\" :[{\" title\" :\" Happy Day\" ,\" description\" :\" Is Really A Happy Day\" ,\" url\" :\" URL\" ,\" picurl\" :\" PIC_URL\" },{\" title\" :\" Happy Day\" ,\" description\" :\" Is Really A Happy Day\" ,\" url\" :\" URL\" ,\" picurl\" :\" PIC_URL\" }]}}" );
107+ assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" news\" ,\" news\" :{\" articles\" :[{\" title\" :\" Happy Day\" ,\" description\" :\" Is Really A Happy Day\" ,\" url\" :\" URL\" ,\" picurl\" :\" PIC_URL\" },{\" title\" :\" Happy Day\" ,\" description\" :\" Is Really A Happy Day\" ,\" url\" :\" URL\" ,\" picurl\" :\" PIC_URL\" }]}}" );
106108 }
107109
108110 public void testMpnewsBuild_with_articles () {
@@ -128,15 +130,15 @@ public void testMpnewsBuild_with_articles() {
128130
129131 WxCpMessage reply = WxCpMessage .MPNEWS ().toUser ("OPENID" ).addArticle (article1 ).addArticle (article2 ).build ();
130132
131- Assert . assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" mpnews\" ," +
133+ assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" mpnews\" ," +
132134 "\" mpnews\" :{\" articles\" :[{\" title\" :\" Happy Day\" ,\" thumb_media_id\" :\" thumb\" ,\" author\" :\" aaaaaa\" ,\" content_source_url\" :\" nice url\" ,\" content\" :\" hahaha\" ,\" digest\" :\" digest\" ,\" show_cover_pic\" :\" heihei\" }," +
133135 "{\" title\" :\" Happy Day\" ,\" thumb_media_id\" :\" thumb\" ,\" author\" :\" aaaaaa\" ,\" content_source_url\" :\" nice url\" ,\" content\" :\" hahaha\" ,\" digest\" :\" digest\" ,\" show_cover_pic\" :\" heihei\" }]}}" );
134136 }
135137
136138 public void testMpnewsBuild_with_media_id () {
137139 WxCpMessage reply = WxCpMessage .MPNEWS ().toUser ("OPENID" ).mediaId ("mmm" ).build ();
138140
139- Assert . assertEquals (reply .toJson (),
141+ assertEquals (reply .toJson (),
140142 "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" mpnews\" ,\" mpnews\" :{\" media_id\" :\" mmm\" }}" );
141143 }
142144
0 commit comments