1
0
mirror of synced 2026-02-11 06:07:48 +08:00

pay模块批量添加缺失的javadoc文档

This commit is contained in:
Binary Wang
2018-09-23 22:05:06 +08:00
parent a41ebdc1aa
commit fbca4cdc59
40 changed files with 632 additions and 55 deletions

View File

@@ -1,16 +1,19 @@
package com.github.binarywang.wxpay.bean.notify;
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import org.testng.*;
import org.testng.annotations.*;
/**
* <pre>
* Created by Binary Wang on 2017-6-15.
* @author <a href="https://github.com/binarywang">Binary Wang</a>
* </pre>
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
public class WxPayOrderNotifyResultTest {
/**
* Test from xml.
*/
@Test
public void testFromXML() {
String xmlString = "<xml>\n" +

View File

@@ -28,6 +28,11 @@ public class WxPayRefundNotifyResultTest {
@Inject
private WxPayConfig wxPayConfig;
/**
* Test from xml.
*
* @throws WxPayException the wx pay exception
*/
public void testFromXML() throws WxPayException {
String xmlString = "<xml>" +
"<return_code>SUCCESS</return_code>" +
@@ -42,6 +47,11 @@ public class WxPayRefundNotifyResultTest {
System.out.println(refundNotifyResult);
}
/**
* Encode req info.
*
* @throws Exception the exception
*/
public void encodeReqInfo() throws Exception {
String xml = "<root>\n" +
"<out_refund_no><![CDATA[R4001312001201707262674894706_4]]></out_refund_no>\n" +

View File

@@ -16,10 +16,16 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class WxScanPayNotifyResultTest {
/**
* Test to map.
*/
@Test
public void testToMap() {
}
/**
* Test from xml.
*/
@Test
public void testFromXML() {
String xmlString = "<xml>\n" +

View File

@@ -1,26 +1,42 @@
package com.github.binarywang.wxpay.bean.result;
import java.util.Map;
import org.testng.*;
import org.testng.annotations.*;
import java.util.Map;
/**
* <pre>
* Created by Binary Wang on 2017-01-04.
* @author <a href="https://github.com/binarywang">binarywang(Binary Wang)</a>
* </pre>
*
* @author <a href="https://github.com/binarywang">binarywang(Binary Wang)</a>
*/
public class BaseWxPayResultTest {
/**
* Test get xml value.
*
* @throws Exception the exception
*/
@Test
public void testGetXmlValue() throws Exception {
}
/**
* Test xml 2 doc.
*
* @throws Exception the exception
*/
@Test
public void testXml2Doc() throws Exception {
}
/**
* Test to map.
*
* @throws Exception the exception
*/
@Test
public void testToMap() throws Exception {
WxPayOrderQueryResult result = new WxPayOrderQueryResult();
@@ -53,6 +69,9 @@ public class BaseWxPayResultTest {
}
/**
* Test to map with empty xml string.
*/
@Test(expectedExceptions = {RuntimeException.class})
public void testToMap_with_empty_xmlString() {
WxPayOrderQueryResult result = new WxPayOrderQueryResult();

View File

@@ -6,10 +6,14 @@ import org.testng.annotations.*;
/**
* <pre>
* Created by Binary Wang on 2017-01-04.
* </pre>
*
* @author <a href="https://github.com/binarywang">binarywang(Binary Wang)</a>
* </pre>
*/
public class WxPayOrderQueryResultTest {
/**
* Test compose coupons.
*/
@Test
public void testComposeCoupons() {
/*

View File

@@ -13,6 +13,9 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
public class WxPayRedpackQueryResultTest {
/**
* Test from xml.
*/
@Test
public void testFromXML() {
String xmlString = "<xml>\n" +

View File

@@ -7,10 +7,16 @@ import org.testng.annotations.*;
/**
* <pre>
* Created by Binary Wang on 2016-12-29.
* </pre>
*
* @author <a href="https://github.com/binarywang">binarywang(Binary Wang)</a>
* </pre>
*/
public class WxPayRefundQueryResultTest {
/**
* Compose refund records.
*
* @throws Exception the exception
*/
@Test
public void composeRefundRecords() throws Exception {
/*

View File

@@ -13,6 +13,9 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class WxPayRefundResultTest {
/**
* Test compose refund coupons.
*/
@Test
public void testComposeRefundCoupons() {
/*

View File

@@ -1,20 +1,30 @@
package com.github.binarywang.wxpay.bean.result;
import com.thoughtworks.xstream.XStream;
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
import org.testng.*;
import org.testng.annotations.*;
import com.thoughtworks.xstream.XStream;
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
/**
* The type Wx pay send redpack result test.
*/
public class WxPaySendRedpackResultTest {
private XStream xstream;
/**
* Sets .
*/
@BeforeTest
public void setup() {
this.xstream = XStreamInitializer.getInstance();
this.xstream.processAnnotations(WxPaySendRedpackResult.class);
}
/**
* Load success result.
*/
@Test
public void loadSuccessResult() {
final String successSample = "<xml>\n" +
@@ -37,6 +47,9 @@ public class WxPaySendRedpackResultTest {
Assert.assertEquals("20150520102602", wxMpRedpackResult.getSendTime());
}
/**
* Load failure result.
*/
@Test
public void loadFailureResult() {
final String failureSample = "<xml>\n" +

View File

@@ -14,6 +14,11 @@ import static org.testng.Assert.*;
public class WxPayConfigTest {
private WxPayConfig payConfig = new WxPayConfig();
/**
* Test init ssl context.
*
* @throws Exception the exception
*/
@Test
public void testInitSSLContext() throws Exception {
payConfig.setMchId("123");

View File

@@ -68,6 +68,8 @@ public class BaseWxPayServiceImplTest {
/**
* Test method for {@link WxPayService#unifiedOrder(WxPayUnifiedOrderRequest)}.
*
* @throws WxPayException the wx pay exception
*/
@Test
public void testUnifiedOrder() throws WxPayException {
@@ -86,11 +88,21 @@ public class BaseWxPayServiceImplTest {
this.logger.warn(this.payService.getWxApiData().toString());
}
/**
* Test create order.
*
* @throws Exception the exception
*/
@Test
public void testCreateOrder() throws Exception {
//see other tests with method name starting with 'testCreateOrder_'
}
/**
* Test create order jsapi.
*
* @throws Exception the exception
*/
@Test
public void testCreateOrder_jsapi() throws Exception {
WxPayMpOrderResult result = this.payService
@@ -107,6 +119,11 @@ public class BaseWxPayServiceImplTest {
this.logger.warn(this.payService.getWxApiData().toString());
}
/**
* Test create order app.
*
* @throws Exception the exception
*/
@Test
public void testCreateOrder_app() throws Exception {
WxPayAppOrderResult result = this.payService
@@ -122,6 +139,11 @@ public class BaseWxPayServiceImplTest {
this.logger.warn(this.payService.getWxApiData().toString());
}
/**
* Test create order native.
*
* @throws Exception the exception
*/
@Test
public void testCreateOrder_native() throws Exception {
WxPayNativeOrderResult result = this.payService
@@ -138,6 +160,11 @@ public class BaseWxPayServiceImplTest {
this.logger.warn(this.payService.getWxApiData().toString());
}
/**
* Test get pay info.
*
* @throws Exception the exception
*/
@Test
public void testGetPayInfo() throws Exception {
//please use createOrder instead
@@ -145,6 +172,8 @@ public class BaseWxPayServiceImplTest {
/**
* Test method for {@link WxPayService#queryOrder(String, String)} .
*
* @throws WxPayException the wx pay exception
*/
@Test
public void testQueryOrder() throws WxPayException {
@@ -154,12 +183,19 @@ public class BaseWxPayServiceImplTest {
/**
* Test method for {@link WxPayService#closeOrder(String)} .
*
* @throws WxPayException the wx pay exception
*/
@Test
public void testCloseOrder() throws WxPayException {
this.logger.info(this.payService.closeOrder("11212121").toString());
}
/**
* Billing data object [ ] [ ].
*
* @return the object [ ] [ ]
*/
@DataProvider
public Object[][] billingData() {
return new Object[][]{
@@ -174,6 +210,15 @@ public class BaseWxPayServiceImplTest {
};
}
/**
* Test download bill.
*
* @param billDate the bill date
* @param billType the bill type
* @param tarType the tar type
* @param deviceInfo the device info
* @throws Exception the exception
*/
@Test(dataProvider = "billingData")
public void testDownloadBill(String billDate, String billType,
String tarType, String deviceInfo) throws Exception {
@@ -182,12 +227,22 @@ public class BaseWxPayServiceImplTest {
this.logger.info(billResult.toString());
}
/**
* Test download bill with no params.
*
* @throws Exception the exception
*/
@Test(expectedExceptions = WxPayException.class)
public void testDownloadBill_withNoParams() throws Exception {
//必填字段为空时,抛出异常
this.payService.downloadBill("", "", "", null);
}
/**
* Fund flow data object [ ] [ ].
*
* @return the object [ ] [ ]
*/
@DataProvider
public Object[][] fundFlowData() {
return new Object[][]{
@@ -200,6 +255,14 @@ public class BaseWxPayServiceImplTest {
};
}
/**
* Test download fund flow.
*
* @param billDate the bill date
* @param accountType the account type
* @param tarType the tar type
* @throws Exception the exception
*/
@Test(dataProvider = "fundFlowData")
public void testDownloadFundFlow(String billDate, String accountType, String tarType) throws Exception {
WxPayFundFlowResult fundFlowResult = this.payService.downloadFundFlow(billDate, accountType, tarType);
@@ -207,12 +270,22 @@ public class BaseWxPayServiceImplTest {
this.logger.info(fundFlowResult.toString());
}
/**
* Test download fund flow with no params.
*
* @throws Exception the exception
*/
@Test(expectedExceptions = WxPayException.class)
public void testDownloadFundFlow_withNoParams() throws Exception {
//必填字段为空时,抛出异常
this.payService.downloadFundFlow("", "", null);
}
/**
* Test report.
*
* @throws Exception the exception
*/
@Test
public void testReport() throws Exception {
WxPayReportRequest request = new WxPayReportRequest();
@@ -227,6 +300,8 @@ public class BaseWxPayServiceImplTest {
/**
* Test method for {@link WxPayService#refund(WxPayRefundRequest)} .
*
* @throws Exception the exception
*/
@Test
public void testRefund() throws Exception {
@@ -242,6 +317,8 @@ public class BaseWxPayServiceImplTest {
/**
* Test method for {@link WxPayService#refundQuery(String, String, String, String)} .
*
* @throws Exception the exception
*/
@Test
public void testRefundQuery() throws Exception {
@@ -264,6 +341,11 @@ public class BaseWxPayServiceImplTest {
this.logger.info(result.toString());
}
/**
* Test parse refund notify result.
*
* @throws Exception the exception
*/
@Test
public void testParseRefundNotifyResult() throws Exception {
// 请参考com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResultTest里的单元测试
@@ -271,6 +353,8 @@ public class BaseWxPayServiceImplTest {
/**
* Test method for {@link WxPayService#sendRedpack(WxPaySendRedpackRequest)} .
*
* @throws Exception the exception
*/
@Test
public void testSendRedpack() throws Exception {
@@ -289,6 +373,8 @@ public class BaseWxPayServiceImplTest {
/**
* Test method for {@link WxPayService#queryRedpack(String)}.
*
* @throws Exception the exception
*/
@Test
public void testQueryRedpack() throws Exception {
@@ -296,6 +382,11 @@ public class BaseWxPayServiceImplTest {
this.logger.info(redpackResult.toString());
}
/**
* Test create scan pay qrcode mode 1.
*
* @throws Exception the exception
*/
@Test
public void testCreateScanPayQrcodeMode1() throws Exception {
String productId = "abc";
@@ -309,6 +400,11 @@ public class BaseWxPayServiceImplTest {
assertTrue(qrcodeContent.contains("product_id=" + productId));
}
/**
* Test create scan pay qrcode mode 2.
*
* @throws Exception the exception
*/
@Test
public void testCreateScanPayQrcodeMode2() throws Exception {
String qrcodeContent = "abc";
@@ -318,6 +414,11 @@ public class BaseWxPayServiceImplTest {
assertEquals(QrcodeUtils.decodeQrcode(qrcodeFilePath.toFile()), qrcodeContent);
}
/**
* Test micropay.
*
* @throws Exception the exception
*/
@Test
public void testMicropay() throws Exception {
WxPayMicropayResult result = this.payService.micropay(
@@ -332,16 +433,31 @@ public class BaseWxPayServiceImplTest {
this.logger.info(result.toString());
}
/**
* Test get config.
*
* @throws Exception the exception
*/
@Test
public void testGetConfig() throws Exception {
// no need to test
}
/**
* Test set config.
*
* @throws Exception the exception
*/
@Test
public void testSetConfig() throws Exception {
// no need to test
}
/**
* Test reverse order.
*
* @throws Exception the exception
*/
@Test
public void testReverseOrder() throws Exception {
WxPayOrderReverseResult result = this.payService.reverseOrder(
@@ -353,6 +469,11 @@ public class BaseWxPayServiceImplTest {
this.logger.info(result.toString());
}
/**
* Test shorturl.
*
* @throws Exception the exception
*/
@Test
public void testShorturl() throws Exception {
String longUrl = "weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXXX&time_stamp=XXXXXX&nonce_str=XXXXX";
@@ -366,6 +487,11 @@ public class BaseWxPayServiceImplTest {
this.logger.info(result);
}
/**
* Test authcode 2 openid.
*
* @throws Exception the exception
*/
@Test
public void testAuthcode2Openid() throws Exception {
String authCode = "11111";
@@ -379,6 +505,11 @@ public class BaseWxPayServiceImplTest {
this.logger.info(result);
}
/**
* Test get sandbox sign key.
*
* @throws Exception the exception
*/
@Test
public void testGetSandboxSignKey() throws Exception {
final String signKey = this.payService.getSandboxSignKey();
@@ -386,6 +517,11 @@ public class BaseWxPayServiceImplTest {
this.logger.info(signKey);
}
/**
* Test send coupon.
*
* @throws Exception the exception
*/
@Test
public void testSendCoupon() throws Exception {
WxPayCouponSendResult result = this.payService.sendCoupon(WxPayCouponSendRequest.newBuilder()
@@ -397,6 +533,11 @@ public class BaseWxPayServiceImplTest {
this.logger.info(result.toString());
}
/**
* Test query coupon stock.
*
* @throws Exception the exception
*/
@Test
public void testQueryCouponStock() throws Exception {
WxPayCouponStockQueryResult result = this.payService.queryCouponStock(
@@ -407,6 +548,11 @@ public class BaseWxPayServiceImplTest {
this.logger.info(result.toString());
}
/**
* Test query coupon info.
*
* @throws Exception the exception
*/
@Test
public void testQueryCouponInfo() throws Exception {
WxPayCouponInfoQueryResult result = this.payService.queryCouponInfo(
@@ -421,6 +567,8 @@ public class BaseWxPayServiceImplTest {
/**
* 只支持拉取90天内的评论数据
*
* @throws Exception the exception
*/
@Test
public void testQueryComment() throws Exception {
@@ -434,7 +582,10 @@ public class BaseWxPayServiceImplTest {
}
/**
* @see WxPayOrderNotifyResultTest#testFromXML()
* Test parse order notify result.
*
* @throws Exception the exception
* @see WxPayOrderNotifyResultTest#testFromXML() WxPayOrderNotifyResultTest#testFromXML()
*/
@Test
public void testParseOrderNotifyResult() throws Exception {
@@ -471,6 +622,11 @@ public class BaseWxPayServiceImplTest {
System.out.println(result);
}
/**
* Test get wx api data.
*
* @throws Exception the exception
*/
@Test
public void testGetWxApiData() throws Exception {
//see test in testUnifiedOrder()

View File

@@ -28,6 +28,11 @@ public class EntPayServiceImplTest {
@Inject
private WxPayService payService;
/**
* Test ent pay.
*
* @throws WxPayException the wx pay exception
*/
@Test
public void testEntPay() throws WxPayException {
EntPayRequest request = EntPayRequest.newBuilder()
@@ -42,16 +47,31 @@ public class EntPayServiceImplTest {
this.logger.info(this.payService.getEntPayService().entPay(request).toString());
}
/**
* Test query ent pay.
*
* @throws WxPayException the wx pay exception
*/
@Test
public void testQueryEntPay() throws WxPayException {
this.logger.info(this.payService.getEntPayService().queryEntPay("11212121").toString());
}
/**
* Test get public key.
*
* @throws Exception the exception
*/
@Test
public void testGetPublicKey() throws Exception {
this.logger.info(this.payService.getEntPayService().getPublicKey());
}
/**
* Test pay bank.
*
* @throws Exception the exception
*/
@Test
public void testPayBank() throws Exception {
EntPayBankResult result = this.payService.getEntPayService().payBank(EntPayBankRequest.builder()
@@ -65,6 +85,11 @@ public class EntPayServiceImplTest {
this.logger.info(result.toString());
}
/**
* Test query pay bank.
*
* @throws Exception the exception
*/
@Test
public void testQueryPayBank() throws Exception {
this.logger.info(this.payService.getEntPayService().queryPayBank("123").toString());

View File

@@ -14,6 +14,9 @@ import com.google.inject.Module;
import com.thoughtworks.xstream.XStream;
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
/**
* The type Api test module.
*/
public class ApiTestModule implements Module {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private static final String TEST_CONFIG_XML = "test-config.xml";

View File

@@ -3,14 +3,27 @@ package com.github.binarywang.wxpay.testbase;
import com.github.binarywang.wxpay.config.WxPayConfig;
import com.thoughtworks.xstream.annotations.XStreamAlias;
/**
* The type Xml wx pay config.
*/
@XStreamAlias("xml")
public class XmlWxPayConfig extends WxPayConfig {
private String openid;
/**
* Gets openid.
*
* @return the openid
*/
public String getOpenid() {
return openid;
}
/**
* Sets openid.
*
* @param openid the openid
*/
public void setOpenid(String openid) {
this.openid = openid;
}

View File

@@ -17,6 +17,11 @@ import static org.testng.Assert.*;
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
public class SignUtilsTest {
/**
* Test create sign.
*
* @throws Exception the exception
*/
@Test
public void testCreateSign() throws Exception {
String signKey = "192006250b4c09247ec02edce69f6a2d";
@@ -25,6 +30,11 @@ public class SignUtilsTest {
"9A0A8659F005D6984697E2CA0A9CF3B7");
}
/**
* Test create sign hmacsha 256.
*
* @throws Exception the exception
*/
@Test
public void testCreateSign_HMACSHA256() throws Exception {
String signKey = "192006250b4c09247ec02edce69f6a2d";
@@ -34,6 +44,11 @@ public class SignUtilsTest {
assertEquals(sign, "6A9AE1657590FD6257D693A078E1C3E4BB6BA4DC30B23E0EE2496E54170DACD6");
}
/**
* Test check sign.
*
* @throws Exception the exception
*/
@Test
public void testCheckSign() throws Exception {
}