forked from binarywang/WxJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBusinessOperationTransferServiceTest.java
More file actions
104 lines (85 loc) · 3.75 KB
/
BusinessOperationTransferServiceTest.java
File metadata and controls
104 lines (85 loc) · 3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package com.github.binarywang.wxpay.service;
import com.github.binarywang.wxpay.bean.transfer.*;
import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.constant.WxPayConstants;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.util.Arrays;
import static org.assertj.core.api.Assertions.assertThat;
/**
* 运营工具-商家转账API测试
*
* @author WxJava Team
*/
public class BusinessOperationTransferServiceTest {
private WxPayService wxPayService;
@BeforeClass
public void setup() {
WxPayConfig config = new WxPayConfig();
config.setAppId("test_app_id");
config.setMchId("test_mch_id");
wxPayService = new WxPayServiceImpl();
wxPayService.setConfig(config);
}
@Test
public void testServiceInitialization() {
BusinessOperationTransferService service = this.wxPayService.getBusinessOperationTransferService();
assertThat(service).isNotNull();
}
@Test
public void testRequestBuilder() {
// 构建转账请求
BusinessOperationTransferRequest.TransferSceneReportInfo reportInfo = new BusinessOperationTransferRequest.TransferSceneReportInfo();
reportInfo.setInfoType("test_info_type");
reportInfo.setInfoContent("test_info_content");
BusinessOperationTransferRequest request = BusinessOperationTransferRequest.newBuilder()
.appid("test_app_id")
.outBillNo("OT" + System.currentTimeMillis())
.transferSceneId(WxPayConstants.OperationSceneId.OPERATION_CASH_MARKETING)
.transferSceneReportInfos(Arrays.asList(reportInfo))
.openid("test_openid")
.transferAmount(100)
.transferRemark("测试转账")
.userRecvPerception(WxPayConstants.UserRecvPerception.CASH_MARKETING.CASH)
.build();
assertThat(request.getAppid()).isEqualTo("test_app_id");
assertThat(request.getTransferSceneId()).isEqualTo(WxPayConstants.OperationSceneId.OPERATION_CASH_MARKETING);
assertThat(request.getTransferAmount()).isEqualTo(100);
assertThat(request.getTransferRemark()).isEqualTo("测试转账");
}
@Test
public void testQueryRequestBuilder() {
BusinessOperationTransferQueryRequest request = BusinessOperationTransferQueryRequest.newBuilder()
.outBillNo("OT123456789")
.appid("test_app_id")
.build();
assertThat(request.getOutBillNo()).isEqualTo("OT123456789");
assertThat(request.getAppid()).isEqualTo("test_app_id");
}
@Test
public void testConstants() {
// 测试运营工具转账场景ID常量
assertThat(WxPayConstants.OperationSceneId.OPERATION_CASH_MARKETING).isEqualTo("2001");
assertThat(WxPayConstants.OperationSceneId.OPERATION_COMMISSION).isEqualTo("2002");
assertThat(WxPayConstants.OperationSceneId.OPERATION_PROMOTION).isEqualTo("2003");
}
@Test
public void testResultClasses() {
// 测试结果类的基本功能
BusinessOperationTransferResult result = new BusinessOperationTransferResult();
result.setOutBillNo("test_out_bill_no");
result.setTransferBillNo("test_transfer_bill_no");
result.setState("SUCCESS");
result.setPackageInfo("test_package_info");
assertThat(result.getOutBillNo()).isEqualTo("test_out_bill_no");
assertThat(result.getTransferBillNo()).isEqualTo("test_transfer_bill_no");
assertThat(result.getState()).isEqualTo("SUCCESS");
assertThat(result.getPackageInfo()).isEqualTo("test_package_info");
BusinessOperationTransferQueryResult queryResult = new BusinessOperationTransferQueryResult();
queryResult.setOperationSceneId("2001");
queryResult.setTransferAmount(100);
assertThat(queryResult.getOperationSceneId()).isEqualTo("2001");
assertThat(queryResult.getTransferAmount()).isEqualTo(100);
}
}