Commit b5906480 by xuyamei

解决报错

parent dc9e9171
...@@ -15,6 +15,9 @@ import org.testng.annotations.BeforeMethod; ...@@ -15,6 +15,9 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.text.SimpleDateFormat;
import java.util.Date;
/** /**
* @BelongsProject: xm-sportstest * @BelongsProject: xm-sportstest
* @BelongsPackage: com.xiaomai.cases.polar.finance.salary * @BelongsPackage: com.xiaomai.cases.polar.finance.salary
...@@ -43,9 +46,9 @@ public class TestSettleSubmitOrUpdateOrDelete extends BaseTestImpl { ...@@ -43,9 +46,9 @@ public class TestSettleSubmitOrUpdateOrDelete extends BaseTestImpl {
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId()); jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId()); jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId()); jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
jsonObject.put("startDate", TimeUtils.getTodayTime()); // 结算开始时间 jsonObject.put("startDate", TimeUtils.getBeforeDayDate(1)); // 结算开始时间
jsonObject.put("payDate", TimeUtils.getTodayTime()); // 发薪日期 jsonObject.put("payDate", TimeUtils.getTodayTime()); // 发薪日期
jsonObject.put("endDate", TimeUtils.getTodayEndTime()); //结算结束时间 jsonObject.put("endDate", TimeUtils.getTodayEndTime(-1)); //结算结束时间
JSONArray adminIds = new JSONArray(); JSONArray adminIds = new JSONArray();
adminIds.add(xmAppApi.getLoginInfo().getAdminId()); adminIds.add(xmAppApi.getLoginInfo().getAdminId());
jsonObject.put("adminIds",adminIds); jsonObject.put("adminIds",adminIds);
...@@ -69,11 +72,11 @@ public class TestSettleSubmitOrUpdateOrDelete extends BaseTestImpl { ...@@ -69,11 +72,11 @@ public class TestSettleSubmitOrUpdateOrDelete extends BaseTestImpl {
// check 1:获取结算单列表 // check 1:获取结算单列表
JSONArray search = salaryTools.searchSettle(searchContext); JSONArray search = salaryTools.searchSettle(searchContext);
String[] resultKey = {"startDate","endDate","payDate","payWay","state"}; String[] resultKey = {"startDate","endDate","payDate","payWay","state"};
String[] resultValue = {String.valueOf(TimeUtils.getTodayTime()),String.valueOf(TimeUtils.getTodayEndTime()),String.valueOf(TimeUtils.getTodayTime()),payWay,"FINISHED"}; String[] resultValue = {String.valueOf(TimeUtils.getBeforeDayDate(1)),String.valueOf(TimeUtils.getTodayEndTime(-1)),String.valueOf(TimeUtils.getTodayTime()),payWay,"FINISHED"};
id = search.getJSONObject(0).getString("id"); // 获取结算记录id id = search.getJSONObject(0).getString("id"); // 获取结算记录id
for (int i = 0; i < resultKey.length; i++){ for (int i = 0; i < resultKey.length; i++){
if (resultKey[i].equals("endDate")){ if (resultKey[i].equals("endDate")){
Assert.assertTrue(search.getJSONObject(0).getLong(resultKey[i])<=Long.parseLong(resultValue[i])); Assert.assertEquals(dateFormat(search.getJSONObject(0).getLong(resultKey[i])),dateFormat(Long.parseLong(resultValue[i])));
}else{ }else{
Assert.assertEquals(search.getJSONObject(0).getString(resultKey[i]),resultValue[i],"结算单数据与实际数据不符合"+resultKey[i]+":"+resultValue[i]); Assert.assertEquals(search.getJSONObject(0).getString(resultKey[i]),resultValue[i],"结算单数据与实际数据不符合"+resultKey[i]+":"+resultValue[i]);
...@@ -85,7 +88,7 @@ public class TestSettleSubmitOrUpdateOrDelete extends BaseTestImpl { ...@@ -85,7 +88,7 @@ public class TestSettleSubmitOrUpdateOrDelete extends BaseTestImpl {
JSONObject fetchRecordById = salaryTools.fetchRecordById(id); JSONObject fetchRecordById = salaryTools.fetchRecordById(id);
for (int i = 0; i < resultKey.length; i++){ for (int i = 0; i < resultKey.length; i++){
if (resultKey[i].equals("endDate")){ if (resultKey[i].equals("endDate")){
Assert.assertTrue(fetchRecordById.getLong(resultKey[i])<=Long.parseLong(resultValue[i])); Assert.assertEquals(dateFormat(fetchRecordById.getLong(resultKey[i])),dateFormat(Long.parseLong(resultValue[i])));
}else{ }else{
Assert.assertEquals(fetchRecordById.getString(resultKey[i]),resultValue[i],"结算单详情数据与实际数据不符合"+resultKey[i]+":"+resultValue[i]); Assert.assertEquals(fetchRecordById.getString(resultKey[i]),resultValue[i],"结算单详情数据与实际数据不符合"+resultKey[i]+":"+resultValue[i]);
...@@ -113,8 +116,8 @@ public class TestSettleSubmitOrUpdateOrDelete extends BaseTestImpl { ...@@ -113,8 +116,8 @@ public class TestSettleSubmitOrUpdateOrDelete extends BaseTestImpl {
JSONObject fetchSettleResultDetailById = salaryTools.fetchSettleResultDetailById(settleDetailId); JSONObject fetchSettleResultDetailById = salaryTools.fetchSettleResultDetailById(settleDetailId);
Assert.assertTrue(fetchSettleResultDetailById.getDouble("totalAmount")>0,"员工结算明细详情中结算金额小于0"); Assert.assertTrue(fetchSettleResultDetailById.getDouble("totalAmount")>0,"员工结算明细详情中结算金额小于0");
Assert.assertTrue(fetchSettleResultDetailById.getString("adminId").equals(xmAppApi.getLoginInfo().getAdminId()),"员工结算明细详情中员工id不符"); Assert.assertTrue(fetchSettleResultDetailById.getString("adminId").equals(xmAppApi.getLoginInfo().getAdminId()),"员工结算明细详情中员工id不符");
Assert.assertTrue(fetchSettleResultDetailById.getString("startDate").equals(String.valueOf(TimeUtils.getTodayTime())),"员工结算明细详情中结算开始时间错误"); Assert.assertTrue(fetchSettleResultDetailById.getString("startDate").equals(String.valueOf(TimeUtils.getBeforeDayDate(1))),"员工结算明细详情中结算开始时间错误");
Assert.assertTrue(fetchSettleResultDetailById.getLong("endDate")<=TimeUtils.getTodayEndTime(),"员工结算明细详情中结算结束时间错误"); Assert.assertEquals(dateFormat(fetchSettleResultDetailById.getLong("endDate")),dateFormat(TimeUtils.getTodayEndTime(-1)),"员工结算明细详情中结算结束时间错误");
} }
...@@ -198,6 +201,13 @@ public class TestSettleSubmitOrUpdateOrDelete extends BaseTestImpl { ...@@ -198,6 +201,13 @@ public class TestSettleSubmitOrUpdateOrDelete extends BaseTestImpl {
private String dateFormat(long timestamp){
Date date = new Date(timestamp);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String formattedDate = sdf.format(date);
return formattedDate;
}
} }
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