Commit a9aca101 authored by 钱雯君's avatar 钱雯君

add

parent 297dc0eb
......@@ -201,7 +201,12 @@
<artifactId>lombok</artifactId>
<version>1.16.18</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.9</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
......
/**
* Copyright (C), 2015-2018
* FileName: 新集卡_达到限制发卡异常_DuibaTest
* Author: qianwenjun
* Date: 2018/10/16 20:09
* Description:
*/
package http.cases.NewCollectActivityTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.NewCollectActivityService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import utils.ExcelDataProvider;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Map;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/10/16
* @since 1.0.0
*/
public class 新集卡_达到限制发卡异常_DuibaTest extends DuibaTestBase {
@Autowired
NewCollectActivityService newCollectActivityService;
private static DuibaLog logger = DuibaLog.getLogger();
@DataProvider
public Iterator<Object[]> providerByMthod(Method method){
Iterator<Object[]> data = null;
if (method.getName().equals("插件发卡异常")){
data = new ExcelDataProvider("duiba/新集卡_插件发卡异常");
}else if (method.getName().equals("活动工具发卡异常")){
data = new ExcelDataProvider("duiba/新集卡_活动工具发卡异常");
}
return data;
}
@Test(dataProvider = "providerByMthod")
public void 插件发卡异常(Map<String,String> data) throws Exception{
String activityId = data.get("activityId");
String collectRuleId = data.get("collectRuleId");
Integer uid = Integer.valueOf(data.get("uid"));
String consumerId = data.get("consumerId");
String gredeLevel = data.get("gradeLevel");
//清开奖记录数据
Boolean result = jdbc.update("delete from collect_card.tb_collect_card_win_record where consumer_id = ? and rule_id = ? and grade_level = ?",consumerId,collectRuleId,gredeLevel);
Response playReasponse = this.playPlugin(activityId,collectRuleId,uid);
playReasponse.prettyPrint();
Response openPrizeResponse = this.openPrize(collectRuleId,uid);
openPrizeResponse.prettyPrint();
Map<String,Object> winRecord = jdbc.findSimpleResult("select * from collect_card.tb_collect_card_win_record where consumer_id = ? and rule_id = ? and grade_level = ?\n",consumerId,collectRuleId,gredeLevel);
Assert.assertNotNull(winRecord,"开奖记录校验失败");
logger.info("用户consumerId="+winRecord.get("consumer_id")+"的中奖记录为:collectRuleId="+winRecord.get("rule_id")+",gredeLevel="+winRecord.get("grade_level"));
Response playReasponse2 = this.playPlugin(activityId,collectRuleId,uid);
playReasponse2.prettyPrint();
Assert.assertEquals(playReasponse2.jsonPath().getString("lottery.type"),"thanks","校验中奖类型失败");
logger.info("校验成功:达到限制,发卡降级谢谢参与");
}
@Test(dataProvider = "providerByMthod")
public void 活动工具发卡异常(Map<String,String> data) throws Exception{
String activityId = data.get("activityId");
String collectRuleId = data.get("collectRuleId");
Integer uid = Integer.valueOf(data.get("uid"));
String consumerId = data.get("consumerId");
String gredeLevel = data.get("gradeLevel");
//清开奖记录数据
Boolean result = jdbc.update("delete from collect_card.tb_collect_card_win_record where consumer_id = ? and rule_id = ? and grade_level = ?",consumerId,collectRuleId,gredeLevel);
Response playReasponse = this.playHdtool(activityId,collectRuleId,uid);
playReasponse.prettyPrint();
Response openPrizeResponse = this.openPrize(collectRuleId,uid);
openPrizeResponse.prettyPrint();
Map<String,Object> winRecord = jdbc.findSimpleResult("select * from collect_card.tb_collect_card_win_record where consumer_id = ? and rule_id = ? and grade_level = ?\n",consumerId,collectRuleId,gredeLevel);
Assert.assertNotNull(winRecord,"开奖记录校验失败");
Response playReasponse2 = this.playHdtool(activityId,collectRuleId,uid);
playReasponse2.prettyPrint();
Assert.assertEquals(playReasponse2.jsonPath().getString("lottery.type"),"lucky","校验中奖类型失败");
logger.info("校验成功:达到限制,发卡降级福袋");
}
// @Test
public void 单接口调试() throws Exception{
String activityId = "33547";
String collectRuleId = "4437";
Integer uid = 3829;
String consumerId = "100089384";
String gredeLevel = "1";
//清开奖记录数据
Boolean result = jdbc.update("delete from collect_card.tb_collect_card_win_record where consumer_id = ? and rule_id = ? and grade_level = ?",consumerId,collectRuleId,gredeLevel);
Response playReasponse = this.playHdtool(activityId,collectRuleId,uid);
playReasponse.prettyPrint();
Response openPrizeResponse = this.openPrize(collectRuleId,uid);
openPrizeResponse.prettyPrint();
Map<String,Object> winRecord = jdbc.findSimpleResult("select * from collect_card.tb_collect_card_win_record where consumer_id = ? and rule_id = ? and grade_level = ?\n",consumerId,collectRuleId,gredeLevel);
Assert.assertNotNull(winRecord,"开奖记录校验失败");
Response playReasponse2 = this.playHdtool(activityId,collectRuleId,uid);
playReasponse2.prettyPrint();
Assert.assertEquals(playReasponse2.jsonPath().getString("lottery.type"),"lucky","校验中奖类型失败");
logger.info("校验成功:达到限制,发卡降级谢谢参与");
}
public Response playPlugin(String activityId, String collectRuleId, int uid) throws Exception {
Response response = newCollectActivityService.doJoinPlugdraw(activityId,collectRuleId,uid);
String orderId = response.jsonPath().getString("orderId");
response = newCollectActivityService.getOrderStatusPlugdraw(orderId,uid);
String result = String.valueOf(response.jsonPath().getString("result"));
int i= 30;
while(i>0&&(result.equals("0"))){
Thread.sleep(1000);
response = newCollectActivityService.getOrderStatusPlugdraw(orderId,uid);
result = String.valueOf(response.jsonPath().getString("result"));
i--;
}
return response;
}
public Response openPrize(String collectRuleId,Integer uid) throws Exception {
Response openResponse = newCollectActivityService.openCollectGoodsPrize(collectRuleId,uid);
String orderId = openResponse.jsonPath().getString("orderId");
Response statusResponse = newCollectActivityService.getOpenOrderStatus(orderId,uid);
String playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
int i = 8;
while (i > 0 && (playResult.equals("0"))) {
Thread.sleep(1000);
statusResponse = newCollectActivityService.getOpenOrderStatus(orderId,uid);
playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
i--;
}
return statusResponse;
}
public Response playHdtool(String activityId, String collectRuleId, int uid) throws Exception{
Response response = newCollectActivityService.doJoin(activityId,collectRuleId,uid);
response.prettyPrint();
String orderId = response.jsonPath().getString("orderId");
Response statusResponse = newCollectActivityService.getOrderStatus(orderId,uid);
// statusResponse.prettyPrint();
String playResult = statusResponse.jsonPath().getString("result");
int i = 30;
while (i > 0 && (playResult.equals("0"))) {
Thread.sleep(1000);
statusResponse = newCollectActivityService.getOrderStatus(orderId,uid);
playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
i--;
}
return statusResponse;
}
}
/**
* Copyright (C), 2015-2018
* FileName: pk_列表测试_AccessTest
* Author: qianwenjun
* Date: 2018/8/5 11:10
* Description:
*/
package http.cases.PkTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.model.BetMobileVo;
import http.service.Activity.PkService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/8/5
* @since 1.0.0
*/
public class pk_列表测试_AccessTest extends DuibaTestBase {
@Autowired
PkService pkService;
private DuibaLog logger = DuibaLog.getLogger();
private static Integer uided_2239 = 3401;//【勿动】pk测试_已押注_2239
private static Integer uid_2239 = 3415;//【勿动】pk测试_未押注_2239
private static Integer uid_18816 = 3414;//【勿动】pk测试01_18816
private static Integer uid_2730 = 2730;//appId=1
@Test
public void 获取pk活动列表测试() throws Exception{
List<Map<String,Object>> dbBetLists = jdbc.findModeResult("select * from act_com_conf.tb_bet_group_relation where group_id = '6' and config_status = '3'");
String totalPk = String.valueOf(dbBetLists.size());
//活动组6,定向给2239好1两个app,所以这两个app的用户都可以获取到该活动组下所有开启的活动;
Response response_uid_2239 = pkService.getBetList(uid_2239);
List<BetMobileVo> betedList = response_uid_2239.jsonPath().getList("data.betedList",BetMobileVo.class);
List<BetMobileVo> unbetList = response_uid_2239.jsonPath().getList("data.unbetList",BetMobileVo.class);
// logger.info("unbetList的信息为"+ JSON.toJSONString(unbetList));
Assert.assertEquals(String.valueOf(betedList.size()),"0","已投注的活动为0校验失败");
Assert.assertEquals(String.valueOf(unbetList.size()),totalPk,"已投注的活动为6校验失败");
Response response_uid_18816 = pkService.getBetList(uid_18816);
List<BetMobileVo> betedList_uid_18816 = response_uid_18816.jsonPath().getList("data.betedList",BetMobileVo.class);
List<BetMobileVo> unbetList_uid_18816 = response_uid_18816.jsonPath().getList("data.unbetList",BetMobileVo.class);
Assert.assertEquals(String.valueOf(unbetList_uid_18816.size()),"0","已投注的活动为6校验失败");
Assert.assertEquals(String.valueOf(betedList_uid_18816.size()),"0","未投注的活动为0校验失败");
Response response_uid_2730 = pkService.getBetList(uid_2730);
List<BetMobileVo> betedList_uid_2730 = response_uid_2730.jsonPath().getList("data.betedList",BetMobileVo.class);
List<BetMobileVo> unbetList_uid_2730 = response_uid_2730.jsonPath().getList("data.unbetList",BetMobileVo.class);
Assert.assertEquals(String.valueOf(betedList_uid_2730.size()),"0","已投注的活动为0校验失败");
Assert.assertEquals(String.valueOf(unbetList_uid_2730.size()),totalPk,"已投注的活动为0校验失败");
//该用户投注过2个活动,且校验活动安装结束时间倒序排
Response response_uided_2239 = pkService.getBetList(uided_2239);
List<BetMobileVo> betedList_uided_2239 = response_uided_2239.jsonPath().getList("data.betedList",BetMobileVo.class);
List<BetMobileVo> unbetList_uided_2239 = response_uided_2239.jsonPath().getList("data.unbetList",BetMobileVo.class);
// logger.info("unbetList的信息为"+ JSON.toJSONString(unbetList));
Assert.assertEquals(String.valueOf(betedList_uided_2239.size()),"2","已投注的活动为0校验失败");
Assert.assertEquals(String.valueOf(unbetList_uided_2239.size()),"4","已投注的活动为6校验失败");
for (int i=0;i<betedList_uided_2239.size()-1;i++){
Assert.assertTrue(Long.valueOf(betedList_uided_2239.get(i).getBetConfig().getEndTime())<=Long.valueOf(betedList_uided_2239.get(i+1).getBetConfig().getEndTime()),"校验已押注活动列表倒序排列失败");
List<String> chooseThisOptions = new ArrayList<>();
for (int j=0;j<betedList_uided_2239.get(i).getOptions().size();j++){
chooseThisOptions.add(betedList_uided_2239.get(i).getOptions().get(j).getChooseThisOption());
}
Assert.assertTrue(chooseThisOptions.contains("true"),"校验已投注活动的标志失败");
}
for (int i=0;i<unbetList_uided_2239.size()-1;i++){
Assert.assertTrue(Long.valueOf(unbetList_uided_2239.get(i).getBetConfig().getEndTime())<=Long.valueOf(unbetList_uided_2239.get(i+1).getBetConfig().getEndTime()),"校验未押注活动列表倒序排列失败");
List<String> chooseThisOptions = new ArrayList<>();
for (int j=0;j<unbetList_uided_2239.get(i).getOptions().size();j++){
chooseThisOptions.add(unbetList_uided_2239.get(i).getOptions().get(j).getChooseThisOption());
}
Assert.assertFalse(chooseThisOptions.contains("true"),"校验已投注活动的标志失败");
}
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: pk_开奖_瓜分红包测试
* Author: qianwenjun
* Date: 2018/8/9 20:13
* Description:
*/
package http.cases.PkTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.model.BetMobileVo;
import http.service.Activity.PkService;
import http.service.Manager.PkActivityService;
import io.restassured.response.Response;
import org.joda.time.format.DateTimeFormat;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import utils.MatcherString;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.DateTime;
import java.util.ArrayList;
import java.util.List;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/8/9
* @since 1.0.0
*/
public class pk_开奖_瓜分红包测试 extends DuibaTestBase {
@Autowired
PkService pkService;
@Autowired
PkActivityService pkActivityService;
private static DuibaLog logger = DuibaLog.getLogger();
private String groupId = "7";
private Integer user01 = 3445;
private Integer user02 = 3446;
private Integer user03 = 3447;
private Integer user04 = 3448;
private String newBetId = "";
private List<String> optionsIds = new ArrayList<>();
@BeforeMethod
public void setUp() {
try {
createPk("2","2020-08-12 00:00:00",groupId);
}catch (Exception e){
e.printStackTrace();
}
}
@Test
public void 瓜分红包_两个选项_押注人数相同_开奖测试() throws Exception{
Response betList = pkService.getBetList(3445);
List<BetMobileVo> betMobileVoList = betList.jsonPath().getList("data.unbetList",BetMobileVo.class);
for (BetMobileVo bet:betMobileVoList){
if (bet.getBetConfig().getId().equals(newBetId)){
for (int i=0;i<bet.getOptions().size();i++){
optionsIds.add(bet.getOptions().get(i).getOptionId());
}
}
}
//押注第一个选项:user01,user02
//押注第二个选项:user03,user04
Response res1 = pkService.doJoin(user01,newBetId,optionsIds.get(0));
Response res2 = pkService.doJoin(user02,newBetId,optionsIds.get(0));
Response res3 = pkService.doJoin(user03,newBetId,optionsIds.get(1));
Response res4 = pkService.doJoin(user04,newBetId,optionsIds.get(1));
//修改开奖时间
this.modifyOpenPrizeTime();
int i=8;
}
public void createPk(String bounsType,String endTime,String groupId) throws Exception {
Response betResponse = pkActivityService.bet(bounsType,endTime);
String betId = MatcherString.getString(betResponse.asString(),"\"data\": (\\w*)",1);
newBetId = betId;
logger.info("newBetId的信息为"+newBetId);
Response betRelation = pkActivityService.betGroupRelation(betId,endTime,groupId);
Response modifyStatusResponse = pkActivityService.modifySatus(betId);
}
public String modifyOpenPrizeTime() throws Exception{
DateTime time1 = new DateTime();
DateTime endTime = time1.minusMillis(10);
DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
String endTimeStr = format.print(endTime.getMillis()).toString();
logger.info("\ntime1="+ format.print(time1.getMillis())+"\n设置的开奖时间endTime="+ endTimeStr);
Boolean result1 = jdbc.update("update act_com_conf.tb_bet_config set end_time = ? where id = \"229\"\n",endTimeStr);
Boolean result2 = jdbc.update("update act_com_conf.tb_bet_group_relation set end_time = ? where bet_id = \"229\"\n",endTimeStr);
return endTimeStr;
}
public static void main(String[] args) {
DateTime time1 = DateTime.now();
DateTime time2 = time1.plusMinutes(1);
DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
logger.info("\ntime1="+ format.print(time1.getMillis())+"\ntime2="+ format.print(time2.getMillis()));
logger.info("\nendTimeStr="+format.print(time1.getMillis()).toString());
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: pk_押注测试_AccessTest
* Author: qianwenjun
* Date: 2018/8/5 15:40
* Description:
*/
package http.cases.PkTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.PkService;
import http.service.hd.DeveloperConfigService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/8/5
* @since 1.0.0
*/
public class pk_押注测试_AccessTest extends DuibaTestBase {
@Autowired
PkService pkService;
@Autowired
DeveloperConfigService developerConfigService;
private DuibaLog logger = DuibaLog.getLogger();
private static Integer uid01 = 3416;//【勿动】pk01_测试押注
private static String uid01_consumerId = "100066015";
private static Integer uid02 = 3417;//【勿动】pk02_积分不足_测试押注
private static String uid02_consumerId = "100066016";
private List<String> orderIds = new ArrayList<>();
@BeforeMethod
public void clearUp() {
try {
Boolean result = jdbc.update("delete from act_record.tb_bet_record where bet_id = '124' and partner_user_id = '3416'\n");
Boolean result2 = jdbc.update("delete from activity_order_con.tb_trade_center_activity_order_0735 where activity_type = 'bet' and duiba_activity_id = '124'\n");
}catch (Exception e){
e.printStackTrace();
}
}
@Test
public void 押注测试() throws Exception{
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",uid01);
Map<String,Object> consumer = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",uid01_consumerId);
Long userCredit = Long.parseLong(user.get("credits").toString());
Long consumerCredit = Long.parseLong(consumer.get("credits").toString());
Response doJoinResponse = pkService.doJoin(uid01,"124","248");
doJoinResponse.prettyPrint();
Assert.assertEquals(doJoinResponse.jsonPath().getString("code"),"200","校验押注是否成功且不是第一次押注失败");
String orderId = doJoinResponse.jsonPath().getString("data");
orderIds.add(orderId);
Response statusResponse = pkService.getOrderStatus(uid01,orderId);
statusResponse.prettyPrint();
String consumerStatus = statusResponse.jsonPath().getString("data.consumeStatus");
int i=8;
while (i>0&consumerStatus.equals("1")){
Thread.sleep(1000);
statusResponse = pkService.getOrderStatus(uid01,orderId);
consumerStatus = statusResponse.jsonPath().getString("data.consumeStatus");
}
Assert.assertEquals(consumerStatus,"2","校验押注是否成功,扣积分是否成功失败");
Map<String,Object> user1 = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",uid01);
Map<String,Object> consumer1 = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",uid01_consumerId);
String userCredit1 = user1.get("credits").toString();
String consumerCredit1 = consumer1.get("credits").toString();
Assert.assertEquals(userCredit1,String.valueOf(userCredit-200),"user积分扣除校验失败");
Assert.assertEquals(consumerCredit1,String.valueOf(consumerCredit-200),"consumer积分扣除校验失败");
logger.info("校验积分消耗成功,原积分值="+userCredit+",消耗后积分值为"+userCredit1);
//参加过一次之后,不能再参加该pk活动
Response doJoinResponse1 = pkService.doJoin2(uid01,"124","248");
doJoinResponse1.prettyPrint();
Assert.assertEquals(doJoinResponse1.jsonPath().getString("success"),"false","校验参加结果失败");
Assert.assertEquals(doJoinResponse1.jsonPath().getString("code"),"100011","校验参加失败错误码失败");
Assert.assertEquals(doJoinResponse1.jsonPath().getString("desc"),"活动已参加","校验参加失败描述失败");
}
@Test
public void 押注_积分不足测试() throws Exception {
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where id=?\n",uid02);
Map<String,Object> consumer = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where id=?\n",uid02_consumerId);
Long userCredit = Long.parseLong(user.get("credits").toString());
Long consumerCredit = Long.parseLong(consumer.get("credits").toString());
logger.info("开发者积分库积分值="+userCredit+",兑吧积分库积分值为"+consumerCredit);
Response appInfoResponse = developerConfigService.getAppInfo();
appInfoResponse.prettyPrint();
String earnCreditsUrl = appInfoResponse.jsonPath().getString("data.earnCreditsUrl");
Response doJoinResponse = pkService.doJoin2(uid02,"124","248");
doJoinResponse.prettyPrint();
Assert.assertEquals(doJoinResponse.jsonPath().getString("success"),"false","校验参加结果失败");
Assert.assertEquals(doJoinResponse.jsonPath().getString("code"),"100009","校验参加失败错误码失败");
Assert.assertEquals(doJoinResponse.jsonPath().getString("desc"),earnCreditsUrl,"校验参加失败描述失败");
}
@Test
public void 押注_未登陆测试() throws Exception{
Response doJoinResponse = pkService.doJoin3("124","248");
doJoinResponse.prettyPrint();
Assert.assertEquals(doJoinResponse.jsonPath().getString("success"),"false","校验参加结果失败");
Assert.assertEquals(doJoinResponse.jsonPath().getString("code"),"00000001","校验参加失败错误码失败");
Assert.assertEquals(doJoinResponse.jsonPath().getString("desc"),"用户未登录","校验参加失败描述失败");
}
@AfterMethod
public void tearDown() {
try {
Boolean result = jdbc.update("delete from act_record.tb_bet_record where bet_id = '124' and partner_user_id = '3416'\n");
for (String orderId:orderIds){
Boolean result2 = jdbc.update("delete from activity_order_con.tb_trade_center_activity_order_0735 where order_num = ?\n",orderId);
}
}catch (Exception e){
e.printStackTrace();
}
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: pk_管理端测试_AccessTest
* Author: qianwenjun
* Date: 2018/7/31 15:46
* Description:
*/
package http.cases.PkTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSON;
import http.model.BetMngVo;
import http.service.Manager.PkActivityService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/7/31
* @since 1.0.0
*/
public class pk_管理端测试_AccessTest extends DuibaTestBase {
@Autowired
PkActivityService pkActivityService;
private static DuibaLog logger = DuibaLog.getLogger();
private String endTime = "2021-12-31 23:55:00";
private Map<String,Object> betIds = new HashMap<>();
private String groupId = "5";
@Test
public void 创建pk活动_瓜分红包测试() {
try {
Response oldBetList = pkActivityService.getMngBetList();
// oldBetList.prettyPrint();
String oldTotal = oldBetList.jsonPath().getString("data.params.total");
createPk("2");
Response newBetList = pkActivityService.getMngBetList();
String newTotal = newBetList.jsonPath().getString("data.params.total");
logger.info("创建之前的列表中条数为:"+oldTotal+"创建之后的列表中条数为:"+newTotal);
Assert.assertEquals(String.valueOf(Long.valueOf(newTotal)-1L),oldTotal,"新建之后列表获取数据校验失败");
List<BetMngVo> betList = newBetList.jsonPath().getList("data.page",BetMngVo.class);
logger.info("betIds"+JSON.toJSONString(betIds));
for (BetMngVo bet:betList){
if (bet.getId().equals(betIds.get("2"))){
logger.info("bet的信息为="+JSON.toJSONString(bet));
Assert.assertEquals(bet.getBetType(),"1","校验pk活动单选单次类型失败");
Assert.assertEquals(bet.getBonusType(),"2","校验pk活动瓜分类型失败");
Assert.assertEquals(bet.getBonusAmount(),"0.10","校验pk活动瓜分类型失败");
Assert.assertEquals(bet.getTitle(),"【自动化】新建pk活动-瓜分红包","校验pk活动名称失败");
Assert.assertEquals(bet.getConfigStatus(),"3","校验pk活动状态失败");
Assert.assertEquals(bet.getEndTime(),"2021-12-31 23:55","校验pk活动结束时间失败");
}else{
break;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void 创建pk活动_瓜分经验测试() {
try {
Response oldBetList = pkActivityService.getMngBetList();
String oldTotal = oldBetList.jsonPath().getString("data.params.total");
logger.info("创建之前的列表中条数为:"+oldTotal);
createPk("1");
Response newBetList = pkActivityService.getMngBetList();
String newTotal = newBetList.jsonPath().getString("data.params.total");
logger.info("创建之前的列表中条数为:"+oldTotal+"创建之后的列表中条数为:"+newTotal);
Assert.assertEquals(String.valueOf(Long.valueOf(newTotal)-1L),oldTotal,"新建之后列表获取数据校验失败");
List<BetMngVo> betList = newBetList.jsonPath().getList("data.page",BetMngVo.class);
logger.info("betIds"+JSON.toJSONString(betIds));
for (BetMngVo bet:betList){
if (bet.getId().equals(betIds.get("1"))){
logger.info("bet的信息为="+JSON.toJSONString(bet));
Assert.assertEquals(bet.getBetType(),"1","校验pk活动单选单次类型失败");
Assert.assertEquals(bet.getBonusType(),"1","校验pk活动瓜分类型失败");
Assert.assertEquals(bet.getBonusAmount(),"0.00","校验pk活动瓜分类型失败");
Assert.assertEquals(bet.getTitle(),"【自动化】新建pk活动-瓜分经验","校验pk活动名称失败");
Assert.assertEquals(bet.getConfigStatus(),"3","校验pk活动状态失败");
Assert.assertEquals(bet.getEndTime(),"2021-12-31 23:55","校验pk活动结束时间失败");
}else{
break;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void createPk(String bounsType) throws Exception {
Response betResponse = pkActivityService.bet(bounsType,endTime);
String betId = MatcherString.getString(betResponse.asString(),"\"data\": (\\w*)",1);
logger.info("betId的信息为"+betId);
betIds.put(bounsType,betId);
Response betRelation = pkActivityService.betGroupRelation(betId,endTime,groupId);
Response modifyStatusResponse = pkActivityService.modifySatus(betId);
}
@AfterClass
public void tearDown() {
try {
Boolean result = jdbc.update("delete from act_com_conf.tb_bet_group_relation where bet_id in (select id from act_com_conf.tb_bet_config where title = \"【自动化】新建pk活动-瓜分经验\" OR title = \"【自动化】新建pk活动-瓜分红包\")\n");
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_config where title = \"【自动化】新建pk活动-瓜分经验\" OR title = \"【自动化】新建pk活动-瓜分红包\"\n");
} catch (SQLException e) {
e.printStackTrace();
}
}
}
\ 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