15
15
import java .io .File ;
16
16
import java .nio .file .Files ;
17
17
import java .nio .file .Path ;
18
+ import java .util .Map ;
18
19
19
20
import static org .testng .Assert .*;
20
21
26
27
*/
27
28
@ Test
28
29
@ Guice (modules = ApiTestModule .class )
29
- public class WxMpPayServiceImplTest {
30
+ public class WxPayServiceImplTest {
30
31
private final Logger logger = LoggerFactory .getLogger (this .getClass ());
31
32
32
33
@ Inject
33
- protected WxPayService wxService ;
34
+ protected WxPayService payService ;
34
35
35
36
@ Test
36
37
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 ());
38
40
}
39
41
40
42
@ Test
41
43
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" );
43
45
assertNotNull (file );
44
46
//必填字段为空时,抛出异常
45
- this .wxService .downloadBill ("" , "" , "" , null );
47
+ this .payService .downloadBill ("" , "" , "" , null );
46
48
}
47
49
48
50
@ Test
@@ -54,15 +56,15 @@ public void testReport() throws Exception {
54
56
request .setReturnCode ("aaa" );
55
57
request .setResultCode ("aaa" );
56
58
request .setUserIp ("8.8.8" );
57
- this .wxService .report (request );
59
+ this .payService .report (request );
58
60
}
59
61
60
62
/**
61
63
* Test method for {@link WxPayService#refund(WxPayRefundRequest)} .
62
64
*/
63
65
@ Test
64
66
public void testRefund () throws Exception {
65
- WxPayRefundResult result = this .wxService .refund (
67
+ WxPayRefundResult result = this .payService .refund (
66
68
WxPayRefundRequest .newBuilder ()
67
69
.outRefundNo ("aaa" )
68
70
.outTradeNo ("1111" )
@@ -79,20 +81,20 @@ public void testRefund() throws Exception {
79
81
public void testRefundQuery () throws Exception {
80
82
WxPayRefundQueryResult result ;
81
83
82
- result = this .wxService .refundQuery ("1" , "" , "" , "" );
84
+ result = this .payService .refundQuery ("1" , "" , "" , "" );
83
85
this .logger .info (result .toString ());
84
86
85
- result = this .wxService .refundQuery ("" , "2" , "" , "" );
87
+ result = this .payService .refundQuery ("" , "2" , "" , "" );
86
88
this .logger .info (result .toString ());
87
89
88
- result = this .wxService .refundQuery ("" , "" , "3" , "" );
90
+ result = this .payService .refundQuery ("" , "" , "3" , "" );
89
91
this .logger .info (result .toString ());
90
92
91
- result = this .wxService .refundQuery ("" , "" , "" , "4" );
93
+ result = this .payService .refundQuery ("" , "" , "" , "4" );
92
94
this .logger .info (result .toString ());
93
95
94
96
//测试四个参数都填的情况,应该报异常的
95
- result = this .wxService .refundQuery ("1" , "2" , "3" , "4" );
97
+ result = this .payService .refundQuery ("1" , "2" , "3" , "4" );
96
98
this .logger .info (result .toString ());
97
99
}
98
100
@@ -105,8 +107,8 @@ public void testSendRedpack() throws Exception {
105
107
request .setActName ("abc" );
106
108
request .setClientIp ("aaa" );
107
109
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 );
110
112
this .logger .info (redpackResult .toString ());
111
113
}
112
114
@@ -115,7 +117,7 @@ public void testSendRedpack() throws Exception {
115
117
*/
116
118
@ Test
117
119
public void testQueryRedpack () throws Exception {
118
- WxPayRedpackQueryResult redpackResult = this .wxService .queryRedpack ("aaaa" );
120
+ WxPayRedpackQueryResult redpackResult = this .payService .queryRedpack ("aaaa" );
119
121
this .logger .info (redpackResult .toString ());
120
122
}
121
123
@@ -124,14 +126,14 @@ public void testQueryRedpack() throws Exception {
124
126
*/
125
127
@ Test
126
128
public void testUnifiedOrder () throws WxErrorException {
127
- WxPayUnifiedOrderResult result = this .wxService
129
+ WxPayUnifiedOrderResult result = this .payService
128
130
.unifiedOrder (WxPayUnifiedOrderRequest .builder ()
129
131
.body ("我去" )
130
132
.totalFee (1 )
131
133
.spbillCreateIp ("111111" )
132
134
.notifyURL ("111111" )
133
135
.tradeType ("JSAPI" )
134
- .openid (((XmlWxPayConfig ) this .wxService .getConfig ()).getOpenid ())
136
+ .openid (((XmlWxPayConfig ) this .payService .getConfig ()).getOpenid ())
135
137
.outTradeNo ("111111" )
136
138
.build ());
137
139
this .logger .info (result .toString ());
@@ -142,16 +144,16 @@ public void testUnifiedOrder() throws WxErrorException {
142
144
*/
143
145
@ Test
144
146
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 ());
147
149
}
148
150
149
151
/**
150
152
* Test method for {@link WxPayService#closeOrder(java.lang.String)} .
151
153
*/
152
154
@ Test
153
155
public void testCloseOrder () throws WxErrorException {
154
- this .logger .info (this .wxService .closeOrder ("11212121" ).toString ());
156
+ this .logger .info (this .payService .closeOrder ("11212121" ).toString ());
155
157
}
156
158
157
159
/**
@@ -160,21 +162,21 @@ public void testCloseOrder() throws WxErrorException {
160
162
@ Test
161
163
public void testEntPay () throws WxErrorException {
162
164
WxEntPayRequest request = new WxEntPayRequest ();
163
- this .logger .info (this .wxService .entPay (request ).toString ());
165
+ this .logger .info (this .payService .entPay (request ).toString ());
164
166
}
165
167
166
168
/**
167
169
* Test method for {@link WxPayService#queryEntPay(java.lang.String)}.
168
170
*/
169
171
@ Test
170
172
public void testQueryEntPay () throws WxErrorException {
171
- this .logger .info (this .wxService .queryEntPay ("11212121" ).toString ());
173
+ this .logger .info (this .payService .queryEntPay ("11212121" ).toString ());
172
174
}
173
175
174
176
@ Test
175
177
public void testCreateScanPayQrcodeMode1 () throws Exception {
176
178
String productId = "abc" ;
177
- byte [] bytes = this .wxService .createScanPayQrcodeMode1 (productId , null , null );
179
+ byte [] bytes = this .payService .createScanPayQrcodeMode1 (productId , null , null );
178
180
Path qrcodeFilePath = Files .createTempFile ("qrcode_" , ".jpg" );
179
181
Files .write (qrcodeFilePath , bytes );
180
182
String qrcodeContent = QrcodeUtils .decodeQrcode (qrcodeFilePath .toFile ());
@@ -187,7 +189,7 @@ public void testCreateScanPayQrcodeMode1() throws Exception {
187
189
@ Test
188
190
public void testCreateScanPayQrcodeMode2 () throws Exception {
189
191
String qrcodeContent = "abc" ;
190
- byte [] bytes = this .wxService .createScanPayQrcodeMode2 (qrcodeContent , null , null );
192
+ byte [] bytes = this .payService .createScanPayQrcodeMode2 (qrcodeContent , null , null );
191
193
Path qrcodeFilePath = Files .createTempFile ("qrcode_" , ".jpg" );
192
194
Files .write (qrcodeFilePath , bytes );
193
195
assertEquals (QrcodeUtils .decodeQrcode (qrcodeFilePath .toFile ()), qrcodeContent );
0 commit comments