Commit ffdd652a authored by 赵然's avatar 赵然

Merge branch 'zr' into develop

parents c0956140 28b38b13
/**
* Copyright (C), 2015-2018
* FileName: 瓜分积分测试_AccessTest
* Author: zhaoran
* Date: 2018/12/10 19:45
* Description:
*/
package http.cases.PkMoudleTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONObject;
import http.service.Activity.PkService;
import http.service.Manager.PkActivityService;
import http.service.hd.PkDevelopService;
import io.restassured.response.Response;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.Map;
public class 瓜分积分_作弊瓜分 extends DuibaTestBase {
@Autowired
PkDevelopService pkDevelopService;
@Autowired
PkService pkService;
@Autowired
PkActivityService pkActivityService;
private DuibaLog logger = DuibaLog.getLogger();
private static Integer uid1 = 5029;
private static Integer uid2 = 5058;
private static Integer uid3 = 5059;
private static String betId;
private static String optionId1;
private static String optionId2;
@Test
public void 创建PK活动() throws Exception{
Response response = pkDevelopService.betEditor("21771","4",null,"30");
Assert.assertEquals(response.jsonPath().getString("desc"),"成功","创建组件化pk活动失败");
response = pkService.getBetList(uid1);
response.print();
int i= 30;
while(i>0&&(response.jsonPath().getString("data.unbetList").equals("[]"))){
Thread.sleep(5000);
response = pkService.getBetList(uid1);
response.print();
i--;
}
betId = response.jsonPath().getString("data.unbetList[0].betConfig.id");
optionId1 = response.jsonPath().getString("data.unbetList[0].options[0].optionId");
optionId2 = response.jsonPath().getString("data.unbetList[0].options[1].optionId");
if(betId.equals(null)){
throw new Exception("楼层查询pk组件活动失败!");
}else {
logger.info("pk活动id 为:" + betId + ",投注id1为:" + optionId1 + ",投注id2为:" + optionId2);
}
}
@Test(dependsOnMethods = { "创建PK活动" })
public void 投注() throws Exception {
//查询数据库,投注前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
Map<String,Object> mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
Map<String,Object> mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits1 = String.valueOf(mapuser1.get("credits"));
String credits2 = String.valueOf(mapuser2.get("credits"));
String credits3 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1投注前积分:"+credits1);
logger.info("用户2投注前积分:"+credits2);
logger.info("用户3投注前积分:"+credits3);
//扣去1积分
credits1 = String.valueOf(Integer.valueOf(credits1)-1);
credits2 = String.valueOf(Integer.valueOf(credits2)-1);
credits3 = String.valueOf(Integer.valueOf(credits3)-1);
Response res1 = pkService.doJoin(uid1,betId,optionId1);
Response res2 = pkService.doJoin(uid2,betId,optionId1);
Response res3 = pkService.doJoin(uid3,betId,optionId2);
//查询数据库,投注前积分(抽奖扣积分流程校验)
mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits4 = String.valueOf(mapuser1.get("credits"));
String credits5 = String.valueOf(mapuser2.get("credits"));
String credits6 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1投注后积分:"+credits4);
logger.info("用户2投注后积分:"+credits5);
logger.info("用户3投注后积分:"+credits6);
Assert.assertEquals(credits4,credits1);
Assert.assertEquals(credits5,credits2);
Assert.assertEquals(credits6,credits3);
}
@Test(dependsOnMethods = { "投注" })
public void 开奖() throws Exception {
//查询数据库,开奖前积分
Map<String,Object> mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
Map<String,Object> mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
Map<String,Object> mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits1 = String.valueOf(mapuser1.get("credits"));
String credits2 = String.valueOf(mapuser2.get("credits"));
String credits3 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1开奖前积分:"+credits1);
logger.info("用户2开奖前积分:"+credits2);
logger.info("用户3开奖前积分:"+credits3);
//增加积分: 30/(2+2)
credits1 = String.valueOf(Integer.valueOf(credits1)+7);
credits2 = String.valueOf(Integer.valueOf(credits2)+7);
//修改开奖时间
this.modifyOpenPrizeTime(betId,60);
//调用开奖接口
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
//查询数据库,开奖后积分
mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits4 = String.valueOf(mapuser1.get("credits"));
String credits5 = String.valueOf(mapuser2.get("credits"));
String credits6 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1开奖后积分:"+credits4);
logger.info("用户2开奖后积分:"+credits5);
logger.info("用户3开奖后积分:"+credits6);
Assert.assertEquals(credits4,credits1);
Assert.assertEquals(credits5,credits2);
Assert.assertEquals(credits6,credits3);
logger.info("投注者瓜分金额校验正确");
//校验点
//1、pk活动表配置的状态更新为4;2、订单表的addCredits字段为瓜分的红包值;3、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数
Map<String,Object> betConfig = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_config where id = ?",betId);
logger.info("betConfig的信息为:"+ JSONObject.toJSONString(betConfig));
Assert.assertEquals(betConfig.get("config_status").toString(),"4","配置表状态更新失败");
Map<String,Object> betGroupRelation = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_group_relation where bet_id = ?\n",betId);
Assert.assertEquals(betGroupRelation.get("config_status").toString(),"4","pk关系表开奖状态更新失败");
logger.info("pk活动配置表状态更新为:"+betConfig.get("config_status").toString()+",pk关系表活动状态更新为:"+betGroupRelation.get("config_status").toString());
Map<String,Object> user01_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0661 where consumer_id = '100112021' and duiba_activity_id = ?\n",betId);
Assert.assertEquals(user01_order.get("add_credits").toString(),"7","开奖后发奖值校验失败");
Map<String,Object> user02_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0691 where consumer_id = '100112051' and duiba_activity_id = ?\n",betId);
Assert.assertEquals(user02_order.get("add_credits").toString(),"","开奖后发奖值校验失败");
logger.info("用户01获取的积分值为:"+user01_order.get("add_credits").toString()+",用户03获取的积分值为:"+user02_order.get("add_credits").toString());
Map<String,Object> bet1Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ?\n",betId,optionId1);
Assert.assertEquals(bet1Result.get("rank").toString(),"1","开始押注的选项获胜校验失败");
Map<String,Object> bet2Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ?\n",betId,optionId2);
Assert.assertEquals(bet2Result.get("rank").toString(),"2","开始押注的选项获胜校验失败");
Long bet1Times = Long.valueOf(bet1Result.get("bet_times").toString());
Long bet2Times = Long.valueOf(bet2Result.get("bet_times").toString());
Assert.assertTrue(bet1Times>bet2Times,"活动获胜人数比失败人数多校验失败");
logger.info("选项1的押注人数为:"+bet1Result.get("bet_times").toString()+",选项2的押注人数为:"+bet2Result.get("bet_times").toString());
}
public void modifyOpenPrizeTime(String betId,int x) throws Exception{
DateTime time1 = new DateTime();
// int x=20+(int)(Math.random()*100);
DateTime endTime = time1.minusMillis(x);
DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
// String endTimeStr = format.print(endTime.getMillis()).toString();
String endTimeStr = "2018-11-26 20:24:39";
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 = ?\n",endTimeStr,betId);
Boolean result2 = jdbc.update("update act_com_conf.tb_bet_group_relation set end_time = ? where bet_id = ?\n",endTimeStr,betId);
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: 瓜分积分测试_AccessTest
* Author: zhaoran
* Date: 2018/12/10 19:45
* Description:
*/
package http.cases.PkMoudleTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONObject;
import http.model.BetMngVo;
import http.service.Activity.PkService;
import http.service.Manager.PkActivityService;
import http.service.hd.PkDevelopService;
import io.restassured.response.Response;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.List;
import java.util.Map;
public class 瓜分积分_实际瓜分 extends DuibaTestBase {
@Autowired
PkDevelopService pkDevelopService;
@Autowired
PkService pkService;
@Autowired
PkActivityService pkActivityService;
private DuibaLog logger = DuibaLog.getLogger();
private static Integer uid1 = 5029;
private static Integer uid2 = 5058;
private static Integer uid3 = 5059;
private static String betId;
private static String optionId1;
private static String optionId2;
@Test
public void 创建PK活动() throws Exception{
Response response = pkDevelopService.betEditor("21771","4",null,"30");
Assert.assertEquals(response.jsonPath().getString("desc"),"成功","创建组件化pk活动失败");
response = pkService.getBetList(uid1);
response.print();
int i= 30;
while(i>0&&(response.jsonPath().getString("data.unbetList").equals("[]"))){
Thread.sleep(5000);
response = pkService.getBetList(uid1);
response.print();
i--;
}
betId = response.jsonPath().getString("data.unbetList[0].betConfig.id");
optionId1 = response.jsonPath().getString("data.unbetList[0].options[0].optionId");
optionId2 = response.jsonPath().getString("data.unbetList[0].options[1].optionId");
if(betId.equals(null)){
throw new Exception("楼层查询pk组件活动失败!");
}else {
logger.info("pk活动id 为:" + betId + ",投注id1为:" + optionId1 + ",投注id2为:" + optionId2);
}
}
@Test(dependsOnMethods = { "创建PK活动" })
public void 投注() throws Exception {
//查询数据库,投注前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
Map<String,Object> mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
Map<String,Object> mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits1 = String.valueOf(mapuser1.get("credits"));
String credits2 = String.valueOf(mapuser2.get("credits"));
String credits3 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1投注前积分:"+credits1);
logger.info("用户2投注前积分:"+credits2);
logger.info("用户3投注前积分:"+credits3);
//扣去1积分
credits1 = String.valueOf(Integer.valueOf(credits1)-1);
credits2 = String.valueOf(Integer.valueOf(credits2)-1);
credits3 = String.valueOf(Integer.valueOf(credits3)-1);
Response res1 = pkService.doJoin(uid1,betId,optionId1);
Response res2 = pkService.doJoin(uid2,betId,optionId1);
Response res3 = pkService.doJoin(uid3,betId,optionId2);
//查询数据库,投注前积分(抽奖扣积分流程校验)
mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits4 = String.valueOf(mapuser1.get("credits"));
String credits5 = String.valueOf(mapuser2.get("credits"));
String credits6 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1投注后积分:"+credits4);
logger.info("用户2投注后积分:"+credits5);
logger.info("用户3投注后积分:"+credits6);
Assert.assertEquals(credits4,credits1);
Assert.assertEquals(credits5,credits2);
Assert.assertEquals(credits6,credits3);
}
@Test(dependsOnMethods = { "投注" })
public void 开奖() throws Exception {
//查询数据库,开奖前积分
Map<String,Object> mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
Map<String,Object> mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
Map<String,Object> mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits1 = String.valueOf(mapuser1.get("credits"));
String credits2 = String.valueOf(mapuser2.get("credits"));
String credits3 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1开奖前积分:"+credits1);
logger.info("用户2开奖前积分:"+credits2);
logger.info("用户3开奖前积分:"+credits3);
//增加积分: 30/(2+2)
credits1 = String.valueOf(Integer.valueOf(credits1)+7);
credits2 = String.valueOf(Integer.valueOf(credits2)+7);
//修改开奖时间
this.modifyOpenPrizeTime(betId,60);
//调用开奖接口
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
//查询数据库,开奖后积分
mapuser1 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid1);
mapuser2 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid2);
mapuser3 = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid3);
String credits4 = String.valueOf(mapuser1.get("credits"));
String credits5 = String.valueOf(mapuser2.get("credits"));
String credits6 = String.valueOf(mapuser3.get("credits"));
logger.info("用户1开奖后积分:"+credits4);
logger.info("用户2开奖后积分:"+credits5);
logger.info("用户3开奖后积分:"+credits6);
Assert.assertEquals(credits4,credits1);
Assert.assertEquals(credits5,credits2);
Assert.assertEquals(credits6,credits3);
logger.info("投注者瓜分金额校验正确");
//校验点
//1、pk活动表配置的状态更新为4;2、订单表的addCredits字段为瓜分的红包值;3、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数
Map<String,Object> betConfig = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_config where id = ?",betId);
logger.info("betConfig的信息为:"+ JSONObject.toJSONString(betConfig));
Assert.assertEquals(betConfig.get("config_status").toString(),"4","配置表状态更新失败");
Map<String,Object> betGroupRelation = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_group_relation where bet_id = ?\n",betId);
Assert.assertEquals(betGroupRelation.get("config_status").toString(),"4","pk关系表开奖状态更新失败");
logger.info("pk活动配置表状态更新为:"+betConfig.get("config_status").toString()+",pk关系表活动状态更新为:"+betGroupRelation.get("config_status").toString());
Map<String,Object> user01_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0661 where consumer_id = '100112021' and duiba_activity_id = ?\n",betId);
Assert.assertEquals(user01_order.get("add_credits").toString(),"7","开奖后发奖值校验失败");
Map<String,Object> user02_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0691 where consumer_id = '100112051' and duiba_activity_id = ?\n",betId);
Assert.assertEquals(user02_order.get("add_credits").toString(),"","开奖后发奖值校验失败");
logger.info("用户01获取的积分值为:"+user01_order.get("add_credits").toString()+",用户03获取的积分值为:"+user02_order.get("add_credits").toString());
Map<String,Object> bet1Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ?\n",betId,optionId1);
Assert.assertEquals(bet1Result.get("rank").toString(),"1","开始押注的选项获胜校验失败");
Map<String,Object> bet2Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ?\n",betId,optionId2);
Assert.assertEquals(bet2Result.get("rank").toString(),"2","开始押注的选项获胜校验失败");
Long bet1Times = Long.valueOf(bet1Result.get("bet_times").toString());
Long bet2Times = Long.valueOf(bet2Result.get("bet_times").toString());
Assert.assertTrue(bet1Times>bet2Times,"活动获胜人数比失败人数多校验失败");
logger.info("选项1的押注人数为:"+bet1Result.get("bet_times").toString()+",选项2的押注人数为:"+bet2Result.get("bet_times").toString());
}
public void modifyOpenPrizeTime(String betId,int x) throws Exception{
DateTime time1 = new DateTime();
// int x=20+(int)(Math.random()*100);
DateTime endTime = time1.minusMillis(x);
DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
// String endTimeStr = format.print(endTime.getMillis()).toString();
String endTimeStr = "2018-11-26 20:24:39";
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 = ?\n",endTimeStr,betId);
Boolean result2 = jdbc.update("update act_com_conf.tb_bet_group_relation set end_time = ? where bet_id = ?\n",endTimeStr,betId);
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: 配置测试_AccessTest
* Author: zhaoran
* Date: 2018/12/10 19:45
* Description:
*/
package http.cases.PkMoudleTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.PkService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.math.BigDecimal;
public class 配置测试_AccessTest extends DuibaTestBase {
@Autowired
PkService pkService;
private DuibaLog logger = DuibaLog.getLogger();
private static Integer uid = 5028;//
@Test
public void 配置测试() throws Exception{
Response response = pkService.getBetList(uid);
response.print();
//分积分配置获取
String betType1 = response.jsonPath().getString("data.unbetList[0].betConfig.betType");
String bonusType1 = response.jsonPath().getString("data.unbetList[0].betConfig.bonusType");
String configStatus1 = response.jsonPath().getString("data.unbetList[0].betConfig.configStatus");
String creditsValue1 = response.jsonPath().getString("data.unbetList[0].betConfig.creditsValue");
String id1 = response.jsonPath().getString("data.unbetList[0].betConfig.id");
String shareExp1 = response.jsonPath().getString("data.unbetList[0].betConfig.shareExp");
String title1 = response.jsonPath().getString("data.unbetList[0].betConfig.title");
String unitName1 = response.jsonPath().getString("data.unbetList[0].betConfig.unitName");
//分积分选项获取
String optionId1 = response.jsonPath().getString("data.unbetList[0].options[0].optionId");
String optionImg1 = response.jsonPath().getString("data.unbetList[0].options[0].optionImg");
String optionName1 = response.jsonPath().getString("data.unbetList[0].options[0].optionName");
String optionId2 = response.jsonPath().getString("data.unbetList[0].options[1].optionId");
String optionImg2 = response.jsonPath().getString("data.unbetList[0].options[1].optionImg");
String optionName2 = response.jsonPath().getString("data.unbetList[0].options[1].optionName");
Assert.assertEquals(betType1,"1","校验押注类型失败"); //'押注类型 1-单选单次,2-多选无限制'
Assert.assertEquals(bonusType1,"4","校验瓜分类型失败");//'瓜分类型1瓜分经验2瓜分红包3发奖品4瓜分积分'
Assert.assertEquals(configStatus1,"3","校验投注活动的状态失败");//'投注活动的状态:1关闭不可见2关闭可见3开启4结束'
Assert.assertEquals(creditsValue1,"2.00","校验积分价值失败");//积分价值
Assert.assertEquals(id1,"1354","校验pk id失败");
Assert.assertTrue(new BigDecimal(shareExp1).compareTo(new BigDecimal("99"))==0,"校验瓜分的经验池失败");//瓜分的经验池
Assert.assertEquals(title1,"瓜分积分","校验投注活动标题失败");//投注活动标题
Assert.assertEquals(unitName1,"元宝","校验消耗类型失败");
Assert.assertEquals(optionId1,"2867","校验选项1 id失败");
Assert.assertEquals(optionImg1,"//yun.dui88.com/images/201812/c5vo081h6h.jpg","校验选项1 图片失败");
Assert.assertEquals(optionName1,"分积分1","校验选项1 title失败");
Assert.assertEquals(optionId2,"2868","校验选项2 id失败");
Assert.assertEquals(optionImg2,"//yun.dui88.com/images/201812/5ib6ews6bw.png","校验选项2 图片失败");
Assert.assertEquals(optionName2,"分积分2","校验选项2 title失败");
//分红包配置获取
String betType2 = response.jsonPath().getString("data.unbetList[1].betConfig.betType");
String bonusType2 = response.jsonPath().getString("data.unbetList[1].betConfig.bonusType");
String configStatus2 = response.jsonPath().getString("data.unbetList[1].betConfig.configStatus");
String creditsValue2 = response.jsonPath().getString("data.unbetList[1].betConfig.creditsValue");
String id2 = response.jsonPath().getString("data.unbetList[1].betConfig.id");
String shareExp2 = response.jsonPath().getString("data.unbetList[1].betConfig.shareExp");
String title2 = response.jsonPath().getString("data.unbetList[1].betConfig.title");
String unitName2 = response.jsonPath().getString("data.unbetList[1].betConfig.unitName");
//分红包选项获取
String optionId3 = response.jsonPath().getString("data.unbetList[1].options[0].optionId");
String optionImg3 = response.jsonPath().getString("data.unbetList[1].options[0].optionImg");
String optionName3 = response.jsonPath().getString("data.unbetList[1].options[0].optionName");
String optionId4 = response.jsonPath().getString("data.unbetList[1].options[1].optionId");
String optionImg4 = response.jsonPath().getString("data.unbetList[1].options[1].optionImg");
String optionName4 = response.jsonPath().getString("data.unbetList[1].options[1].optionName");
Assert.assertEquals(betType2,"1","校验押注类型失败"); //'押注类型 1-单选单次,2-多选无限制'
Assert.assertEquals(bonusType2,"2","校验瓜分类型失败");//'瓜分类型1瓜分经验2瓜分红包3发奖品4瓜分积分'
Assert.assertEquals(configStatus2,"3","校验投注活动的状态失败");//'投注活动的状态:1关闭不可见2关闭可见3开启4结束'
Assert.assertEquals(creditsValue2,"3.00","校验积分价值失败");//积分价值
Assert.assertEquals(id2,"1355","校验pk id失败");
Assert.assertTrue(new BigDecimal(shareExp2).compareTo(new BigDecimal("199"))==0,"校验瓜分的经验池失败");//瓜分的经验池
Assert.assertEquals(title2,"瓜分红包","校验投注活动标题失败");//投注活动标题
Assert.assertEquals(unitName2,"元宝","校验消耗类型失败");
Assert.assertEquals(optionId3,"2869","校验选项1 id失败");
Assert.assertEquals(optionImg3,"//yun.dui88.com/images/201812/wfvn1m8wm0.jpg","校验选项1 图片失败");
Assert.assertEquals(optionName3,"分红包选项一","校验选项1 title失败");
Assert.assertEquals(optionId4,"2870","校验选项2 id失败");
Assert.assertEquals(optionImg4,"//yun.dui88.com/images/201812/ifh1kvaq9m.jpg","校验选项2 图片失败");
Assert.assertEquals(optionName4,"分红包选项二","校验选项2 title失败");
logger.info("pk组件分红包、分积分配置校验正确!");
}
}
\ No newline at end of file
......@@ -2,7 +2,10 @@ package http.cases.SingleLotteryTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.SingleLotteryService;
import http.service.Authorization;
import http.service.hd.SigninService;
import io.restassured.http.Cookies;
import io.restassured.internal.assertion.Assertion;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -10,12 +13,20 @@ import org.testng.Assert;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by zhaoran on 2018/6/8.
*/
public class 预览单品抽奖_AccessTest extends DuibaTestBase {
@Autowired
SigninService signinService;
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
Authorization authorization;
private static DuibaLog logger = DuibaLog.getLogger();
@Test
......@@ -25,6 +36,14 @@ public class 预览单品抽奖_AccessTest extends DuibaTestBase {
logger.info("预览url为:"+url);
Assert.assertEquals(url.contains("http://activity.m.duibatest.com.cn/autoLogin/autologin?appKey=BDqysEMghRqpDWAaQu9S4rLihHm&uid=duiba-preview-user"), true, "校验是否展示马上使用失败");
//获取预发场景cookie
Response responses = authorization.previewLogin("BDqysEMghRqpDWAaQu9S4rLihHm","3G9A4pn8M2gVQQJbieW3CF8LRHM4");
//打开活动界面
response = singleLotteryService.index_preview("36732","preview","login",responses.getDetailedCookies());
//判断结果
Assert.assertEquals(MatcherString.getString(response.asString(),"<title>(.*?)</title>",1),"自动化_预览单抽","活动页打开异常!");
logger.info("活动页面打开成功");
}
......
/**
* Copyright (C), 2015-2018
* FileName: BetMngVo
* Author: qianwenjun
* Date: 2018/8/5 10:12
* Description:
*/
package http.model;
import java.util.List;
/**
* @author 赵然
* @create 2018/12/11
* @since 1.0.0
*/
public class BetDevelopVo {
public List<BetOptionVo> getBetOptionDtoList() {
return betOptionDtoList;
}
public void setBetOptionDtoList(List<BetOptionVo> betOptionDtoList) {
this.betOptionDtoList = betOptionDtoList;
}
private List<BetOptionVo> betOptionDtoList;
private String betType; //'押注类型 1-单选单次,2-多选无限制'
private String bonusAmount; //'每人实际分得金额'
private String bonusType; //'瓜分类型1瓜分经验2瓜分红包3发奖品4瓜分积分'
private String configStatus; //'投注活动的状态:1关闭不可见2关闭可见3开启4结束'
private String creditsValue; //'积分价值'
private String endTime; //'活动结束时间'
private String shareExp; //'瓜分的经验池'
private String startTime; // '活动开始时间'
private String title; //'投注活动标题'
// private String id; //主键
// private String pluginId; //'发奖品时需要填插件id'
// private String prizeLimit; //'发奖品时的发放上限'
// public String getPluginId() {
// return pluginId;
// }
//
// public void setPluginId(String pluginId) {
// this.pluginId = pluginId;
// }
//
// public String getPrizeLimit() {
// return prizeLimit;
// }
// public void setPrizeLimit(String prizeLimit) {
// this.prizeLimit = prizeLimit;
// }
public String getBetType() {
return betType;
}
public void setBetType(String betType) {
this.betType = betType;
}
public String getBonusAmount() {
return bonusAmount;
}
public void setBonusAmount(String bonusAmount) {
this.bonusAmount = bonusAmount;
}
public String getBonusType() {
return bonusType;
}
public void setBonusType(String bonusType) {
this.bonusType = bonusType;
}
public String getConfigStatus() {
return configStatus;
}
public void setConfigStatus(String configStatus) {
this.configStatus = configStatus;
}
public String getCreditsValue() {
return creditsValue;
}
public void setCreditsValue(String creditsValue) {
this.creditsValue = creditsValue;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public String getShareExp() {
return shareExp;
}
public void setShareExp(String shareExp) {
this.shareExp = shareExp;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
}
\ No newline at end of file
......@@ -19,7 +19,7 @@ public class BetOptionVo {
private String optionImg;
private String optionName;
private String rightAnswer;
public String getOptionImg() {
return optionImg;
......@@ -37,5 +37,11 @@ public class BetOptionVo {
this.optionName = optionName;
}
public String getRightAnswer() {
return rightAnswer;
}
public void setRightAnswer(String rightAnswer) {
this.rightAnswer = rightAnswer;
}
}
\ No newline at end of file
......@@ -89,7 +89,25 @@ public class SingleLotteryService {
}
return response;
}
public Response index_preview(String atcId,String type,String from,Cookies cookies) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("id",atcId);
map.put("type",type);
map.put("from",from);
map.put("spm","18714.1.1.1");
logger.info("请求/singleLottery/index接口,id=" + atcId);
Response response = given().cookies(cookies).params(map).get("https://activity.m.duibatest.com.cn" + "/singleLottery/index");
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200","活动页打开异常");
}catch(Exception e){
throw new Exception("/singleLottery/index接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/singleLottery/index接口失败,返回信息:"+response.asString());
}
return response;
}
//访问开发者自有手动开奖
public Response index_sd(String atcId) throws Exception {
Map<String,String> map = new HashMap<>();
......
......@@ -173,6 +173,20 @@ public class Authorization {
return response;
}
public Response previewLogin(String appKey,String appSecret){
CreditTool tool=new CreditTool(appKey, appSecret);
Map params=new HashMap();
params.put("uid","duiba-preview-user");
String url=tool.buildUrlWithSign("http://activity.m.duibatest.com.cn/autoLogin/autologin?",params);
logger.info("dafuweng免登陆url为:"+url);
Response response=given().redirects().follow(false).get(url);
logger.info("dafuweng免登陆,响应数据:"+response.asString());
logger.info("dafuweng免登陆,响应状态码:"+response.getStatusCode());
return response;
}
public Map generateSignAutoLogin(String appKey, int uid){
String url = "http://activity.m.duibatest.com.cn/test/generateSign?appKey=" + appKey + "&uid=" + uid + "&vip=5";
Response response = given().get(url);
......
package http.service.hd;
import base.DuibaLog;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import http.model.BetOptionVo;
import http.model.BetDevelopVo;
import http.service.Authorization;
import io.restassured.response.Response;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import utils.MatcherString;
import utils.PublicMethod;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* @author zhaoran
* @create 2018/12/11
* @since 1.0.0
*/
@Service
public class PkDevelopService {
@Value("${hdserver.host}")
String hdHost;
@Value("${manager.host}")
String ManagerHost;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
public Response betEditor(String appId,String bonusType,String bonusAmount,String shareExp) throws Exception{
String data = PublicMethod.data();
String url = "http://" + hdHost + "/visual-editor/bet/post";
//创建投注项
List<BetOptionVo> betOptionVoList = new ArrayList<>();
BetOptionVo betOptionVo1 = new BetOptionVo();
BetOptionVo betOptionVo2 = new BetOptionVo();
betOptionVo1.setOptionImg("//yun.dui88.com/images/201812/75j84chnkg.jpg");
betOptionVo1.setOptionName("1");
betOptionVo1.setRightAnswer(null);
betOptionVo2.setOptionImg("//yun.dui88.com/images/201812/4f51vmzfpu.png");
betOptionVo2.setOptionName("2");
betOptionVo2.setRightAnswer(null);
betOptionVoList.add(betOptionVo1);
betOptionVoList.add(betOptionVo2);
//创建活动配置
List<BetDevelopVo> betDevelopVoList = new ArrayList<>();
BetDevelopVo betDevelopVo = new BetDevelopVo();
betDevelopVo.setBetOptionDtoList(betOptionVoList);
betDevelopVo.setBetType("1");
betDevelopVo.setBonusType(bonusType);
if (bonusType.equals("2")){
betDevelopVo.setTitle("【自动化】组件pk_瓜分红包"+data);
}else if (bonusType.equals("4")){
betDevelopVo.setTitle("【自动化】组件pk_瓜分积分"+data);
}
betDevelopVo.setBonusAmount(bonusAmount);
betDevelopVo.setConfigStatus("3");
betDevelopVo.setCreditsValue("1");
betDevelopVo.setEndTime("2029-12-31 00:00");
betDevelopVo.setShareExp(shareExp);
betDevelopVoList.add(betDevelopVo);
Map<String,Object> para = new HashMap<>();
para.put("list",betDevelopVoList);
para.put("rules","自动化规则自动化规则");
para.put("title","组件pk自动化");
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(para));
Response betResponse = given().contentType("application/json;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).body(jsonParam).post(url);
betResponse.prettyPrint();
try{
Assert.assertEquals(betResponse.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("创建pk活动接口失败,返回信息:"+betResponse.asString());
}catch(Error er){
throw new Exception("创建pk活动接口失败,返回信息:"+betResponse.asString());
}
return betResponse;
}
public Response doDraw() throws Exception{
String url = "http://" + ManagerHost + "/newmanager/betOpenPrize/doDraw";
Map<String,Object> para = new HashMap<>();
// para.put("pageNo","1");
// para.put("pageSize","20");
Response doDrawResponse = given().cookies(authorization.ssoLogin()).params(para).get(url);
try{
Assert.assertEquals(doDrawResponse.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("pk活动开奖接口失败,返回信息:"+doDrawResponse.asString());
}catch(Error er){
throw new Exception("pk活动开奖接口失败,返回信息:"+doDrawResponse.asString());
}
return doDrawResponse;
}
// public static void main(String[] args) throws Exception{
// String endTime = "2021-12-31 23:55:00";
// PkActivityService pkActivityService = new PkActivityService();
//
// Response betResponse = pkActivityService.bet("2",endTime);
// String betId = MatcherString.getString(betResponse.asString(),"\"data\":(.*?)}",1);
// Response betRelation = pkActivityService.betGroupRelation(betId,endTime);
// Response modifyStatusResponse = pkActivityService.modifySatus(betId);
//
// }
}
\ 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