@@ -17,7 +17,7 @@ public void testToJson() {
1717 WxMpTemplateMessage tm = WxMpTemplateMessage .builder ()
1818 .toUser ("OPENID" )
1919 .templateId ("ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY" )
20- .miniProgram (new WxMpTemplateMessage .MiniProgram ("xiaochengxuappid12345" , "index?foo=bar" ,true ))
20+ .miniProgram (new WxMpTemplateMessage .MiniProgram ("xiaochengxuappid12345" , "index?foo=bar" , true ))
2121 .url ("http://weixin.qq.com/download" )
2222 .clientMsgId ("MSG_000001" )
2323 .build ();
@@ -26,7 +26,29 @@ public void testToJson() {
2626 new WxMpTemplateData ("first" , "haahah" , "#FF00FF" ));
2727 tm .addData (
2828 new WxMpTemplateData ("remark" , "heihei" , "#FF00FF" ));
29- assertEquals (tm .toJson (), "{\" touser\" :\" OPENID\" ,\" template_id\" :\" ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY\" ,\" client_msg_id\" :\" MSG_000001\" ,\" url\" :\" http://weixin.qq.com/download\" ,\" miniprogram\" :{\" appid\" :\" xiaochengxuappid12345\" ,\" path\" :\" index?foo=bar\" },\" data\" :{\" first\" :{\" value\" :\" haahah\" ,\" color\" :\" #FF00FF\" },\" remark\" :{\" value\" :\" heihei\" ,\" color\" :\" #FF00FF\" }}}" );
29+
30+ assertEquals ("{\" touser\" :\" OPENID\" ,\" template_id\" :\" ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY\" ,\" client_msg_id\" :\" MSG_000001\" ,\" url\" :\" http://weixin.qq.com/download\" ,\" miniprogram\" :{\" appid\" :\" xiaochengxuappid12345\" ,\" path\" :\" index?foo=bar\" },\" data\" :{\" first\" :{\" value\" :\" haahah\" ,\" color\" :\" #FF00FF\" },\" remark\" :{\" value\" :\" heihei\" ,\" color\" :\" #FF00FF\" }}}" , tm .toJson ());
3031 }
3132
33+ @ Test
34+ public void testAddData () {
35+ WxMpTemplateMessage tm = WxMpTemplateMessage .builder ().build ()
36+ .addData (new WxMpTemplateData ("thing01" , "张三李四王麻子张三李四王麻子张三李四王麻子张三李四王麻子" ))
37+ .addData (new WxMpTemplateData ("time01" , "2019年10月1日 15:01" ))
38+ .addData (new WxMpTemplateData ("character_string01" , "1234567890123456789012345678901234567890" ))
39+ .addData (new WxMpTemplateData ("amount01" , "¥100.21" ))
40+ .addData (new WxMpTemplateData ("phone_number01" , "+86-0766-668888661111" ))
41+ .addData (new WxMpTemplateData ("car_number01" , "粤A8Z888挂9" ))
42+ .addData (new WxMpTemplateData ("const01" , "支付状态、排队状态、天气状态、物流状态、用药提醒、还款提醒" ));
43+
44+ assertEquals (7 , tm .getData ().size ());
45+
46+ assertEquals ("张三李四王麻子张三李四王麻子张三李..." , tm .getData ().get (0 ).getValue ());
47+ assertEquals ("2019年10月1日 15:01" , tm .getData ().get (1 ).getValue ());
48+ assertEquals ("12345678901234567890123456789..." , tm .getData ().get (2 ).getValue ());
49+ assertEquals ("¥100.21" , tm .getData ().get (3 ).getValue ());
50+ assertEquals ("+86-0766-66888..." , tm .getData ().get (4 ).getValue ());
51+ assertEquals ("粤A8Z8..." , tm .getData ().get (5 ).getValue ());
52+ assertEquals ("支付状态、排队状态、天气状态、物流..." , tm .getData ().get (6 ).getValue ());
53+ }
3254}
0 commit comments