|
6 | 6 | import java.util.List; |
7 | 7 | import java.util.Map; |
8 | 8 |
|
| 9 | +import static org.assertj.core.api.Assertions.as; |
9 | 10 | import static org.assertj.core.api.Assertions.assertThat; |
10 | 11 | import static org.testng.Assert.assertEquals; |
11 | 12 | import static org.testng.Assert.assertNotNull; |
@@ -291,4 +292,40 @@ public void testFromXmlForAllFieldsMap() { |
291 | 292 | .containsEntry("Lat", "0") |
292 | 293 | .containsEntry("Lng", "0"); |
293 | 294 | } |
| 295 | + |
| 296 | + /** |
| 297 | + * 自定义交易组件付款通知事件测试用例 |
| 298 | + * msgType等于event且event等于WxConsts.EventType.OPEN_PRODUCT_ORDER_PAY |
| 299 | + */ |
| 300 | + @Test |
| 301 | + public void testFromXmlForOpenProductOrderPayEvent(){ |
| 302 | + String xml = "<xml> \n" + |
| 303 | + " <ToUserName>gh_abcdefg</ToUserName> \n" + |
| 304 | + " <FromUserName>oABCD</FromUserName> \n" + |
| 305 | + " <CreateTime>1642658087</CreateTime> \n" + |
| 306 | + " <MsgType>event</MsgType> \n" + |
| 307 | + " <Event>open_product_order_pay</Event>\n" + |
| 308 | + " <order_info>\n" + |
| 309 | + " <out_order_id>123456</out_order_id>\n" + |
| 310 | + " <order_id>1234567</order_id>\n" + |
| 311 | + " <transaction_id>42000000123123</transaction_id>\n" + |
| 312 | + " <pay_time>2021-12-30 22:31:00</pay_time>\n" + |
| 313 | + " <amount>10</amount>\n" + |
| 314 | + " <sp_openid>oNMZ-5C0SPGHUiKsTwnOXpSHzFvw</sp_openid>\n" + |
| 315 | + " </order_info>\n" + |
| 316 | + "</xml>"; |
| 317 | + WxMaMessage wxMessage = WxMaMessage.fromXml(xml); |
| 318 | + assertThat(wxMessage.getMsgType()).isEqualTo("event"); |
| 319 | + assertThat(wxMessage.getEvent()).isEqualTo(WxConsts.EventType.OPEN_PRODUCT_ORDER_PAY); |
| 320 | + Map<String, Object> allFieldsMap = wxMessage.getAllFieldsMap(); |
| 321 | + Map<String, Object> orderInfo = (Map<String, Object>) allFieldsMap.get("order_info"); |
| 322 | + assertThat(orderInfo).isNotEmpty(); |
| 323 | + assertThat(orderInfo) |
| 324 | + .containsEntry("out_order_id","123456") |
| 325 | + .containsEntry("order_id","1234567") |
| 326 | + .containsEntry("transaction_id","42000000123123") |
| 327 | + .containsEntry("pay_time","2021-12-30 22:31:00") |
| 328 | + .containsEntry("amount","10") |
| 329 | + .containsEntry("sp_openid","oNMZ-5C0SPGHUiKsTwnOXpSHzFvw"); |
| 330 | + } |
294 | 331 | } |
0 commit comments