22
33import me .chanjar .weixin .common .api .WxConsts ;
44import me .chanjar .weixin .mp .bean .kefu .WxMpKefuMessage .WxArticle ;
5- import org .testng .* ;
6- import org .testng .annotations .* ;
5+ import org .testng .Assert ;
6+ import org .testng .annotations .Test ;
77
88@ Test
99public class WxMpKefuMessageTest {
@@ -13,38 +13,44 @@ public void testTextReply() {
1313 reply .setToUser ("OPENID" );
1414 reply .setMsgType (WxConsts .KefuMsgType .TEXT );
1515 reply .setContent ("sfsfdsdf" );
16- Assert .assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" text\" ,\" text\" :{\" content\" :\" sfsfdsdf\" }}" );
16+ Assert
17+ .assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" text\" ,\" text\" :{\" content\" :\" sfsfdsdf\" }}" );
1718 }
1819
1920 public void testTextBuild () {
2021 WxMpKefuMessage reply = WxMpKefuMessage .TEXT ().toUser ("OPENID" ).content ("sfsfdsdf" ).build ();
21- Assert .assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" text\" ,\" text\" :{\" content\" :\" sfsfdsdf\" }}" );
22+ Assert
23+ .assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" text\" ,\" text\" :{\" content\" :\" sfsfdsdf\" }}" );
2224 }
2325
2426 public void testImageReply () {
2527 WxMpKefuMessage reply = new WxMpKefuMessage ();
2628 reply .setToUser ("OPENID" );
2729 reply .setMsgType (WxConsts .KefuMsgType .IMAGE );
2830 reply .setMediaId ("MEDIA_ID" );
29- Assert .assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" image\" ,\" image\" :{\" media_id\" :\" MEDIA_ID\" }}" );
31+ Assert .assertEquals (reply .toJson (),
32+ "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" image\" ,\" image\" :{\" media_id\" :\" MEDIA_ID\" }}" );
3033 }
3134
3235 public void testImageBuild () {
3336 WxMpKefuMessage reply = WxMpKefuMessage .IMAGE ().toUser ("OPENID" ).mediaId ("MEDIA_ID" ).build ();
34- Assert .assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" image\" ,\" image\" :{\" media_id\" :\" MEDIA_ID\" }}" );
37+ Assert .assertEquals (reply .toJson (),
38+ "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" image\" ,\" image\" :{\" media_id\" :\" MEDIA_ID\" }}" );
3539 }
3640
3741 public void testVoiceReply () {
3842 WxMpKefuMessage reply = new WxMpKefuMessage ();
3943 reply .setToUser ("OPENID" );
4044 reply .setMsgType (WxConsts .KefuMsgType .VOICE );
4145 reply .setMediaId ("MEDIA_ID" );
42- Assert .assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" voice\" ,\" voice\" :{\" media_id\" :\" MEDIA_ID\" }}" );
46+ Assert .assertEquals (reply .toJson (),
47+ "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" voice\" ,\" voice\" :{\" media_id\" :\" MEDIA_ID\" }}" );
4348 }
4449
4550 public void testVoiceBuild () {
4651 WxMpKefuMessage reply = WxMpKefuMessage .VOICE ().toUser ("OPENID" ).mediaId ("MEDIA_ID" ).build ();
47- Assert .assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" voice\" ,\" voice\" :{\" media_id\" :\" MEDIA_ID\" }}" );
52+ Assert .assertEquals (reply .toJson (),
53+ "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" voice\" ,\" voice\" :{\" media_id\" :\" MEDIA_ID\" }}" );
4854 }
4955
5056 public void testVideoReply () {
@@ -55,12 +61,15 @@ public void testVideoReply() {
5561 reply .setThumbMediaId ("MEDIA_ID" );
5662 reply .setTitle ("TITLE" );
5763 reply .setDescription ("DESCRIPTION" );
58- Assert .assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" video\" ,\" video\" :{\" media_id\" :\" MEDIA_ID\" ,\" thumb_media_id\" :\" MEDIA_ID\" ,\" title\" :\" TITLE\" ,\" description\" :\" DESCRIPTION\" }}" );
64+ Assert .assertEquals (reply .toJson (),
65+ "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" video\" ,\" video\" :{\" media_id\" :\" MEDIA_ID\" ,\" thumb_media_id\" :\" MEDIA_ID\" ,\" title\" :\" TITLE\" ,\" description\" :\" DESCRIPTION\" }}" );
5966 }
6067
6168 public void testVideoBuild () {
62- WxMpKefuMessage reply = WxMpKefuMessage .VIDEO ().toUser ("OPENID" ).title ("TITLE" ).mediaId ("MEDIA_ID" ).thumbMediaId ("MEDIA_ID" ).description ("DESCRIPTION" ).build ();
63- Assert .assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" video\" ,\" video\" :{\" media_id\" :\" MEDIA_ID\" ,\" thumb_media_id\" :\" MEDIA_ID\" ,\" title\" :\" TITLE\" ,\" description\" :\" DESCRIPTION\" }}" );
69+ WxMpKefuMessage reply = WxMpKefuMessage .VIDEO ().toUser ("OPENID" ).title ("TITLE" ).mediaId ("MEDIA_ID" )
70+ .thumbMediaId ("MEDIA_ID" ).description ("DESCRIPTION" ).build ();
71+ Assert .assertEquals (reply .toJson (),
72+ "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" video\" ,\" video\" :{\" media_id\" :\" MEDIA_ID\" ,\" thumb_media_id\" :\" MEDIA_ID\" ,\" title\" :\" TITLE\" ,\" description\" :\" DESCRIPTION\" }}" );
6473 }
6574
6675 public void testMusicReply () {
@@ -72,7 +81,8 @@ public void testMusicReply() {
7281 reply .setTitle ("TITLE" );
7382 reply .setMusicUrl ("MUSIC_URL" );
7483 reply .setHqMusicUrl ("HQ_MUSIC_URL" );
75- Assert .assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" music\" ,\" music\" :{\" title\" :\" TITLE\" ,\" description\" :\" DESCRIPTION\" ,\" thumb_media_id\" :\" MEDIA_ID\" ,\" musicurl\" :\" MUSIC_URL\" ,\" hqmusicurl\" :\" HQ_MUSIC_URL\" }}" );
84+ Assert .assertEquals (reply .toJson (),
85+ "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" music\" ,\" music\" :{\" title\" :\" TITLE\" ,\" description\" :\" DESCRIPTION\" ,\" thumb_media_id\" :\" MEDIA_ID\" ,\" musicurl\" :\" MUSIC_URL\" ,\" hqmusicurl\" :\" HQ_MUSIC_URL\" }}" );
7686 }
7787
7888 public void testMusicBuild () {
@@ -84,7 +94,8 @@ public void testMusicBuild() {
8494 .musicUrl ("MUSIC_URL" )
8595 .hqMusicUrl ("HQ_MUSIC_URL" )
8696 .build ();
87- Assert .assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" music\" ,\" music\" :{\" title\" :\" TITLE\" ,\" description\" :\" DESCRIPTION\" ,\" thumb_media_id\" :\" MEDIA_ID\" ,\" musicurl\" :\" MUSIC_URL\" ,\" hqmusicurl\" :\" HQ_MUSIC_URL\" }}" );
97+ Assert .assertEquals (reply .toJson (),
98+ "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" music\" ,\" music\" :{\" title\" :\" TITLE\" ,\" description\" :\" DESCRIPTION\" ,\" thumb_media_id\" :\" MEDIA_ID\" ,\" musicurl\" :\" MUSIC_URL\" ,\" hqmusicurl\" :\" HQ_MUSIC_URL\" }}" );
8899 }
89100
90101 public void testNewsReply () {
@@ -106,8 +117,8 @@ public void testNewsReply() {
106117 article2 .setTitle ("Happy Day" );
107118 reply .getArticles ().add (article2 );
108119
109-
110- 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\" }]}}" );
120+ Assert . assertEquals ( reply . toJson (),
121+ "{\" 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\" }]}}" );
111122 }
112123
113124 public void testNewsBuild () {
@@ -125,7 +136,22 @@ public void testNewsBuild() {
125136
126137 WxMpKefuMessage reply = WxMpKefuMessage .NEWS ().toUser ("OPENID" ).addArticle (article1 ).addArticle (article2 ).build ();
127138
128- 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\" }]}}" );
139+ Assert .assertEquals (reply .toJson (),
140+ "{\" 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\" }]}}" );
141+ }
142+
143+ public void testMiniProgramPageBuild () {
144+
145+ WxMpKefuMessage reply = WxMpKefuMessage .MINIPROGRAMPAGE ()
146+ .toUser ("OPENID" )
147+ .title ("title" )
148+ .appId ("appid" )
149+ .pagePath ("pagepath" )
150+ .thumbMediaId ("thumb_media_id" )
151+ .build ();
152+
153+ Assert .assertEquals (reply .toJson (),
154+ "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" miniprogrampage\" ,\" miniprogrampage\" :{\" title\" :\" title\" ,\" appid\" :\" appid\" ,\" pagepath\" :\" pagepath\" ,\" thumb_media_id\" :\" thumb_media_id\" }}" );
129155 }
130156
131157}
0 commit comments