Commit 4f87e98b authored by 赵然's avatar 赵然

zr

parent 2957c24e
...@@ -104,7 +104,7 @@ public class 种红包_AccessTest extends DuibaTestBase{ ...@@ -104,7 +104,7 @@ public class 种红包_AccessTest extends DuibaTestBase{
} }
@Test @Test(description = "第二款土地种植一次解锁")
public void 解锁土地() throws Exception { public void 解锁土地() throws Exception {
Response response = seedRedPacketService.updateUserLand("19380","1","2","100066444","2"); Response response = seedRedPacketService.updateUserLand("19380","1","2","100066444","2");
Map cookies = authorization.dafuwengLogin(3454); Map cookies = authorization.dafuwengLogin(3454);
......
package http.cases.WalletTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.SeedRedPacketService;
import http.service.Activity.WalletAccountService;
import http.service.Authorization;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import utils.RedisUtil;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* Created by mabo on 2018/8/15
*/
public class 种红包登录解锁_AccessTest extends DuibaTestBase{
@Autowired
SeedRedPacketService seedRedPacketService;
@Autowired
WalletAccountService walletAccountService;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 4565;
private static String consumerId = "100101043";
@BeforeClass
public void beforeclass() {
try {
//还原用户的连续登陆天数为2
RedisUtil.setKey( "AAW_K146_19380_"+consumerId+"_"+getTime(),"2");
seedRedPacketService.updateUserLand("19380","1","3",consumerId,"1");
seedRedPacketService.updateUserLand("19380","1","5",consumerId,"1");
seedRedPacketService.updateUserLand("19380","1","7",consumerId,"1");
} catch (Exception e) {
logger.info("数据前后置操作异常");
}
}
@Test(description = "第三块土地连续登录3天解锁")
public void a_第三块土地解锁() throws Exception {
//dafuweng登陆获取cookies
Map cookies = authorization.dafuwengLogin(uid);
//调用getLandList接口
Response response = seedRedPacketService.getLandList(cookies,"1","424");
String landStatus = response.jsonPath().getString("data.landList[2].landStatus");
logger.info("第三块土地状态为:未解锁-"+landStatus);
Assert.assertEquals(landStatus,"1","第三块土地状态校验失败");
//修改redis用户连续登陆天数为3天
RedisUtil.setKey( "AAW_K146_19380_"+consumerId+"_"+getTime(),"3");
//调用getLandList接口
response = seedRedPacketService.getLandList(cookies,"1","424");
landStatus = response.jsonPath().getString("data.landList[2].landStatus");
logger.info("第三块土地状态为:可解锁-"+landStatus);
Assert.assertEquals(landStatus,"2","第三块土地状态校验失败");
//调用解锁土地接口
response = seedRedPacketService.unlockLand(cookies,"1","424","3");
//调用getLandList接口
response = seedRedPacketService.getLandList(cookies,"1","424");
landStatus = response.jsonPath().getString("data.landList[2].landStatus");
logger.info("第三块土地状态为:空地-"+landStatus);
Assert.assertEquals(landStatus,"3","第三块土地状态校验失败");
}
@Test(description = "第五块土地连续登录7天解锁")
public void b_第五块土地解锁() throws Exception {
//dafuweng登陆获取cookies
Map cookies = authorization.dafuwengLogin(uid);
//调用getLandList接口
Response response = seedRedPacketService.getLandList(cookies,"1","424");
String landStatus = response.jsonPath().getString("data.landList[4].landStatus");
logger.info("第五块土地状态为:未解锁-"+landStatus);
Assert.assertEquals(landStatus,"1","第五块土地状态校验失败");
//修改redis用户连续登陆天数为3天
RedisUtil.setKey( "AAW_K146_19380_"+consumerId+"_"+getTime(),"7");
//调用getLandList接口
response = seedRedPacketService.getLandList(cookies,"1","424");
landStatus = response.jsonPath().getString("data.landList[4].landStatus");
logger.info("第五块土地状态为:可解锁-"+landStatus);
Assert.assertEquals(landStatus,"2","第五块土地状态校验失败");
//调用解锁土地接口
response = seedRedPacketService.unlockLand(cookies,"1","424","5");
//调用getLandList接口
response = seedRedPacketService.getLandList(cookies,"1","424");
landStatus = response.jsonPath().getString("data.landList[4].landStatus");
logger.info("第五块土地状态为:空地-"+landStatus);
Assert.assertEquals(landStatus,"3","第五块土地状态校验失败");
}
@Test(description = "第七块土地连续登录15天解锁")
public void c_第七块土地解锁() throws Exception {
//dafuweng登陆获取cookies
Map cookies = authorization.dafuwengLogin(uid);
//调用getLandList接口
Response response = seedRedPacketService.getLandList(cookies,"1","424");
String landStatus = response.jsonPath().getString("data.landList[6].landStatus");
logger.info("第七块土地状态为:未解锁-"+landStatus);
Assert.assertEquals(landStatus,"1","第七块土地状态校验失败");
//修改redis用户连续登陆天数为3天
RedisUtil.setKey( "AAW_K146_19380_"+consumerId+"_"+getTime(),"15");
//调用getLandList接口
response = seedRedPacketService.getLandList(cookies,"1","424");
landStatus = response.jsonPath().getString("data.landList[6].landStatus");
logger.info("第七块土地状态为:可解锁-"+landStatus);
Assert.assertEquals(landStatus,"2","第七块土地状态校验失败");
//调用解锁土地接口
response = seedRedPacketService.unlockLand(cookies,"1","424","7");
//调用getLandList接口
response = seedRedPacketService.getLandList(cookies,"1","424");
landStatus = response.jsonPath().getString("data.landList[6].landStatus");
logger.info("第七块土地状态为:空地-"+landStatus);
Assert.assertEquals(landStatus,"3","第七块土地状态校验失败");
}
//获取当天日期
public String getTime(){
SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd", Locale.ENGLISH);
Date date = new Date();
String time = dateFormat.format(date);
return time;
}
public void 解锁土地(String landId) throws Exception {
Response response = seedRedPacketService.updateUserLand("19380","1",landId,consumerId,"1");
Map cookies = authorization.dafuwengLogin(uid);
response = seedRedPacketService.unlockLand(cookies,"1","424","2");
response = seedRedPacketService.getLandList(cookies,"1","424");
List<Map> list = response.jsonPath().getList("data.landList",Map.class);
int landStatus = (int)list.get(1).get("landStatus");
Assert.assertEquals(landStatus,3,"解锁失败");
logger.info("解锁土地成功");
}
}
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