Commit 6e177c8d authored by 周松波's avatar 周松波

add cases

parent 5c6fca8c
......@@ -180,12 +180,12 @@ public class ContractSign_signTest extends DuibaTestBase {
@Test(description = "活动ID=2,uid2第六天断签", priority = 3)
public void 契约签到断签() throws Exception{
String actID = "2";
String actId = "2";
//当天为周期第一天,周期往前再挪6天
modifyIssuePeriod(issueId,-6);
//补签前5天,第六天不签
this.contractResign(actID, uid2, 7,true);
Response homeInfoRes = ContractSignService.getHomeInfo(actID, uid2);
this.contractResign(actId, uid2, 7,true);
Response homeInfoRes = ContractSignService.getHomeInfo(actId, uid2);
//homeInfoRes.prettyPrint();
String status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(status, "5", "当前签到状态不正确");
......@@ -253,7 +253,7 @@ public class ContractSign_signTest extends DuibaTestBase {
Assert.assertEquals(periodShow, period, "参与期次号不正确");
String status = homeInfoRes.jsonPath().getString("data.status");
Assert.assertEquals(status, "6", "当前参与状态不正确");
// 查询中奖信息
// 查询参与记录
Response recordRes = ContractSignService.getContracts(actId, uid3);
String contractId = recordRes.jsonPath().getString("data.list[0].contractId");
String doneStatus = recordRes.jsonPath().getString("data.list[0].doneStatus");
......@@ -266,9 +266,107 @@ public class ContractSign_signTest extends DuibaTestBase {
String rewardAmount = rewardRes.jsonPath().getString("data");
Assert.assertEquals(rewardStatus,"true","领取奖励结果不正确");
Assert.assertEquals(rewardAmount,winCount,"领取奖励金额不正确");
//再次查询参与记录
recordRes = ContractSignService.getContracts(actId, uid3);
doneStatus = recordRes.jsonPath().getString("data.list[0].doneStatus");
Assert.assertEquals(doneStatus, "REWARD", "当前期次完成状态不正确");
winCount = recordRes.jsonPath().getString("data.list[0].winCount");
Assert.assertEquals(winCount, "7000", "显示领取金额不正确");
//uid4领奖
recordRes = ContractSignService.getContracts(actId, uid4);
contractId = recordRes.jsonPath().getString("data.list[0].contractId");
ContractSignService.getReward(contractId,uid4);
}
@Test(description = "打卡/收益排行榜,活动ID=2",priority = 6)
public void 参与记录() throws Exception{
// 查询断签用户参与记录
Response recordRes = ContractSignService.getContracts("2", uid2);
String doneStatus = recordRes.jsonPath().getString("data.list[0].doneStatus");
Assert.assertEquals(doneStatus,"FAIL","参与记录中参与状态不正确");
int totalPay = recordRes.jsonPath().getInt("data.totalPay");
int totalSuccTime = recordRes.jsonPath().getInt("data.totalSuccTime");
int totalJoinTime = recordRes.jsonPath().getInt("data.totalJoinTime");
int totalProfit = recordRes.jsonPath().getInt("data.totalProfit");
String failDate = recordRes.jsonPath().getString("data.list[0].failDate");
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.setTime(now);
calendar.add(Calendar.DAY_OF_YEAR, -2);
String failDateT = sdf.format(calendar.getTime());
Assert.assertEquals(failDate,failDateT,"断签日期不正确");
Assert.assertEquals(totalPay, 1000,"累计投入不正确");
Assert.assertEquals(totalJoinTime, 1,"累计参与次数不正确");
Assert.assertEquals(totalSuccTime, 0,"参与成功次数不正确");
Assert.assertEquals(totalProfit, 0,"累计收益不正确");
//查询成功用户参与记录
recordRes = ContractSignService.getContracts("2", uid3);
totalPay = recordRes.jsonPath().getInt("data.totalPay");
totalSuccTime = recordRes.jsonPath().getInt("data.totalSuccTime");
totalJoinTime = recordRes.jsonPath().getInt("data.totalJoinTime");
totalProfit = recordRes.jsonPath().getInt("data.totalProfit");
Assert.assertEquals(totalPay, 1000,"累计投入不正确");
Assert.assertEquals(totalJoinTime, 1,"累计参与次数不正确");
Assert.assertEquals(totalSuccTime, 1,"参与成功次数不正确");
Assert.assertEquals(totalProfit, 7000,"累计收益不正确");
}
@Test(description = "打卡/收益排行榜,活动ID=2",priority = 7)
public void 排行榜() throws Exception{
String actId = "2";
//查询签到次数排行榜
Response countResponse = ContractSignService.getContractRank(actId, 10, 1, uid3);
String status1 = countResponse.jsonPath().getString("success");
Assert.assertEquals(status1, "true", "打卡次数排行榜查询失败");
String rank1 = countResponse.jsonPath().getString("data.rankList[2]");
String userInfo1 = countResponse.jsonPath().getString("data.user");
Assert.assertEquals(userInfo1,rank1);
int userRank1 = countResponse.jsonPath().getInt("data.user.rank");
int userAmount1 = countResponse.jsonPath().getInt("data.user.amount");
int userId1 = countResponse.jsonPath().getInt("data.user.consumerId");
String nickName1 = countResponse.jsonPath().getString("data.user.nickName");
Assert.assertEquals(userRank1, 3, "打卡排名不正确");
//Assert.assertEquals(userAmount1, 1, "打卡次数不正确");
Assert.assertEquals(userId1, 100085019, "consumerId不正确");
Assert.assertEquals(nickName1,"Auto3720","用户名不正确");
//查询收益排行榜
Response rewardResponse = ContractSignService.getContractRank(actId, 10, 2, uid3);
String status2 = rewardResponse.jsonPath().getString("success");
Assert.assertEquals(status2, "true", "打卡次数排行榜查询失败");
String rank2 = rewardResponse.jsonPath().getString("data.rankList[1]");
String userInfo2 = rewardResponse.jsonPath().getString("data.user");
int userRank2 = rewardResponse.jsonPath().getInt("data.user.rank");
int userAmount2 = rewardResponse.jsonPath().getInt("data.user.amount");
int userId2 = rewardResponse.jsonPath().getInt("data.user.consumerId");
String nickName2 = rewardResponse.jsonPath().getString("data.user.nickName");
Assert.assertEquals(userInfo2,rank2);
Assert.assertEquals(userRank2, 2, "用户收益排名不正确");
//Assert.assertEquals(userAmount2, 6000, "收益金额不正确");
Assert.assertEquals(userId2, 100085019, "consumerId不正确");
Assert.assertEquals(nickName2,"Auto3720","用户名不正确");
}
@Test(description = "中奖轮播",priority = 8)
public void 中奖轮播() throws Exception{
//删除redis key
// Map<String, String> carouselMap = new HashMap<>();
// carouselMap.put("key", );
// Response redisResponse = given().params(map).get(activityHost + "/signtest/redis/delKey");
// String redisResult = redisResponse.jsonPath().getString("success");
// Assert.assertEquals(redisResult, "true", "删除redis键值失败");
// 中奖轮播接口查询
Response CarouselRes = ContractSignService.getRewardTodayLimit200("2",uid1);
String cid1 = CarouselRes.jsonPath().getString("data[1].consumerId");
String partnerUserId1 = CarouselRes.jsonPath().getString("data[1].uid");
String nickname1 = CarouselRes.jsonPath().getString("data[1].nickName");
String winCount1 = CarouselRes.jsonPath().getString("data[1].winCount");
Assert.assertEquals(cid1,"100085020");
Assert.assertEquals(partnerUserId1, String.valueOf(uid4));
Assert.assertEquals(nickname1, "Auto3721");
Assert.assertEquals(winCount1, "7000");
}
public Map<String, String> doJoinResult(String activityId, String betAmount, int uid) throws Exception {
Response doJoinRes = ContractSignService.doJoin(activityId, betAmount, uid);
......
......@@ -109,8 +109,8 @@ public class ContractSignService {
* @return
* @throws Exception
*/
public Response getContractRank(String activityId, String topNum, String showType, int uid) throws Exception{
Map<String, String> map = new HashMap<>();
public Response getContractRank(String activityId, int topNum, int showType, int uid) throws Exception{
Map<String, Object> map = new HashMap<>();
map.put("activityId", activityId);
map.put("topNum", topNum);
map.put("showType", showType);
......
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