|
| 1 | +package com.github.binarywang.wxpay.bean.result; |
| 2 | + |
| 3 | +import org.testng.*; |
| 4 | +import org.testng.annotations.*; |
| 5 | + |
| 6 | +/** |
| 7 | + * <pre> |
| 8 | + * Created by Binary Wang on 2017-6-15. |
| 9 | + * @author <a href="https://github.com/binarywang">Binary Wang</a> |
| 10 | + * </pre> |
| 11 | + */ |
| 12 | +public class WxPayOrderNotifyResultTest { |
| 13 | + @Test |
| 14 | + public void testFromXML() throws Exception { |
| 15 | + String xmlString = "<xml>\n" + |
| 16 | + " <appid><![CDATA[wx2421b1c4370ec43b]]></appid>\n" + |
| 17 | + " <attach><![CDATA[支付测试]]></attach>\n" + |
| 18 | + " <bank_type><![CDATA[CFT]]></bank_type>\n" + |
| 19 | + " <fee_type><![CDATA[CNY]]></fee_type>\n" + |
| 20 | + " <is_subscribe><![CDATA[Y]]></is_subscribe>\n" + |
| 21 | + " <mch_id><![CDATA[10000100]]></mch_id>\n" + |
| 22 | + " <nonce_str><![CDATA[5d2b6c2a8db53831f7eda20af46e531c]]></nonce_str>\n" + |
| 23 | + " <openid><![CDATA[oUpF8uMEb4qRXf22hE3X68TekukE]]></openid>\n" + |
| 24 | + " <out_trade_no><![CDATA[1409811653]]></out_trade_no>\n" + |
| 25 | + " <result_code><![CDATA[SUCCESS]]></result_code>\n" + |
| 26 | + " <return_code><![CDATA[SUCCESS]]></return_code>\n" + |
| 27 | + " <sign><![CDATA[B552ED6B279343CB493C5DD0D78AB241]]></sign>\n" + |
| 28 | + " <sub_mch_id><![CDATA[10000100]]></sub_mch_id>\n" + |
| 29 | + " <time_end><![CDATA[20140903131540]]></time_end>\n" + |
| 30 | + " <total_fee>1</total_fee>\n" + |
| 31 | + " <trade_type><![CDATA[JSAPI]]></trade_type>\n" + |
| 32 | + " <transaction_id><![CDATA[1004400740201409030005092168]]></transaction_id>\n" + |
| 33 | + " <coupon_count>2</coupon_count>\n" + |
| 34 | + " <coupon_type_0><![CDATA[CASH]]></coupon_type_0>\n" + |
| 35 | + " <coupon_id_0>10000</coupon_id_0>\n" + |
| 36 | + " <coupon_fee_0>100</coupon_fee_0>\n" + |
| 37 | + " <coupon_type_1><![CDATA[NO_CASH]]></coupon_type_1>\n" + |
| 38 | + " <coupon_id_1>10001</coupon_id_1>\n" + |
| 39 | + " <coupon_fee_1>200</coupon_fee_1>\n" + |
| 40 | + "</xml>"; |
| 41 | + |
| 42 | + WxPayOrderNotifyResult result = WxPayOrderNotifyResult.fromXML(xmlString); |
| 43 | + |
| 44 | + Assert.assertEquals(result.getCouponCount().intValue(), 2); |
| 45 | + Assert.assertNotNull(result.getCouponList()); |
| 46 | + Assert.assertEquals(result.getCouponList().size(), 2); |
| 47 | + |
| 48 | + Assert.assertEquals(result.getCouponList().get(0).getCouponFee().intValue(), 100); |
| 49 | + Assert.assertEquals(result.getCouponList().get(1).getCouponFee().intValue(), 200); |
| 50 | + |
| 51 | + Assert.assertEquals(result.getCouponList().get(0).getCouponType(), "CASH"); |
| 52 | + Assert.assertEquals(result.getCouponList().get(1).getCouponType(), "NO_CASH"); |
| 53 | + |
| 54 | + Assert.assertEquals(result.getCouponList().get(0).getCouponId(), "10000"); |
| 55 | + Assert.assertEquals(result.getCouponList().get(1).getCouponId(), "10001"); |
| 56 | + } |
| 57 | + |
| 58 | +} |
0 commit comments