6
6
import org .testng .Assert ;
7
7
import org .testng .annotations .Test ;
8
8
9
+ import static org .testng .Assert .assertEquals ;
10
+
9
11
@ Test
10
12
public class WxCpMessageTest {
11
13
@@ -14,38 +16,38 @@ public void testTextReply() {
14
16
reply .setToUser ("OPENID" );
15
17
reply .setMsgType (WxConsts .CUSTOM_MSG_TEXT );
16
18
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\" }}" );
18
20
}
19
21
20
22
public void testTextBuild () {
21
23
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\" }}" );
23
25
}
24
26
25
27
public void testImageReply () {
26
28
WxCpMessage reply = new WxCpMessage ();
27
29
reply .setToUser ("OPENID" );
28
30
reply .setMsgType (WxConsts .CUSTOM_MSG_IMAGE );
29
31
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\" }}" );
31
33
}
32
34
33
35
public void testImageBuild () {
34
36
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\" }}" );
36
38
}
37
39
38
40
public void testVoiceReply () {
39
41
WxCpMessage reply = new WxCpMessage ();
40
42
reply .setToUser ("OPENID" );
41
43
reply .setMsgType (WxConsts .CUSTOM_MSG_VOICE );
42
44
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\" }}" );
44
46
}
45
47
46
48
public void testVoiceBuild () {
47
49
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\" }}" );
49
51
}
50
52
51
53
public void testVideoReply () {
@@ -56,12 +58,12 @@ public void testVideoReply() {
56
58
reply .setThumbMediaId ("MEDIA_ID" );
57
59
reply .setTitle ("TITLE" );
58
60
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\" }}" );
60
62
}
61
63
62
64
public void testVideoBuild () {
63
65
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\" }}" );
65
67
}
66
68
67
69
public void testNewsReply () {
@@ -84,7 +86,7 @@ public void testNewsReply() {
84
86
reply .getArticles ().add (article2 );
85
87
86
88
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\" }]}}" );
88
90
}
89
91
90
92
public void testNewsBuild () {
@@ -102,7 +104,7 @@ public void testNewsBuild() {
102
104
103
105
WxCpMessage reply = WxCpMessage .NEWS ().toUser ("OPENID" ).addArticle (article1 ).addArticle (article2 ).build ();
104
106
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\" }]}}" );
106
108
}
107
109
108
110
public void testMpnewsBuild_with_articles () {
@@ -128,15 +130,15 @@ public void testMpnewsBuild_with_articles() {
128
130
129
131
WxCpMessage reply = WxCpMessage .MPNEWS ().toUser ("OPENID" ).addArticle (article1 ).addArticle (article2 ).build ();
130
132
131
- Assert . assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" mpnews\" ," +
133
+ assertEquals (reply .toJson (), "{\" touser\" :\" OPENID\" ,\" msgtype\" :\" mpnews\" ," +
132
134
"\" mpnews\" :{\" articles\" :[{\" title\" :\" Happy Day\" ,\" thumb_media_id\" :\" thumb\" ,\" author\" :\" aaaaaa\" ,\" content_source_url\" :\" nice url\" ,\" content\" :\" hahaha\" ,\" digest\" :\" digest\" ,\" show_cover_pic\" :\" heihei\" }," +
133
135
"{\" title\" :\" Happy Day\" ,\" thumb_media_id\" :\" thumb\" ,\" author\" :\" aaaaaa\" ,\" content_source_url\" :\" nice url\" ,\" content\" :\" hahaha\" ,\" digest\" :\" digest\" ,\" show_cover_pic\" :\" heihei\" }]}}" );
134
136
}
135
137
136
138
public void testMpnewsBuild_with_media_id () {
137
139
WxCpMessage reply = WxCpMessage .MPNEWS ().toUser ("OPENID" ).mediaId ("mmm" ).build ();
138
140
139
- Assert . assertEquals (reply .toJson (),
141
+ assertEquals (reply .toJson (),
140
142
"{\" touser\" :\" OPENID\" ,\" msgtype\" :\" mpnews\" ,\" mpnews\" :{\" media_id\" :\" mmm\" }}" );
141
143
}
142
144
0 commit comments