🎨 #4001 【微信支付】为普通商户版退款请求对象类补齐与服务商版一致的“退款资金来源/出资账户明细”参数,以支持在 V3 退款申请时指定退款来源资金账户
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package com.github.binarywang.wxpay.bean.request;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* {@link WxPayRefundV3Request} 单元测试
|
||||
*
|
||||
*/
|
||||
public class WxPayRefundV3RequestTest {
|
||||
|
||||
@Test
|
||||
public void testFundsAccountSerialization() {
|
||||
WxPayRefundV3Request request = new WxPayRefundV3Request();
|
||||
request.setOutRefundNo("1217752501201407033233368018");
|
||||
request.setFundsAccount("AVAILABLE");
|
||||
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(request);
|
||||
JsonObject jsonObject = gson.fromJson(json, JsonObject.class);
|
||||
|
||||
assertThat(jsonObject.has("funds_account")).isTrue();
|
||||
assertThat(jsonObject.get("funds_account").getAsString()).isEqualTo("AVAILABLE");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAmountFromSerialization() {
|
||||
WxPayRefundV3Request.From from = new WxPayRefundV3Request.From();
|
||||
from.setAccount("AVAILABLE");
|
||||
from.setAmount(444);
|
||||
|
||||
WxPayRefundV3Request.Amount amount = new WxPayRefundV3Request.Amount();
|
||||
amount.setRefund(888);
|
||||
amount.setTotal(888);
|
||||
amount.setCurrency("CNY");
|
||||
amount.setFrom(Collections.singletonList(from));
|
||||
|
||||
WxPayRefundV3Request request = new WxPayRefundV3Request();
|
||||
request.setAmount(amount);
|
||||
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(request);
|
||||
JsonObject jsonObject = gson.fromJson(json, JsonObject.class);
|
||||
JsonArray fromJson = jsonObject.getAsJsonObject("amount").getAsJsonArray("from");
|
||||
|
||||
assertThat(fromJson).hasSize(1);
|
||||
assertThat(fromJson.get(0).getAsJsonObject().get("account").getAsString()).isEqualTo("AVAILABLE");
|
||||
assertThat(fromJson.get(0).getAsJsonObject().get("amount").getAsInt()).isEqualTo(444);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user