Commit b1938a4f authored by 赵然's avatar 赵然

zr

parent efb8a4b4
package http.cases.SingleLotteryTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.SingleLotteryService;
import http.service.Authorization;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import utils.MatcherString;
import utils.RedisUtil;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.*;
import static io.restassured.RestAssured.given;
/**
* Created by zhaoran on 2018/6/8.
*/
public class 自有单抽限制_AccessTest extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
Authorization authorization;
@Value("${activity.host}")
String activityHost;
@Value("${manager.host}")
private static DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 4881;
private static int uid2 = 4882;
private static int uid3 = 2709;
private static int uid4 = 2709;
@BeforeClass
public void before() {
try {
RedisUtil.clearKey("AC_K001_36686_"+getTime(0));
jdbc.update("delete from ckvtable.tb_kvtable_0804 where vkey = 'activity-centerjoinNum_100109092_36708'");
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void 每日用户抽奖限制() throws Exception{
Map<String, String> map = new HashMap<>();
map.put("operationAcitvityId", "36686");
map.put("oaId", "36686");
map.put("token", "12321");
Response response = given().cookies(authorization.dafuwengLogin(uid2)).params(map).post(activityHost + "/singleLottery/doJoin");
response.print();
Assert.assertEquals(response.jsonPath().getString("success"), "true", "校验success失败");
Thread.sleep(1000);
response = given().cookies(authorization.dafuwengLogin(uid2)).params(map).post(activityHost + "/singleLottery/doJoin");
response.print();
Assert.assertEquals(response.jsonPath().getString("success"), "false", "校验success失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"), "8", "校验状态失败");
Assert.assertEquals(response.jsonPath().getString("message"), "今日已抽完", "校验信息失败");
logger.info("校验success、lotteryButtonStatus、message正确");
}
@Test
public void 永久用户抽奖限制() throws Exception{
Map<String, String> map = new HashMap<>();
map.put("operationAcitvityId", "36708");
map.put("oaId", "36708");
map.put("token", "12321");
Response response = given().cookies(authorization.dafuwengLogin(uid2)).params(map).post(activityHost + "/singleLottery/doJoin");
response.print();
Assert.assertEquals(response.jsonPath().getString("success"), "true", "校验success失败");
Thread.sleep(1000);
response = given().cookies(authorization.dafuwengLogin(uid2)).params(map).post(activityHost + "/singleLottery/doJoin");
response.print();
Assert.assertEquals(response.jsonPath().getString("success"), "false", "校验success失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"), "2", "校验状态失败");
Assert.assertEquals(response.jsonPath().getString("message"), "已抽完", "校验信息失败");
logger.info("校验success、lotteryButtonStatus、message正确");
}
@Test
public void 抽奖日期限制(){
Map<String, String> map = new HashMap<>();
map.put("operationAcitvityId", "36689");
map.put("oaId", "36689");
map.put("token", "12321");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(activityHost + "/singleLottery/doJoin");
//response.prettyPeek();
Assert.assertEquals(response.jsonPath().getString("success"), "false", "校验success失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"), "4", "校验状态失败");
Assert.assertEquals(response.jsonPath().getString("message"), "已结束", "校验信息失败");
logger.info("校验success、lotteryButtonStatus、message正确");
}
public String getTime(int amount){
SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd", Locale.ENGLISH);
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH, amount);
date = calendar.getTime();
// System.out.println(dateFormat.format(date));
String time = dateFormat.format(date);
// System.out.println(time);
return time;
}
}
\ No newline at end of file
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