mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-11-11 19:07:09 +08:00
为新增加的发送红包的接口方法添加单元测试,仅测试接口格式,未测试实际功能
This commit is contained in:
@@ -1,12 +1,26 @@
|
||||
package me.chanjar.weixin.mp.api.impl;
|
||||
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import me.chanjar.weixin.mp.api.ApiTestModule;
|
||||
import me.chanjar.weixin.mp.bean.pay.WxRedpackResult;
|
||||
import me.chanjar.weixin.mp.bean.pay.WxSendRedpackRequest;
|
||||
|
||||
/**
|
||||
* 测试支付相关接口
|
||||
* Created by Binary Wang on 2016/7/28.
|
||||
* @author binarywang (https://github.com/binarywang)
|
||||
*/
|
||||
@Test
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxMpPayServiceImplTest {
|
||||
|
||||
@Inject
|
||||
protected WxMpServiceImpl wxService;
|
||||
|
||||
@Test
|
||||
public void testGetPrepayId() throws Exception {
|
||||
|
||||
@@ -54,7 +68,14 @@ public class WxMpPayServiceImplTest {
|
||||
|
||||
@Test
|
||||
public void testSendRedpack() throws Exception {
|
||||
|
||||
WxSendRedpackRequest request = new WxSendRedpackRequest();
|
||||
request.setActName("abc");
|
||||
request.setClientIp("aaa");
|
||||
request.setMchBillno("aaaa");
|
||||
request
|
||||
.setReOpenid(((ApiTestModule.WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid());
|
||||
WxRedpackResult redpackResult = this.wxService.getPayService().sendRedpack(request);
|
||||
System.err.println(redpackResult);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package me.chanjar.weixin.mp.bean.pay;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.joor.Reflect;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
|
||||
@Test
|
||||
public class WxSendRedpackRequestTest {
|
||||
|
||||
public void test() throws NoSuchFieldException, SecurityException {
|
||||
|
||||
WxSendRedpackRequest request = new WxSendRedpackRequest();
|
||||
request.setMchBillno("123");
|
||||
request.setActName("ab");
|
||||
for (Entry<String, Reflect> entry : Reflect.on(request).fields().entrySet()) {
|
||||
Reflect reflect = entry.getValue();
|
||||
if (reflect.get() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Field field = WxSendRedpackRequest.class.getDeclaredField(entry.getKey());
|
||||
if (field.isAnnotationPresent(XStreamAlias.class)) {
|
||||
System.err.println(reflect.get() + " = " + field.getAnnotation(XStreamAlias.class).value());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user