Commit 3278a4ad by xuyamei

解决报错电子合同数据对比报错

parent f33e2790
...@@ -11,6 +11,8 @@ import org.testng.annotations.BeforeMethod; ...@@ -11,6 +11,8 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/** /**
* @BelongsProject: xm-sportstest * @BelongsProject: xm-sportstest
...@@ -32,21 +34,36 @@ public class TestGetValidBalanceList extends BaseTestImpl { ...@@ -32,21 +34,36 @@ public class TestGetValidBalanceList extends BaseTestImpl {
} }
@Test @Test
public void testGetValidBalanceList(){ public void testGetValidBalanceList() {
JSONObject body = new JSONObject(); JSONObject body = new JSONObject();
body.put("tenantId",xmAppApi.getLoginInfo().getStudioId()); body.put("tenantId", xmAppApi.getLoginInfo().getStudioId());
body.put("brandId",xmAppApi.getLoginInfo().getBrandId()); body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("studioId",xmAppApi.getLoginInfo().getStudioId()); body.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body.put("operatorId",xmAppApi.getLoginInfo().getAdminId()); body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON,params,body.toString(),headers).assetsSuccess(true); xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
Assert.assertTrue(xmAppApi.getBodyInJSON().getJSONArray("result").size()>0,"获取租户有效余额记录失败"); Assert.assertTrue(xmAppApi.getBodyInJSON().getJSONArray("result").size() > 0, "获取租户有效余额记录失败");
// 和充值记录的数据对比 // 和充值记录的数据对比
String[] keys = {"id","tenantId","productCode","purchaseAmount","startTime","endTime","payChannel"}; String[] keys = {"id", "tenantId", "productCode", "purchaseAmount", "startTime", "endTime", "payChannel"};
for (int i = 0; i < keys.length; i++){
Assert.assertEquals(xmAppApi.getBodyInJSON().getJSONArray("result").getJSONObject(0).getString(keys[i]),eleContractTools.getBalanceList().getJSONObject(0).getString(keys[i]),"获取租户有效余额记录与充值记录列表内容对比"); int total = xmAppApi.getBodyInJSON().getJSONArray("result").size();
List<JSONObject> list1 = new ArrayList<>();
List<JSONObject> list2 = new ArrayList<>();
for (int i = 0; i < total; i++) {
list1.add(eleContractTools.getBalanceList().getJSONObject(i));
list2.add(xmAppApi.getBodyInJSON().getJSONArray("result").getJSONObject(i));
} }
} int flag = 1;
for (int i = 0; i < total; i++) {
for (int j = 0; j < keys.length; j++) {
String expected = list1.get(i).getString(keys[j]);
String actual = list2.get(total - flag).getString(keys[j]);
Assert.assertEquals(actual, expected, "获取租户有效余额记录与充值记录列表内容对比");
}
flag++;
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment