1515import java .io .File ;
1616import java .nio .file .Files ;
1717import java .nio .file .Path ;
18+ import java .util .Map ;
1819
1920import static org .testng .Assert .*;
2021
2627 */
2728@ Test
2829@ Guice (modules = ApiTestModule .class )
29- public class WxMpPayServiceImplTest {
30+ public class WxPayServiceImplTest {
3031 private final Logger logger = LoggerFactory .getLogger (this .getClass ());
3132
3233 @ Inject
33- protected WxPayService wxService ;
34+ protected WxPayService payService ;
3435
3536 @ Test
3637 public void testGetPayInfo () throws Exception {
37-
38+ Map <String , String > payInfo = this .payService .getPayInfo (WxPayUnifiedOrderRequest .builder ().body ("abc" ).build ());
39+ this .logger .info (payInfo .toString ());
3840 }
3941
4042 @ Test
4143 public void testDownloadBill () throws Exception {
42- File file = this .wxService .downloadBill ("20170101" , "ALL" , "GZIP" , "1111111" );
44+ File file = this .payService .downloadBill ("20170101" , "ALL" , "GZIP" , "1111111" );
4345 assertNotNull (file );
4446 //必填字段为空时,抛出异常
45- this .wxService .downloadBill ("" , "" , "" , null );
47+ this .payService .downloadBill ("" , "" , "" , null );
4648 }
4749
4850 @ Test
@@ -54,15 +56,15 @@ public void testReport() throws Exception {
5456 request .setReturnCode ("aaa" );
5557 request .setResultCode ("aaa" );
5658 request .setUserIp ("8.8.8" );
57- this .wxService .report (request );
59+ this .payService .report (request );
5860 }
5961
6062 /**
6163 * Test method for {@link WxPayService#refund(WxPayRefundRequest)} .
6264 */
6365 @ Test
6466 public void testRefund () throws Exception {
65- WxPayRefundResult result = this .wxService .refund (
67+ WxPayRefundResult result = this .payService .refund (
6668 WxPayRefundRequest .newBuilder ()
6769 .outRefundNo ("aaa" )
6870 .outTradeNo ("1111" )
@@ -79,20 +81,20 @@ public void testRefund() throws Exception {
7981 public void testRefundQuery () throws Exception {
8082 WxPayRefundQueryResult result ;
8183
82- result = this .wxService .refundQuery ("1" , "" , "" , "" );
84+ result = this .payService .refundQuery ("1" , "" , "" , "" );
8385 this .logger .info (result .toString ());
8486
85- result = this .wxService .refundQuery ("" , "2" , "" , "" );
87+ result = this .payService .refundQuery ("" , "2" , "" , "" );
8688 this .logger .info (result .toString ());
8789
88- result = this .wxService .refundQuery ("" , "" , "3" , "" );
90+ result = this .payService .refundQuery ("" , "" , "3" , "" );
8991 this .logger .info (result .toString ());
9092
91- result = this .wxService .refundQuery ("" , "" , "" , "4" );
93+ result = this .payService .refundQuery ("" , "" , "" , "4" );
9294 this .logger .info (result .toString ());
9395
9496 //测试四个参数都填的情况,应该报异常的
95- result = this .wxService .refundQuery ("1" , "2" , "3" , "4" );
97+ result = this .payService .refundQuery ("1" , "2" , "3" , "4" );
9698 this .logger .info (result .toString ());
9799 }
98100
@@ -105,8 +107,8 @@ public void testSendRedpack() throws Exception {
105107 request .setActName ("abc" );
106108 request .setClientIp ("aaa" );
107109 request .setMchBillNo ("aaaa" );
108- request .setReOpenid (((XmlWxPayConfig ) this .wxService .getConfig ()).getOpenid ());
109- WxPaySendRedpackResult redpackResult = this .wxService .sendRedpack (request );
110+ request .setReOpenid (((XmlWxPayConfig ) this .payService .getConfig ()).getOpenid ());
111+ WxPaySendRedpackResult redpackResult = this .payService .sendRedpack (request );
110112 this .logger .info (redpackResult .toString ());
111113 }
112114
@@ -115,7 +117,7 @@ public void testSendRedpack() throws Exception {
115117 */
116118 @ Test
117119 public void testQueryRedpack () throws Exception {
118- WxPayRedpackQueryResult redpackResult = this .wxService .queryRedpack ("aaaa" );
120+ WxPayRedpackQueryResult redpackResult = this .payService .queryRedpack ("aaaa" );
119121 this .logger .info (redpackResult .toString ());
120122 }
121123
@@ -124,14 +126,14 @@ public void testQueryRedpack() throws Exception {
124126 */
125127 @ Test
126128 public void testUnifiedOrder () throws WxErrorException {
127- WxPayUnifiedOrderResult result = this .wxService
129+ WxPayUnifiedOrderResult result = this .payService
128130 .unifiedOrder (WxPayUnifiedOrderRequest .builder ()
129131 .body ("我去" )
130132 .totalFee (1 )
131133 .spbillCreateIp ("111111" )
132134 .notifyURL ("111111" )
133135 .tradeType ("JSAPI" )
134- .openid (((XmlWxPayConfig ) this .wxService .getConfig ()).getOpenid ())
136+ .openid (((XmlWxPayConfig ) this .payService .getConfig ()).getOpenid ())
135137 .outTradeNo ("111111" )
136138 .build ());
137139 this .logger .info (result .toString ());
@@ -142,16 +144,16 @@ public void testUnifiedOrder() throws WxErrorException {
142144 */
143145 @ Test
144146 public void testQueryOrder () throws WxErrorException {
145- this .logger .info (this .wxService .queryOrder ("11212121" , null ).toString ());
146- this .logger .info (this .wxService .queryOrder (null , "11111" ).toString ());
147+ this .logger .info (this .payService .queryOrder ("11212121" , null ).toString ());
148+ this .logger .info (this .payService .queryOrder (null , "11111" ).toString ());
147149 }
148150
149151 /**
150152 * Test method for {@link WxPayService#closeOrder(java.lang.String)} .
151153 */
152154 @ Test
153155 public void testCloseOrder () throws WxErrorException {
154- this .logger .info (this .wxService .closeOrder ("11212121" ).toString ());
156+ this .logger .info (this .payService .closeOrder ("11212121" ).toString ());
155157 }
156158
157159 /**
@@ -160,21 +162,21 @@ public void testCloseOrder() throws WxErrorException {
160162 @ Test
161163 public void testEntPay () throws WxErrorException {
162164 WxEntPayRequest request = new WxEntPayRequest ();
163- this .logger .info (this .wxService .entPay (request ).toString ());
165+ this .logger .info (this .payService .entPay (request ).toString ());
164166 }
165167
166168 /**
167169 * Test method for {@link WxPayService#queryEntPay(java.lang.String)}.
168170 */
169171 @ Test
170172 public void testQueryEntPay () throws WxErrorException {
171- this .logger .info (this .wxService .queryEntPay ("11212121" ).toString ());
173+ this .logger .info (this .payService .queryEntPay ("11212121" ).toString ());
172174 }
173175
174176 @ Test
175177 public void testCreateScanPayQrcodeMode1 () throws Exception {
176178 String productId = "abc" ;
177- byte [] bytes = this .wxService .createScanPayQrcodeMode1 (productId , null , null );
179+ byte [] bytes = this .payService .createScanPayQrcodeMode1 (productId , null , null );
178180 Path qrcodeFilePath = Files .createTempFile ("qrcode_" , ".jpg" );
179181 Files .write (qrcodeFilePath , bytes );
180182 String qrcodeContent = QrcodeUtils .decodeQrcode (qrcodeFilePath .toFile ());
@@ -187,7 +189,7 @@ public void testCreateScanPayQrcodeMode1() throws Exception {
187189 @ Test
188190 public void testCreateScanPayQrcodeMode2 () throws Exception {
189191 String qrcodeContent = "abc" ;
190- byte [] bytes = this .wxService .createScanPayQrcodeMode2 (qrcodeContent , null , null );
192+ byte [] bytes = this .payService .createScanPayQrcodeMode2 (qrcodeContent , null , null );
191193 Path qrcodeFilePath = Files .createTempFile ("qrcode_" , ".jpg" );
192194 Files .write (qrcodeFilePath , bytes );
193195 assertEquals (QrcodeUtils .decodeQrcode (qrcodeFilePath .toFile ()), qrcodeContent );
0 commit comments