mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-04-05 17:38:05 +08:00
🎨 修复错误的获取分账接收方列表的方法代码,并增加单元测试代码
This commit is contained in:
parent
320af9baff
commit
76fd3a20b5
@ -1,16 +1,19 @@
|
||||
package com.github.binarywang.wxpay.bean.profitsharing;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.result.BaseWxPayResult;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.w3c.dom.Document;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -65,17 +68,19 @@ public class ProfitSharingResult extends BaseWxPayResult implements Serializable
|
||||
/**
|
||||
* 获取分账接收方列表方法
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<Receiver> getReceiverList() {
|
||||
if (receiverList == null && receivers != null && receivers.length() > 0) {
|
||||
List<String> tempList = GSON.fromJson(receivers, List.class);
|
||||
for (String str : tempList) {
|
||||
Receiver receiver = GSON.fromJson(str, Receiver.class);
|
||||
receiverList.add(receiver);
|
||||
}
|
||||
if (receiverList != null) {
|
||||
return receiverList;
|
||||
}
|
||||
return receiverList;
|
||||
|
||||
if (StringUtils.isNotEmpty(receivers)) {
|
||||
this.receiverList = GSON.fromJson(receivers, new TypeToken<List<Receiver>>() {
|
||||
}.getType());
|
||||
return receiverList;
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,71 @@
|
||||
package com.github.binarywang.wxpay.bean.profitsharing;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ProfitSharingResultTest {
|
||||
|
||||
@Test
|
||||
public void testGetReceiverList() {
|
||||
ProfitSharingResult profitSharingResult = ProfitSharingResult.fromXML("<xml>\n" +
|
||||
"\t<return_code>\n" +
|
||||
"\t\t<![CDATA[SUCCESS]]>\n" +
|
||||
"\t</return_code>\n" +
|
||||
"\t<result_code>\n" +
|
||||
"\t\t<![CDATA[SUCCESS]]>\n" +
|
||||
"\t</result_code>\n" +
|
||||
"\t<mch_id>\n" +
|
||||
"\t\t<![CDATA[aseedwq]]>\n" +
|
||||
"\t</mch_id>\n" +
|
||||
"\t<appid>\n" +
|
||||
"\t\t<![CDATA[qweqweq]]>\n" +
|
||||
"\t</appid>\n" +
|
||||
"\t<nonce_str>\n" +
|
||||
"\t\t<![CDATA[e2qedawws]]>\n" +
|
||||
"\t</nonce_str>\n" +
|
||||
"\t<sign>\n" +
|
||||
"\t\t<![CDATA[eqwdsqwsq\t]]>\n" +
|
||||
"\t</sign>\n" +
|
||||
"\t<transaction_id>\n" +
|
||||
"\t\t<![CDATA[eqwqwsq]]>\n" +
|
||||
"\t</transaction_id>\n" +
|
||||
"\t<out_order_no>\n" +
|
||||
"\t\t<![CDATA[wqdqwdw]]>\n" +
|
||||
"\t</out_order_no>\n" +
|
||||
"\t<order_id>\n" +
|
||||
"\t\t<![CDATA[dqdwedewee]]>\n" +
|
||||
"\t</order_id>\n" +
|
||||
"\t<receivers>\n" +
|
||||
"\t\t<![CDATA[[\n" +
|
||||
" {\n" +
|
||||
" \"account\": \"123423121\",\n" +
|
||||
" \"amount\": 7,\n" +
|
||||
" \"description\": \"解冻给分账方\",\n" +
|
||||
" \"detail_id\": \"360002qwq3006254484\",\n" +
|
||||
" \"finish_time\": \"\t360002qwq3006254484wq\",\n" +
|
||||
" \"result\": \"PENDING\",\n" +
|
||||
" \"type\": \"MERCHANT_ID\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"account\": \"wqwqeeqe\",\n" +
|
||||
" \"amount\": 3,\n" +
|
||||
" \"description\": \"qwwqw\",\n" +
|
||||
" \"detail_id\": \"3600020wqwqw06254482\",\n" +
|
||||
" \"finish_time\": \"q2wqewqwq\",\n" +
|
||||
" \"result\": \"PENDING\",\n" +
|
||||
" \"type\": \"MERCHANT_ID\"\n" +
|
||||
" }\n" +
|
||||
"]]]>\n" +
|
||||
"\t</receivers>\n" +
|
||||
"\t<status>\n" +
|
||||
"\t\t<![CDATA[PROCESSING]]>\n" +
|
||||
"\t</status>\n" +
|
||||
"</xml>", ProfitSharingResult.class);
|
||||
|
||||
List<ProfitSharingResult.Receiver> receiverList = profitSharingResult.getReceiverList();
|
||||
assertThat(receiverList).isNotEmpty();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user