Commit 45efea03 authored by 赵然's avatar 赵然

Merge branch 'develop'

parents c570bb3f 2485f9e3
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
package http.cases.WalletTest;
import base.DuibaTestBase;
import org.testng.annotations.BeforeClass;
import utils.RedisUtil;
import http.service.Activity.SeedRedPacketService;
import http.service.Activity.WalletAccountService;
......@@ -28,6 +29,15 @@ public class 种红包_AccessTest extends DuibaTestBase{
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
@BeforeClass
public void beforeclass() {
try {
//前置操作,确保土地是空地状态
seedRedPacketService.updateUserLand("19380","1","1","100066444","3");
} catch (Exception e) {
logger.info("数据前后置操作异常");
}
}
@Test
public void 种红包() throws Exception {
......
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