Commit 779009ba authored by 钱雯君's avatar 钱雯君

Merge branch 'qwj_181029' into mabo

parents 3a3520eb fccb45cf
......@@ -168,7 +168,7 @@ public class 集卡_出奖方式测试_DuibaTest extends DuibaTestBase {
String orderId = openResponse.jsonPath().getString("orderId");
Response statusResponse = newActivityService.getOrderStatus31(orderId,uid);
// logger.info("开奖结果如下1:");
// statusResponse.prettyPrint();
statusResponse.prettyPrint();
String playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
int i = 8;
while (i > 0 && (playResult.equals("0"))) {
......@@ -177,7 +177,7 @@ public class 集卡_出奖方式测试_DuibaTest extends DuibaTestBase {
playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
i--;
// logger.info("开奖结果如下2:");
// statusResponse.prettyPrint();
statusResponse.prettyPrint();
}
return statusResponse;
......
......@@ -122,7 +122,7 @@ public class 集卡规则_中奖属性配置_DuibaTest extends DuibaTestBase {
//校验修改内容
Map<String,Object> selectResult = jdbc.findSimpleResult("select * from act_com_conf.tb_clcard_config where id =?",newId);
Assert.assertEquals(selectResult.get("deleted").toString(),"true","删除中奖条件失败");
Assert.assertEquals(selectResult.get("deleted").toString(),"1","删除中奖条件失败");
logger.info("校验删除属性配置成功");
}
......
......@@ -299,7 +299,7 @@ public class 集卡规则_中奖配置测试_DuibaTest extends DuibaTestBase {
//校验修改内容
Map<String,Object> selectResult = jdbc.findSimpleResult("select * from act_com_conf.tb_clcard_config where id =?",newId);
Assert.assertEquals(selectResult.get("deleted").toString(),"true","删除中奖条件失败");
Assert.assertEquals(selectResult.get("deleted").toString(),"1","删除中奖条件失败");
}
......
......@@ -158,7 +158,7 @@ public class 集卡规则_助力规则配置测试_DuibaTest extends DuibaTestBa
//校验修改内容
Map<String,Object> selectResult = jdbc.findSimpleResult("select * from act_com_conf.tb_clcard_config_goods_rules where id =?",newGoodsRuleId);
Assert.assertEquals(selectResult.get("deleted").toString(),"true","删除中奖条件失败");
Assert.assertEquals(selectResult.get("deleted").toString(),"1","删除中奖条件失败");
logger.info("删除集卡助力规则成功");
}
......
......@@ -267,7 +267,6 @@ public class 创建自有活动_DuibaTest extends DuibaTestBase {
}
//删除自有活动
public void 删除自有活动(String title) throws Exception{
//开发者删除自有活动
......
package http.cases.DeveloperTest;
import base.DuibaTestBase;
import org.testng.annotations.DataProvider;
import utils.PublicMethod;
import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService;
import http.service.Activity.SingleLotteryService;
import http.service.hd.DeveloperService;
import http.service.hd.SigninService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
/**
* Created by lvwenyan on 2018/11/23.
*/
public class 新建活动测试_DuibaTest extends DuibaTestBase{
@Autowired
DeveloperService developerService;
private static DuibaLog logger = DuibaLog.getLogger();
@DataProvider
public Object[][] providerMethod(Method method){
Object[][] result = null;
if(method.getName().equals("新建自有积分商城活动工具")) {
result = new Object[][]{
new Object[]{1, "5","everyday","3","everyday","[{\"index\":1,\"type\":\"thanks\",\"img\":\"//yun.duiba.com.cn/upload/uP99F1462438316972.png\",\"title\":\"谢谢参与\",\"valid\":true,\"show\":true},{\"type\":\"coupon\",\"title\":\"优惠券\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":159857,\"name\":\"【自动化勿动】自有优惠券\",\"limit\":\"1\",\"low\":\"2\",\"remaind\":\"100\"},{\"type\":\"object\",\"title\":\"实物\",\"img\":\"//yun.duiba.com.cn/upload/1uF0l1462438316968.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":177222,\"name\":\"【自动化】自有实物\",\"limit\":\"2\",\"low\":\"3\",\"remaind\":\"90\"},{\"type\":\"virtual\",\"title\":\"虚拟商品\",\"img\":\"//yun.duiba.com.cn/developer/img/activityTool/slotMachine/virtual.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":178060,\"value\":\"test\",\"limit\":\"3\",\"low\":\"4\",\"remaind\":\"80\"},{\"type\":\"alipay\",\"title\":\"支付宝\",\"img\":\"//yun.duiba.com.cn/upload/KkZMp1462438317113.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"value\":\"1\",\"limit\":\"4\",\"low\":\"5\",\"remaind\":\"70\"},{\"type\":\"qb\",\"title\":\"Q币\",\"img\":\"//yun.duiba.com.cn/upload/mF3wO1462438317114.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"value\":\"10\",\"limit\":\"5\",\"low\":\"6\",\"remaind\":\"60\"},{\"type\":\"lucky\",\"title\":\"福袋\",\"img\":\"//yun.duiba.com.cn/webapp/img/luckynewn.png\",\"valid\":true,\"probability\":\"10\",\"show\":false,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\"},{\"type\":\"again\",\"title\":\"再抽一次\",\"img\":\"//yun.duiba.com.cn/upload/aJwb11462438317113.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\"}]"
,"//yun.duiba.com.cn/upload/newHdTool/turntable_cricle/banner_750x220.png","新建自有积分商城活动工具--每日次数"}, //case1
new Object[]{2, "10", "forever", "3","forever","[{\"index\":1,\"type\":\"thanks\",\"img\":\"//yun.duiba.com.cn/upload/uP99F1462438316972.png\",\"title\":\"谢谢参与\",\"valid\":true,\"show\":true},{\"type\":\"coupon\",\"title\":\"优惠券\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":159857,\"name\":\"【自动化勿动】自有优惠券\",\"remaind\":\"100\"},{\"type\":\"coupon\",\"title\":\"优惠券2\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":169713,\"name\":\"【勿动】兑吧优惠券扣库存\",\"remaind\":\"100\"},{\"type\":\"coupon\",\"title\":\"优惠券3\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"10\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":172293,\"name\":\"【勿动】兑吧优惠券下载链接兑换记录页\",\"remaind\":\"100\"},{\"type\":\"coupon\",\"title\":\"优惠券4\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":174797,\"name\":\"【勿动】兑吧优惠券预分配库存测试\",\"remaind\":\"100\"},{\"type\":\"coupon\",\"title\":\"优惠券5\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":174923,\"name\":\"【勿动】兑吧优惠券共享库存测试\",\"remaind\":\"100\"},{\"type\":\"coupon\",\"title\":\"优惠券6\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":172292,\"name\":\"【勿动】兑吧优惠券下载链接商家落地页\",\"remaind\":\"100\"},{\"type\":\"coupon\",\"title\":\"优惠券7\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":true,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":175605,\"name\":\"【勿动】兑吧优惠券地区兑换白名单不可兑\",\"remaind\":\"199\"}]"
,"//yun.dui88.com/images/201811/2yyblucaps.jpg","新建自有积分商城活动工具--永久次数"}, //case2
};
}else
if (method.getName().equals("新建自有独立活动工具")){
result = new Object[][]{
new Object[]{1, "10","everyday","everyday","[{\"index\":1,\"type\":\"thanks\",\"img\":\"//yun.duiba.com.cn/upload/uP99F1462438316972.png\",\"title\":\"谢谢参与\",\"valid\":true,\"show\":true},{\"type\":\"coupon\",\"title\":\"优惠券\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":159857,\"name\":\"【自动化勿动】自有优惠券\",\"limit\":\"1\",\"low\":\"2\",\"remaind\":\"100\"},{\"type\":\"object\",\"title\":\"实物\",\"img\":\"//yun.duiba.com.cn/upload/1uF0l1462438316968.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":177222,\"name\":\"【自动化】自有实物\",\"limit\":\"2\",\"low\":\"3\",\"remaind\":\"90\"},{\"type\":\"virtual\",\"title\":\"虚拟商品\",\"img\":\"//yun.duiba.com.cn/developer/img/activityTool/slotMachine/virtual.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":178060,\"value\":\"test\",\"limit\":\"3\",\"low\":\"4\",\"remaind\":\"80\"},{\"type\":\"alipay\",\"title\":\"支付宝\",\"img\":\"//yun.duiba.com.cn/upload/KkZMp1462438317113.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"value\":\"1\",\"limit\":\"4\",\"low\":\"5\",\"remaind\":\"70\"},{\"type\":\"qb\",\"title\":\"Q币\",\"img\":\"//yun.duiba.com.cn/upload/mF3wO1462438317114.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"value\":\"10\",\"limit\":\"5\",\"low\":\"6\",\"remaind\":\"60\"},{\"type\":\"lucky\",\"title\":\"福袋\",\"img\":\"//yun.duiba.com.cn/webapp/img/luckynewn.png\",\"valid\":true,\"probability\":\"10\",\"show\":false,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\"},{\"type\":\"again\",\"title\":\"再抽一次\",\"img\":\"//yun.duiba.com.cn/upload/aJwb11462438317113.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\"}]"
,"//yun.duiba.com.cn/upload/newHdTool/turntable_cricle/banner_750x220.png","新建自有独立活动工具--每日次数"}, //case1
new Object[]{2, "50", "forever", "everyday","[{\"index\":1,\"type\":\"thanks\",\"img\":\"//yun.duiba.com.cn/upload/uP99F1462438316972.png\",\"title\":\"谢谢参与\",\"valid\":true,\"show\":true},{\"type\":\"coupon\",\"title\":\"优惠券\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":159857,\"name\":\"【自动化勿动】自有优惠券\",\"remaind\":\"100\"},{\"type\":\"coupon\",\"title\":\"优惠券2\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":169713,\"name\":\"【勿动】兑吧优惠券扣库存\",\"remaind\":\"100\"},{\"type\":\"coupon\",\"title\":\"优惠券3\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"10\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":172293,\"name\":\"【勿动】兑吧优惠券下载链接兑换记录页\",\"remaind\":\"100\"},{\"type\":\"coupon\",\"title\":\"优惠券4\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":174797,\"name\":\"【勿动】兑吧优惠券预分配库存测试\",\"remaind\":\"100\"},{\"type\":\"coupon\",\"title\":\"优惠券5\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":174923,\"name\":\"【勿动】兑吧优惠券共享库存测试\",\"remaind\":\"100\"},{\"type\":\"coupon\",\"title\":\"优惠券6\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":false,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":172292,\"name\":\"【勿动】兑吧优惠券下载链接商家落地页\",\"remaind\":\"100\"},{\"type\":\"coupon\",\"title\":\"优惠券7\",\"img\":\"//yun.duiba.com.cn/upload/bust51462438317113.png\",\"valid\":true,\"probability\":\"10\",\"show\":true,\"arealimit\":true,\"pronumber\":\"\",\"alipay\":\"\",\"description\":\"\",\"appItemId\":175605,\"name\":\"【勿动】兑吧优惠券地区兑换白名单不可兑\",\"remaind\":\"199\"}]"
,"//yun.dui88.com/images/201811/2yyblucaps.jpg","新建自有独立活动工具--永久次数"}, //case2
};
}else
if(method.getName().equals("新建自有单品抽奖活动")){
result = new Object[][]{
new Object[]{1,"177222","【自动化】自有实物","object","100","5","everyday","//yun.dui88.com/images/201811/hvhlu2ggta.png","0","","false","新建自有单品抽奖--每日次数"}, //case1
new Object[]{2,"159857","【自动化勿动】自有优惠券","coupon","2000","5","forever","//yun.dui88.com/images/201811/hvhlu2ggta.png","2","2","true","新建自有单品抽奖--永久次数和会员等级"}, //case1
};
}
return result;
}
/**
* @param caseNum 用例编号
* @param limitCount 限制次数
* @param limitScope 限制次数类型
* @param freeLimit 免费次数
* @param freeScope 免费次数类型
* @param awards 活动奖品
* @param bannerImgNew 新版banner图
* @param caseName 用例名称
* @throws Exception
*/
@Test(dataProvider = "providerMethod" )
public void 新建自有积分商城活动工具(int caseNum,String limitCount,String limitScope,String freeLimit,String freeScope,String awards,String bannerImgNew,String caseName) throws Exception {
logger.info("-----------------------------"+caseName+"-----------------------------");
String data = PublicMethod.data();
String title = "【自动化】自有活动工具"+data;
//新建自有活动工具
developerService.saveHdAll("","1",title,limitCount,limitScope,freeLimit,freeScope,awards,bannerImgNew);
//获取活动id
Response listResponse = developerService.list2(title);
String id = String.valueOf(listResponse.jsonPath().getString("data.list[0].id"));
//编辑活动,校验活动内容
Response editResponse = developerService.editData(id,"turntable_circle","2239");
switch (caseNum){
case 1:
Assert.assertEquals(editResponse.jsonPath().getString("data.credits"),"10","校验活动积分失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.freeLimit"),"3","校验活动免费抽奖次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.freeScope"),"everyday","校验活动免费抽奖次数类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitCount"),"5","校验活动限制次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitScope"),"everyday","校验活动限制次数类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[1].name"),"【自动化勿动】自有优惠券","校验活动奖品名称失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[1].limit"),"1","校验活动奖品中奖限制失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[1].oldRemaind"),"100","校验活动奖品数量失败");
logger.info("校验新建自有活动工具-1内容成功");
break;
case 2:
Assert.assertEquals(editResponse.jsonPath().getString("data.limitCount"),"10","校验活动限制次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitScope"),"forever","校验活动限制次数类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.freeLimit"),"3","校验活动免费抽奖次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.freeScope"),"forever","校验活动免费抽奖次数类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[2].name"),"【勿动】兑吧优惠券扣库存","校验活动奖品名称失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.bannerImgNew"),"//yun.dui88.com/images/201811/2yyblucaps.jpg","校验活动新版banner图失败");
logger.info("校验新建自有活动工具-2内容成功");
break;
}
//删除测试数据
this.删除自有活动(title);
}
@Test(dataProvider = "providerMethod" )
public void 新建自有独立活动工具(int caseNum,String limitCount,String limitScope,String freeScope,String awards,String bannerImgNew,String caseName) throws Exception {
logger.info("-----------------------------"+caseName+"-----------------------------");
String data = PublicMethod.data();
String title = "【自动化】自有独立活动工具"+data;
//新建自有活动工具
developerService.saveHdAll("","0",title,limitCount,limitScope,"",freeScope,awards,bannerImgNew);
//获取活动id
Response listResponse = developerService.list2(title);
String id = String.valueOf(listResponse.jsonPath().getString("data.list[0].id"));
//编辑活动,校验活动内容
Response editResponse = developerService.editData(id,"turntable_circle","2239");
switch (caseNum){
case 1:
Assert.assertEquals(editResponse.jsonPath().getString("data.credits"),"0","校验活动积分失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitCount"),"10","校验活动免费抽奖次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitScope"),"everyday","校验活动免费抽奖次数类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[1].name"),"【自动化勿动】自有优惠券","校验活动奖品名称失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[1].limit"),"1","校验活动奖品中奖限制失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[1].oldRemaind"),"100","校验活动奖品数量失败");
logger.info("校验新建自有独立活动工具-1内容成功");
break;
case 2:
Assert.assertEquals(editResponse.jsonPath().getString("data.limitCount"),"50","校验活动免费抽奖次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitScope"),"forever","校验活动免费抽奖次数类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.awards[2].name"),"【勿动】兑吧优惠券扣库存","校验活动奖品名称失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.bannerImgNew"),"//yun.dui88.com/images/201811/2yyblucaps.jpg","校验活动新版banner图失败");
logger.info("校验新建自有独立活动工具-2内容成功");
break;
}
//删除测试数据
this.删除自有活动(title);
}
/**
* @param caseNum 用例编号
* @param mainAppItemId 活动奖品id
* @param appItemTitle 活动奖品名称
* @param appItemType 活动奖品类型
* @param mainAppItemRemaining 奖品数量
* @param freeDrawLimit 免费抽奖次数
* @param freeDrawLimitScope 免费抽奖类型
* @param bannerImgNew 新版banner图
* @param vipLimitType 会员等级配置
* @param vipLimits 会员的等级范围
* @param exchangeLimit 直充防刷
* @param caseName 用例名称
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 新建自有单品抽奖活动(int caseNum,String mainAppItemId,String appItemTitle,String appItemType,String mainAppItemRemaining,String freeDrawLimit,String freeDrawLimitScope,String bannerImgNew,String vipLimitType,String vipLimits,String exchangeLimit,String caseName) throws Exception{
logger.info("-----------------------------"+caseName+"-----------------------------");
String data = PublicMethod.data();
String title = "【自动化】自有单品抽奖"+data;
//新建自有活动工具
developerService.saveDpAll("",title,mainAppItemId,appItemTitle,appItemType,mainAppItemRemaining,freeDrawLimit,freeDrawLimitScope,bannerImgNew,vipLimitType,vipLimits,exchangeLimit);
//获取活动id
Response listResponse = developerService.list2(title);
String id = String.valueOf(listResponse.jsonPath().getString("data.list[0].activityId"));
//编辑活动,校验活动内容
Response editResponse = developerService.editDetail("2239",id);
switch (caseNum){
case 1:
Assert.assertEquals(editResponse.jsonPath().getString("data.appItemTitle"),"【自动化】自有实物","校验活动奖品名称失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.bannerImgNew"),"//yun.dui88.com/images/201811/hvhlu2ggta.png","校验活动新版banner图失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.freeDrawLimit"),"5","校验活动免费抽奖次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.freeDrawLimitScope"),"everyday","校验活动免费抽奖类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.consumerDrawLimit"),"2","校验用户抽奖限制次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.consumerDrawLimitScope"),"everyday","校验用户抽奖限制类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.mainAppItemId"),"177222","校验活动奖品id失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.mainAppItemRemaining"),"100","校验活动奖品数量失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.mainAppItemRate"),"66.66","校验活动奖品数量失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.limitDateJson"),"{\"endDay\":\"2020-02-01\",\"endThours\":\"22\",\"endTminute\":\"0\",\"startDay\":\"2018-11-26\",\"startHours\":\"6\",\"startTminute\":\"0\"}","校验活动抽奖日期限制失败");
logger.info("校验新建自有单品抽奖-1内容成功");
break;
case 2:
Assert.assertEquals(editResponse.jsonPath().getString("data.appItemTitle"),"【自动化勿动】自有优惠券","校验活动奖品名称失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.freeDrawLimit"),"5","校验活动免费抽奖次数失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.freeDrawLimitScope"),"forever","校验活动免费抽奖类型失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.mainAppItemId"),"159857","校验活动奖品id失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.appVipLimitOpen"),"true","校验活动会员等级开关失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.vipLimits"),"2","校验活动会员等级范围失败");
Assert.assertEquals(editResponse.jsonPath().getString("data.exchangeLimit"),"true","校验活动直充防刷失败");
logger.info("校验新建自有单品抽奖-1内容成功");
break;
}
//删除测试数据
this.删除自有活动(title);
}
//删除自有活动
public void 删除自有活动(String title) throws Exception{
//开发者删除自有活动
Response HdResponse = developerService.list2(title);
String actId = HdResponse.jsonPath().getString("data.list[0].id");
developerService.delActivity(actId);
}
}
......@@ -11,6 +11,7 @@ import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import http.model.CollectGoodsInfo;
import http.service.Activity.NewCollectActivityService;
import http.service.Manager.EditManagerInfoService;
......@@ -18,6 +19,7 @@ import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import utils.GetCookieUtil;
import java.util.HashMap;
import java.util.List;
......@@ -32,6 +34,7 @@ import static io.restassured.RestAssured.given;
* @create 2018/10/27
* @since 1.0.0
*/
//3个case
public class 新集卡_助力发集卡_DuibaTest extends DuibaTestBase {
......@@ -46,7 +49,7 @@ public class 新集卡_助力发集卡_DuibaTest extends DuibaTestBase {
@Test
public void 助力_发集卡() throws Exception{
//助力规则
//助力规则git
int userId = 3934;
String consumerId = "100092114";
String collectRuleId = "4795";
......@@ -241,15 +244,11 @@ public class 新集卡_助力发集卡_DuibaTest extends DuibaTestBase {
Response response = editManagerInfoService.createUser("新用户助力",appId);
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where name = '新用户助力' and app_id = ?\n",appId);
String uid = user.get("id").toString();
String url = "http://47.97.214.108/user/loginDuiba?uid=" + uid;
Response login = given().get(url);
Map<String,Object> consumer = jdbc.findSimpleResult("select * from new_consumer.consumer_0010 where partner_user_id =? and app_id = ?\n",uid,app_id);
String consumerId = consumer.get("id").toString();
Boolean res = jdbc.update("UPDATE new_consumer.consumer_0010 set addr_name = 'qwj' , addr_phone = '18143476563' ,addr_province = '浙江省' ,addr_city = '杭州市' " +
", addr_area = '西湖区' , addr_detail = '奖池花印' where partner_user_id = ? and app_id = ?\n",uid,app_id);
String url = GetCookieUtil.genUrl(uid,"2wGQc3MZaQsqYFWcX4gguya5PnnS");
JSONObject cookie = GetCookieUtil.getConsumerIdFromCookie(url);
map.put("uid",uid);
map.put("consumerId",consumerId);
logger.info("用户信息为,uid="+uid+"consumerId="+consumerId);
map.put("consumerId",cookie.get("cid").toString());
logger.info("用户信息为,uid="+uid+"consumerId="+cookie.get("cid").toString());
return map;
}
......
......@@ -30,6 +30,7 @@ import java.util.Map;
* @create 2018/10/17
* @since 1.0.0
*/
//5个case
public class 新集卡_开奖异常_DuibaTest extends DuibaTestBase {
......
......@@ -35,6 +35,7 @@ import java.util.Map;
* @create 2018/10/15
* @since 1.0.0
*/
//16个case
public class 新集卡_开奖流程_DuibaTest extends DuibaTestBase {
@Autowired
......
/**
* Copyright (C), 2015-2018
* FileName: pk_开奖_瓜分红包_押注人数不同测试_AccessTest
* Author: qianwenjun
* Date: 2018/8/9 20:13
* Description:
*/
package http.cases.PkTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONObject;
import http.model.BetMngVo;
import http.service.Activity.PkService;
import http.service.Manager.EditManagerInfoService;
import http.service.Manager.PkActivityService;
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.AfterClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import utils.GetCookieUtil;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static io.restassured.RestAssured.form;
import static io.restassured.RestAssured.given;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/8/9
* @since 1.0.0
*/
public class pk_开奖_批量用户开奖测试 extends DuibaTestBase {
@Autowired
PkService pkService;
@Autowired
PkActivityService pkActivityService;
@Autowired
EditManagerInfoService editManagerInfoService;
private static DuibaLog logger = DuibaLog.getLogger();
private String groupId = "7";
private String newBetId = "";
private List<String> optionsIds = new ArrayList<>();
private List<String> consumerIds = new ArrayList<>();
@BeforeMethod
//注意初始化的方法不能与父类的相同,会被覆盖住
public void setUpPkActivity() {
try {
createPk("2","2020-08-12 00:00:00",groupId);
}catch (Exception e){
e.printStackTrace();
}
}
@Test
public void 瓜分红包_批量用户开奖测试() throws Exception{
List<Map<String,Object>> pks = jdbc.findModeResult("select * from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
logger.info("pk活动信息为"+JSONObject.toJSONString(pks));
for (int i=0;i<pks.size();i++){
optionsIds.add(pks.get(i).get("id").toString());
}
logger.info("pk活动id为:"+newBetId+",选项id为:"+ optionsIds.toString());
for (int i=0;i<101;i++){
Map<String,String> user = createUser();
consumerIds.add(user.get("consumerId"));
Response res = pkService.doJoin(Integer.valueOf(user.get("uid")),newBetId,optionsIds.get(0));
}
logger.info("用户的consumerId为="+consumerIds.toString());
//修改开奖时间
this.modifyOpenPrizeTime(newBetId);
//调用开奖接口
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
//校验点
//1、pk活动表配置的状态更新为4;2、订单表的addCredits字段为瓜分的红包值;3、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数
this.checkPKConfig();
this.checkUserAccount(consumerIds);
this.checkRecord();
Map<String,Object> bet1Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ?\n",newBetId,optionsIds.get(0));
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",newBetId,optionsIds.get(1));
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 createPk(String bounsType,String endTime,String groupId) throws Exception {
Response betResponse = pkActivityService.betForSetUp(bounsType,endTime);
logger.info("新建pk活动的结果信息为"+JSONObject.toJSONString(betResponse.prettyPrint()));
betResponse.prettyPrint();
String betId = betResponse.jsonPath().getString("data");
// 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 void modifyOpenPrizeTime(String betId) 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);
}
public Map<String,String> createUser() throws Exception{
Map<String,String> map = new HashMap<>();
Response response = editManagerInfoService.createUser("pk活动批量开奖测试用户");
Map<String,Object> user = jdbc.findSimpleResult("select * from dafuweng.user where name = 'pk活动批量开奖测试用户' and app_id = '67'\n");
String uid = user.get("id").toString();
String url = GetCookieUtil.genUrl(uid,"3erv8LvBxKBSyuGK5i8FSGyYoFD1");
JSONObject cookie = GetCookieUtil.getConsumerIdFromCookie(url);
map.put("uid",uid);
map.put("consumerId",cookie.get("cid").toString());
logger.info("用户信息为,uid="+uid+"consumerId="+cookie.get("cid").toString());
return map;
}
public void checkPKConfig() throws Exception{
Map<String,Object> betConfig = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_config where id = ?",newBetId);
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",newBetId);
Assert.assertEquals(betGroupRelation.get("config_status").toString(),"4","pk关系表开奖状态更新失败");
logger.info("pk活动配置表状态更新为:"+betConfig.get("config_status").toString()+",pk关系表活动状态更新为:"+betGroupRelation.get("config_status").toString());
Response betList = pkActivityService.getMngBetList();
betList.prettyPrint();
List<BetMngVo> betMngVoList = betList.jsonPath().getList("data.page",BetMngVo.class);
for (BetMngVo bet:betMngVoList){
if (bet.getId().equals(newBetId)){
Assert.assertEquals(bet.getConfigStatus(),"4","开奖结果校验失败");
}
}
}
public void checkUserAccount(List<String> comsumerIds) throws Exception{
for (int i=0;i<comsumerIds.size();i++){
String dbName = "consumer_accounts.tb_consumer_account_"+ String.format("%04d", Long.parseLong(comsumerIds.get(i)) % 1024);
logger.info("用户的分表名dbName为"+dbName);
Map<String,Object> user_account = jdbc.findSimpleResult("select * from "+dbName+" where consumer_id = ? and account_type = '6'\n",consumerIds.get(i));
Long account = Long.valueOf(user_account.get("balance_amount").toString());
Assert.assertEquals(account.toString(),"10","用户入账校验失败");
}
}
public void checkRecord() throws Exception{
List<Map<String,Object>> useRecord = jdbc.findModeResult("select * from act_record.tb_bet_record where bet_id = ? \n",newBetId);
for (int i=0;i<useRecord.size();i++) {
Assert.assertEquals(useRecord.get(i).get("bonus").toString(), "10", "record表的红包值校验失败");
Assert.assertEquals(useRecord.get(i).get("exchange_status").toString(), "2", "record表的发奖状态校验失败");
}
}
public void clear(List<String> comsumerIds) throws Exception{
Boolean res = jdbc.update("delete from dafuweng.user where name = 'pk活动批量开奖测试用户' and app_id = '67'");
for(int i=0;i<comsumerIds.size();i++){
String dbName = "new_consumer.consumer_"+ String.format("%04d", Long.parseLong(comsumerIds.get(i))/10000000);
logger.info("用户的分表名dbName为"+dbName);
Boolean res1 = jdbc.update("delete from "+dbName+" where id = ?",comsumerIds.get(i));
}
}
@AfterClass
public void tearDown() {
try {
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result2 = 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 like '【自动化】瓜分红包%')");
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%'");
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
clear(consumerIds);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: pk_开奖_瓜分红包_押注人数不同测试_AccessTest
* Author: qianwenjun
* Date: 2018/8/9 20:13
* Description:
*/
package http.cases.PkTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSONObject;
import http.model.BetMngVo;
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.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
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.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/8/9
* @since 1.0.0
*/
public class pk_开奖_瓜分红包_押注人数不同测试_AccessTest extends DuibaTestBase {
@Autowired
PkService pkService;
@Autowired
PkActivityService pkActivityService;
private static DuibaLog logger = DuibaLog.getLogger();
private String groupId = "7";
private Integer user01 = 3445;
private String consumerId01 = "100066364";//activity_order_con.tb_trade_center_activity_order_0060
private Integer user02 = 3446;
private String consumerId02 = "100066365";//activity_order_con.tb_trade_center_activity_order_0061
private Integer user03 = 3447;
private String consumerId03 = "100066366";//activity_order_con.tb_trade_center_activity_order_0062
private Integer user04 = 3448;
private String consumerId04 = "100066367";//activity_order_con.tb_trade_center_activity_order_0063
private String newBetId = "";
private List<String> optionsIds = new ArrayList<>();
@BeforeMethod
//注意初始化的方法不能与父类的相同,会被覆盖住
public void setUpPkActivity() {
try {
createPk("2","2020-08-12 00:00:00",groupId);
}catch (Exception e){
e.printStackTrace();
}
}
@Test
public void 瓜分红包_两个选项_押注人数不同_开奖测试(){
try {
List<Map<String,Object>> pks = jdbc.findModeResult("select * from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
logger.info("pk活动信息为"+JSONObject.toJSONString(pks));
for (int i=0;i<pks.size();i++){
optionsIds.add(pks.get(i).get("id").toString());
}
logger.info("pk活动id为:"+newBetId+",选项id为:"+ optionsIds.toString());
Map<String,Object> user01_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0060 where consumer_id = '100066364' and account_type = '6'\n");
Long use1_Acc1 = Long.valueOf(user01_account1.get("balance_amount").toString());
Map<String,Object> user02_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0061 where consumer_id = '100066365' and account_type = '6'\n");
Long use2_Acc1 = Long.valueOf(user02_account1.get("balance_amount").toString());
Map<String,Object> user03_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0062 where consumer_id = '100066366' and account_type = '6'\n");
Long use3_Acc1 = Long.valueOf(user03_account1.get("balance_amount").toString());
Map<String,Object> user04_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0063 where consumer_id = '100066367' and account_type = '6'\n");
Long use4_Acc1 = Long.valueOf(user04_account1.get("balance_amount").toString());
//押注第一个选项:user01,user02
//押注第二个选项:user03,user04
Response res1 = pkService.doJoin(user01,newBetId,optionsIds.get(0));
Response res2 = pkService.doJoin(user02,newBetId,optionsIds.get(1));
Response res3 = pkService.doJoin(user03,newBetId,optionsIds.get(1));
Response res4 = pkService.doJoin(user04,newBetId,optionsIds.get(1));
//修改开奖时间
this.modifyOpenPrizeTime(newBetId,60);
//调用开奖接口
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
//校验点
//1、pk活动表配置的状态更新为4;2、订单表的addCredits字段为瓜分的红包值;3、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数,4、校验account表的红包值加上去
Map<String,Object> betConfig = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_config where id = ?",newBetId);
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",newBetId);
Assert.assertEquals(betGroupRelation.get("config_status").toString(),"4","pk关系表开奖状态更新失败");
logger.info("pk活动配置表状态更新为:"+betConfig.get("config_status").toString()+",pk关系表活动状态更新为:"+betGroupRelation.get("config_status").toString());
Response betList = pkActivityService.getMngBetList();
betList.prettyPrint();
List<BetMngVo> betMngVoList = betList.jsonPath().getList("data.page",BetMngVo.class);
for (BetMngVo bet:betMngVoList){
if (bet.getId().equals(newBetId)){
Assert.assertEquals(bet.getConfigStatus(),"4","开奖结果校验失败");
}
}
Map<String,Object> user01_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0060 where consumer_id = '100066364' and duiba_activity_id = ?\n",newBetId);
Assert.assertEquals(user01_order.get("add_credits").toString(),"","开奖后发奖值校验失败");
Map<String,Object> user02_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0061 where consumer_id = '100066365' and duiba_activity_id = ?\n",newBetId);
Assert.assertEquals(user02_order.get("add_credits").toString(),"10","开奖后发奖值校验失败");
Map<String,Object> user03_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0062 where consumer_id = '100066366' and duiba_activity_id = ?\n",newBetId);
Assert.assertEquals(user03_order.get("add_credits").toString(),"10","开奖后发奖值校验失败");
Map<String,Object> user04_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0063 where consumer_id = '100066367' and duiba_activity_id = ?\n",newBetId);
Assert.assertEquals(user04_order.get("add_credits").toString(),"10","开奖后发奖值校验失败");
logger.info("用户01获取的红包值为:"+user01_order.get("add_credits").toString()+",用户02获取的红包值为:"+user02_order.get("add_credits").toString());
logger.info("用户03获取的红包值为:"+user03_order.get("add_credits").toString()+",用户04获取的红包值为:"+user04_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",newBetId,optionsIds.get(0));
Assert.assertEquals(bet1Result.get("rank").toString(),"2","开始押注的选项获胜校验失败");
Map<String,Object> bet2Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ?\n",newBetId,optionsIds.get(1));
Assert.assertEquals(bet2Result.get("rank").toString(),"1","开始押注的选项获胜校验失败");
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());
Map<String,Object> user01_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0060 where consumer_id = '100066364' and account_type = '6'\n");
Long use1_Acc2 = Long.valueOf(user01_account2.get("balance_amount").toString());
Assert.assertEquals(use1_Acc2,use1_Acc1,"用户1入账校验失败");
Map<String,Object> user02_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0061 where consumer_id = '100066365' and account_type = '6'\n");
Long use2_Acc2 = Long.valueOf(user02_account2.get("balance_amount").toString());
Assert.assertEquals(use2_Acc2.toString(),String.valueOf(use2_Acc1+10),"用户2入账校验失败");
Map<String,Object> user03_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0062 where consumer_id = '100066366' and account_type = '6'\n");
Long use3_Acc2 = Long.valueOf(user03_account2.get("balance_amount").toString());
Assert.assertEquals(use3_Acc2.toString(),String.valueOf(use3_Acc1+10),"用户3入账校验失败");
Map<String,Object> user04_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0063 where consumer_id = '100066367' and account_type = '6'\n");
Long use4_Acc2 = Long.valueOf(user04_account2.get("balance_amount").toString());
Assert.assertEquals(use4_Acc2.toString(),String.valueOf(use4_Acc1+10),"用户4入账校验失败");
}catch (Exception e){
e.printStackTrace();
}
}
public void createPk(String bounsType,String endTime,String groupId) throws Exception {
Response betResponse = pkActivityService.betForSetUp(bounsType,endTime);
logger.info("新建pk活动的结果信息为"+JSONObject.toJSONString(betResponse.prettyPrint()));
betResponse.prettyPrint();
String betId = betResponse.jsonPath().getString("data");newBetId = betId;
logger.info("newBetId的信息为"+newBetId);
Response betRelation = pkActivityService.betGroupRelation(betId,endTime,groupId);
Response modifyStatusResponse = pkActivityService.modifySatus(betId);
}
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);
}
// @Test
public void 调试(){
try {
Map<String,Object> betConfig = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_config where id = ?","1179");
logger.info("betConfig的信息为:"+ JSONObject.toJSONString(betConfig));
logger.info("betConfig的信息为:"+ betConfig.toString());
Response betList = pkActivityService.getMngBetList();
betList.prettyPrint();
List<BetMngVo> betMngVoList = betList.jsonPath().getList("data.page",BetMngVo.class);
for (BetMngVo bet:betMngVoList){
if (bet.getId().equals("1185")){
Assert.assertEquals(bet.getConfigStatus(),"4","开奖结果校验失败");
}
}
}catch (Exception e){
e.printStackTrace();
}
}
@AfterClass
public void tearDown() {
try {
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result2 = 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 like '【自动化】瓜分红包%')");
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%'");
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: pk_开奖_瓜分红包_押注人数不同测试_AccessTest
* Author: qianwenjun
* Date: 2018/8/9 20:13
* Description:
*/
package http.cases.PkTest;
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 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.AfterClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import utils.MatcherString;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/8/9
* @since 1.0.0
*/
public class pk_开奖_瓜分红包_押注人数相同测试_AccessTest extends DuibaTestBase {
@Autowired
PkService pkService;
@Autowired
PkActivityService pkActivityService;
private static DuibaLog logger = DuibaLog.getLogger();
private String groupId = "7";
private Integer user01 = 4782;
private String consumerId01 = "100107000";//activity_order_con.tb_trade_center_activity_order_0760
private Integer user02 = 4783;
private String consumerId02 = "100107001";//activity_order_con.tb_trade_center_activity_order_0761
private String newBetId = "";
private List<String> optionsIds = new ArrayList<>();
@BeforeMethod
//注意初始化的方法不能与父类的相同,会被覆盖住
public void setUpPkActivity() {
try {
createPk("2","2020-08-12 00:00:00",groupId);
}catch (Exception e){
e.printStackTrace();
}
}
@Test
public void 瓜分红包_两个选项_押注人数相同_开奖测试() throws Exception{
List<Map<String,Object>> pks = jdbc.findModeResult("select * from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
logger.info("pk活动信息为"+JSONObject.toJSONString(pks));
for (int i=0;i<pks.size();i++){
optionsIds.add(pks.get(i).get("id").toString());
}
logger.info("pk活动id为:"+newBetId+",选项id为:"+ optionsIds.toString());
Map<String,Object> user01_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0760 where consumer_id = '100107000' and account_type = '6'\n");
Long use1_Acc1 = Long.valueOf(user01_account1.get("balance_amount").toString());
Map<String,Object> user02_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0761 where consumer_id = '100107001' and account_type = '6'\n");
Long use2_Acc1 = Long.valueOf(user02_account1.get("balance_amount").toString());
//押注第一个选项:user01,user02
//押注第二个选项:user03,user04
Response res1 = pkService.doJoin(user01,newBetId,optionsIds.get(0));
Response res2 = pkService.doJoin(user02,newBetId,optionsIds.get(1));
//修改开奖时间
this.modifyOpenPrizeTime(newBetId,120);
//调用开奖接口
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
//校验点
//1、pk活动表配置的状态更新为4;2、订单表的addCredits字段为瓜分的红包值;3、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数
Map<String,Object> betConfig = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_config where id = ?",newBetId);
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",newBetId);
Assert.assertEquals(betGroupRelation.get("config_status").toString(),"4","pk关系表开奖状态更新失败");
logger.info("pk活动配置表状态更新为:"+betConfig.get("config_status").toString()+",pk关系表活动状态更新为:"+betGroupRelation.get("config_status").toString());
Response betList = pkActivityService.getMngBetList();
betList.prettyPrint();
List<BetMngVo> betMngVoList = betList.jsonPath().getList("data.page",BetMngVo.class);
for (BetMngVo bet:betMngVoList){
if (bet.getId().equals(newBetId)){
Assert.assertEquals(bet.getConfigStatus(),"4","开奖结果校验失败");
}
}
Map<String,Object> user01_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0760 where consumer_id = '100107000' and duiba_activity_id = ?\n",newBetId);
Assert.assertEquals(user01_order.get("add_credits").toString(),"10","开奖后发奖值校验失败");
Map<String,Object> user02_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0761 where consumer_id = '100107001' and duiba_activity_id = ?\n",newBetId);
Assert.assertEquals(user02_order.get("add_credits").toString(),"","开奖后发奖值校验失败");
logger.info("用户01获取的红包值为:"+user01_order.get("add_credits").toString()+",用户02获取的红包值为:"+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",newBetId,optionsIds.get(0));
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",newBetId,optionsIds.get(1));
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());
Map<String,Object> user01_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0760 where consumer_id = '100107000' and account_type = '6'\n");
Long use1_Acc2 = Long.valueOf(user01_account2.get("balance_amount").toString());
Assert.assertEquals(use1_Acc2.toString(),String.valueOf(use1_Acc1+10),"用户2入账校验失败");
Map<String,Object> user02_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0761 where consumer_id = '100107001' and account_type = '6'\n");
Long use2_Acc2 = Long.valueOf(user02_account2.get("balance_amount").toString());
Assert.assertEquals(use2_Acc2,use2_Acc1,"用户2入账校验失败");
}
public void createPk(String bounsType,String endTime,String groupId) throws Exception {
Response betResponse = pkActivityService.betForSetUp(bounsType,endTime);
logger.info("新建pk活动的结果信息为"+JSONObject.toJSONString(betResponse.prettyPrint()));
betResponse.prettyPrint();
String betId = betResponse.jsonPath().getString("data");
// 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 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);
}
@AfterClass
public void tearDown() {
try {
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result4 = jdbc.update("delete from act_record.tb_bet_record where bet_id in (select id from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%')");
Boolean result2 = 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 like '【自动化】瓜分红包%')");
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where title like '【自动化】瓜分红包%'");
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
}
}
\ 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 beforeMethod() {
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
......@@ -124,6 +124,44 @@ public class pk_管理端测试_AccessTest extends DuibaTestBase {
}
@Test
public void 创建pk活动_瓜分优惠券测试() {
try {
Response oldBetList = pkActivityService.getMngBetList();
String oldTotal = oldBetList.jsonPath().getString("data.params.total");
logger.info("创建之前的列表中条数为:"+oldTotal);
createPk("3");
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("3"))){
logger.info("bet的信息为="+JSON.toJSONString(bet));
Assert.assertEquals(bet.getBetType(),"1","校验pk活动单选单次类型失败");
Assert.assertEquals(bet.getBonusType(),"3","校验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活动结束时间失败");
Assert.assertEquals(bet.getPluginId(),"12","校验插件id失败");
Assert.assertEquals(bet.getPrizeLimit(),"1000","校验奖品发放上限失败");
}else{
break;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void 创建pk活动组_无投放渠道(){
......@@ -211,8 +249,8 @@ public class pk_管理端测试_AccessTest extends DuibaTestBase {
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");
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活动-瓜分红包\" OR title = \"【自动化】新建pk活动-瓜分红包\")\n");
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_config where title = \"【自动化】新建pk活动-瓜分经验\" OR title = \"【自动化】新建pk活动-瓜分红包\" OR title = \"【自动化】新建pk活动-瓜分优惠券\"\n");
Boolean result2 = jdbc.update("delete from act_com_conf.tb_app_group_relation where group_id in (select id from act_com_conf.tb_bet_act_group where title = '【勿动】新增pk组')");
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_act_group where title = '【勿动】新增pk组'");
......@@ -220,6 +258,10 @@ public class pk_管理端测试_AccessTest extends DuibaTestBase {
Boolean result4 = jdbc.update("delete from act_com_conf.tb_app_group_relation where group_id in (select id from act_com_conf.tb_bet_act_group where title = '【勿动】增pk组投放')");
Boolean result5 = jdbc.update("delete from act_com_conf.tb_bet_act_group where title = '【勿动】增pk组投放'");
Boolean result6 = 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活动-瓜分红包')");
Boolean result7 = jdbc.update("delete from act_com_conf.tb_bet_config where title = '【自动化】新建pk活动-瓜分红包'");
} catch (SQLException e) {
e.printStackTrace();
}
......
......@@ -13,6 +13,9 @@ import com.alibaba.fastjson.JSONObject;
import http.model.BetOptionVo;
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;
......@@ -46,6 +49,7 @@ public class PkActivityService {
public Response bet(String bonusType,String endTime) throws Exception{
String url = "http://" + ManagerHost + "/newmanager/bet";
List<BetOptionVo> betOptionVoList = new ArrayList<>();
BetOptionVo betOptionVo1 = new BetOptionVo();
BetOptionVo betOptionVo2 = new BetOptionVo();
......@@ -58,12 +62,18 @@ public class PkActivityService {
Map<String,Object> para = new HashMap<>();
para.put("betOptionDtoList",betOptionVoList);
para.put("betType","1");//1-单选单次;
para.put("bonusType",bonusType);//1-经验;2-红包
para.put("bonusType",bonusType);//1-经验;2-红包;3-优惠券
if (bonusType.equals("2")){
para.put("bonusAmount","0.1");//实际瓜分红包金额
para.put("title","【自动化】新建pk活动-瓜分红包");
}else {
}else if (bonusType.equals("1")){
para.put("title","【自动化】新建pk活动-瓜分经验");
}else {
para.put("title","【自动化】新建pk活动-瓜分优惠券");
para.put("bonusAmount","");
para.put("pluginId","12");//插件id
para.put("prizeLimit","1000");//发放上限
}
para.put("configStatus","1");
para.put("creditsValue","1");
......@@ -87,6 +97,52 @@ public class PkActivityService {
}
public Response betForSetUp(String bonusType,String endTime) throws Exception{
String url = "http://" + ManagerHost + "/newmanager/bet";
DateTime date = new DateTime();
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
String time = formatter.print(date.getMillis()).toString();
List<BetOptionVo> betOptionVoList = new ArrayList<>();
BetOptionVo betOptionVo1 = new BetOptionVo();
BetOptionVo betOptionVo2 = new BetOptionVo();
betOptionVo1.setOptionImg("//yun.dui88.com/images/201807/6pyca34t5e.jpeg");
betOptionVo1.setOptionName("【自动化】选项A1");
betOptionVo2.setOptionImg("//yun.dui88.com/images/201807/kcrl1q7hkt.jpeg");
betOptionVo2.setOptionName("【自动化】选项A2");
betOptionVoList.add(betOptionVo1);
betOptionVoList.add(betOptionVo2);
Map<String,Object> para = new HashMap<>();
para.put("betOptionDtoList",betOptionVoList);
para.put("betType","1");//1-单选单次;
para.put("bonusType",bonusType);//1-经验;2-红包
if (bonusType.equals("2")){
para.put("bonusAmount","0.1");//实际瓜分红包金额
para.put("title","【自动化】瓜分红包"+time);
}else {
para.put("title","【自动化】瓜分经验"+time);
}
para.put("configStatus","1");
para.put("creditsValue","1");
para.put("endTime",endTime);
para.put("shareExp","13");
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(para));
Response betResponse = given().contentType("application/json;charset=UTF-8").cookies(authorization.ssoLogin()).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 betGroupRelation(String betId,String endTime,String groupId) throws Exception{
String url = "http://" + ManagerHost + "/newmanager/betGroupRelation";
......@@ -225,9 +281,28 @@ public class PkActivityService {
return groupListResponse;
}
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();
......
package http.service.hd;
import cn.com.duiba.activity.center.api.params.MainmeetActivityParams;
import com.alibaba.fastjson.JSON;
import http.service.Authorization;
import base.DuibaLog;
......@@ -15,6 +16,7 @@ import java.util.List;
import java.util.Map;
import static io.restassured.RestAssured.given;
import static io.restassured.RestAssured.post;
@Service
public class DeveloperService {
......@@ -912,4 +914,144 @@ public class DeveloperService {
return response;
}
//创建自有活动工具-所有字段
public Response saveHdAll(String id,String creditsType,String title,String limitCount,String limitScope,String freeLimit,String freeScope,String awards,String bannerImgNew) throws Exception {
String url=hdHost+"/launch/save";
Map<String,String> map = new HashMap<>();
map.put("id",id);
map.put("subType","turntable_circle");
map.put("creditsType",creditsType);
map.put("title",title);
map.put("credits","10");
map.put("limitCount",limitCount);
map.put("limitScope",limitScope);
map.put("freeLimit",freeLimit);
map.put("freeScope",freeScope);
map.put("optionNum","");
map.put("anticheatExchangeLimit","true");
map.put("autoOffDate","2030-12-01 00:00");
map.put("banner","//yun.duiba.com.cn/upload/r1u3O1460639179556.png");
map.put("thumbnail","//yun.duiba.com.cn/upload/R8Hac1467009242903.png");
map.put("questionRecord","[]");
map.put("awards",awards);
map.put("appId","2239");
map.put("bannerImgNew",bannerImgNew);
logger.info("请求创建自有活动工具url:"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLogin()).params(map).post("http://"+url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建自有活动接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建自有活动接口失败,返回信息:"+response.asString());
}
return response;
}
//开发者后台编辑自有活动
public Response editData(String actId,String type,String appId) throws Exception {
String url=hdHost+"/launch/editData";
Map<String,String> map = new HashMap<>();
map.put("actId",actId);
map.put("type",type);
map.put("appId",appId);
logger.info("请求编辑自有活动url:"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLogin()).params(map).post("http://"+url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("编辑自有活动接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("编辑自有活动接口失败,返回信息:"+response.asString());
}
return response;
}
//创建保存自有单品抽奖
public Response saveDpAll(String id,String title,String mainAppItemId,String appItemTitle,String appItemType, String mainAppItemRemaining,String freeDrawLimit,String freeDrawLimitScope,String bannerImgNew,String vipLimitType,String vipLimits,String exchangeLimit) throws Exception {
String url=hdHost+"/appSingleLottery/saveOrUpdate";
Map<String,String> map = new HashMap<>();
map.put("appId","2239");
map.put("id",id);
map.put("appItemTitle",appItemTitle);
map.put("title",title);
map.put("mainAppItemRemaining",mainAppItemRemaining);
map.put("preMainAppItemRemaining","0");
map.put("credits","50");
map.put("mainAppItemRate","66.66");
map.put("minComein","100");
map.put("autoOffDate","2020-11-01 00:00");
map.put("introduction","自动化测试单品抽奖 奖品说明");
map.put("vipLimitType",vipLimitType);
map.put("vipLimits",vipLimits);
map.put("moreExchangeLimit","true");
map.put("freeDrawLimit",freeDrawLimit);
map.put("freeDrawLimitScope",freeDrawLimitScope);
map.put("consumerDrawLimit","2");
map.put("consumerDrawLimitScope","everyday");
map.put("consumerWinLimit","1");
map.put("everydayWinLimit","10");
map.put("startDay","2018-11-26");
map.put("endDay","2020-02-01");
map.put("startHours","6");
map.put("startTminute","0");
map.put("endThours","22");
map.put("endTminute","0");
map.put("exchangeLimit",exchangeLimit);
map.put("appItemType",appItemType);
map.put("mainAppItemId",mainAppItemId);
map.put("mainAppItemDegree","");
map.put("appItemId",mainAppItemId);
map.put("logo","//yun.dui88.com/images/201610/dczuwpckbw.png");
map.put("smallImage","//yun.dui88.com/images/201610/2tvxvbhj3x.jpg");
map.put("image","//yun.dui88.com/images/201610/sk21di3uia.jpg");
map.put("bannerImgNew",bannerImgNew);
logger.info("请求创建单品抽奖url:"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLogin()).params(map).post("http://"+url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建自有单品抽奖接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建自有单品抽奖接口失败,返回信息:"+response.asString());
}
return response;
}
//开发者后台编辑自有单品抽奖活动
public Response editDetail(String appId,String singleLotteryId) throws Exception {
String url=hdHost+"/appSingleLottery/editDetail";
Map<String,String> map = new HashMap<>();
map.put("appId",appId);
map.put("singleLotteryId",singleLotteryId);
logger.info("请求编辑自有单品抽奖活动url:"+url);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLogin()).params(map).get("http://"+url);
response.prettyPrint();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("编辑自有单品抽奖活动接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("编辑自有单品抽奖活动接口失败,返回信息:"+response.asString());
}
return response;
}
}
/**
* Copyright (C), 2015-2018
* FileName: BASE64
* Author: qianwenjun
* Date: 2018/9/11 10:02
* Description:
*/
package utils;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/9/11
* @since 1.0.0
*/
public class BASE64 {
/**
* BASE64解密
*
* @param key
* @return
* @throws Exception
*/
public static byte[] decryptBASE64(String key) throws Exception {
return (new BASE64Decoder()).decodeBuffer(key);
}
/**
* BASE64加密
*
* @param key
* @return
* @throws Exception
*/
public static String encryptBASE64(byte[] key) throws Exception {
return (new BASE64Encoder()).encodeBuffer(key);
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: GetCookieUtil
* Author: qianwenjun
* Date: 2018/11/28 13:34
* Description:
*/
package utils;
import base.DuibaLog;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.restassured.response.Response;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/11/28
* @since 1.0.0
*/
public class GetCookieUtil {
private static DuibaLog logger = DuibaLog.getLogger();
public static JSONObject getConsumerIdFromCookie(String url) throws Exception{
// Response response = given().get(url);
Response response=given().redirects().follow(false).get(url);
response.prettyPrint();
Map<String,String> cookies = response.getCookies();
String cookieValue = response.getCookie("_ac");
byte[] bytes = BASE64.decryptBASE64(cookieValue);
JSONObject userCookie = JSON.parseObject(new String(bytes,"utf-8"));
// Headers allHeaders = response.getHeaders();
// String headerName = response.getHeader("Set-Cookie");
logger.info("userCookie="+JSONObject.toJSONString(userCookie));
logger.info("aid="+userCookie.get("aid")+",cid="+userCookie.get("cid"));
return userCookie;
}
public static String genUrl(String uid,String appkey) throws Exception{
String res = null;
String url = "http://home.m.duibatest.com.cn/test/generateSign";
Map<String,String> para = new HashMap<>();
para.put("appKey",appkey);
para.put("uid",uid);
Response response = given().params(para).get(url);
response.prettyPrint();
res = response.jsonPath().getString("url").toString();
return res;
}
}
\ No newline at end of file
......@@ -4,8 +4,8 @@ proxyserver.ip=172.16.80.203
proxyserver.port=22
proxyserver.user=dev
proxyserver.prvkey=key/hzlId_rsa
dafuweng.host=dafuweng.duibatest.com.cn
dafuweng.port=80
dafuweng.host=47.97.214.108
dafuweng.port=9002
uid=2707
appId=2239
hdserver.host=hd.dlp.duibatest.com.cn
......@@ -24,47 +24,47 @@ trade.host = activity.m.duibatest.com.cn
//\u6570\u636E\u5E93\u914D\u7F6E
db.name = duiba_test
db.password= svbP3KUw2PurAnBb2rbs3vohF
db.url = jdbc:mysql://47.97.127.67:13001/?tinyInt1isBit=false
db.url = jdbc:mysql://rdswy2b9wy53044250u1o.mysql.rds.aliyuncs.com:3306/?tinyInt1isBit=false
db.driver= com.mysql.cj.jdbc.Driver
db.maxtotal = 6
//钉钉报告配置
pluginTest.project=插件
//\u9489\u9489\u62A5\u544A\u914D\u7F6E
pluginTest.project=\u63D2\u4EF6
pluginTest.names=zhaoran,qianwenjun
pluginTest.group=插件-接口自动化
pluginTest.group=\u63D2\u4EF6-\u63A5\u53E3\u81EA\u52A8\u5316
pluginTest.resultUrl=http://tst.deploy.dui88.com/view/duibaTest/job/duibaPlugin_interface/HTML_Report/suite1_test1_results.html
signTest.project=签到
signTest.project=\u7B7E\u5230
signTest.names=zhousongbo
signTest.group=签到-接口自动化
signTest.group=\u7B7E\u5230-\u63A5\u53E3\u81EA\u52A8\u5316
signTest.resultUrl=http://tst.deploy.dui88.com/view/duibaTest/job/duibaSign_interface/HTML_Report/suite1_test1_results.html
FloorTest.project=楼层
FloorTest.project=\u697C\u5C42
FloorTest.names=zhaoran,qianwenjun
FloorTest.group=楼层-接口自动化
FloorTest.group=\u697C\u5C42-\u63A5\u53E3\u81EA\u52A8\u5316
FloorTest.resultUrl=http://tst.deploy.dui88.com/view/duibaTest/job/duibaFloor_interface/HTML_Report/suite1_test1_results.html
DuibaTest.project=活动工具
DuibaTest.project=\u6D3B\u52A8\u5DE5\u5177
DuibaTest.names=zhaoran,qianwenjun
DuibaTest.group=活动工具-接口自动化
DuibaTest.group=\u6D3B\u52A8\u5DE5\u5177-\u63A5\u53E3\u81EA\u52A8\u5316
DuibaTest.resultUrl=http://tst.deploy.dui88.com/view/duibaTest/job/duiba_interface/HTML_Report/suite1_test1_results.html
AccessTest.project=综合业务(单品抽奖/秒杀/游戏)
AccessTest.project=\u7EFC\u5408\u4E1A\u52A1(\u5355\u54C1\u62BD\u5956/\u79D2\u6740/\u6E38\u620F)
AccessTest.names=zhaoran,qianwenjun
AccessTest.group=综合业务-接口自动化
AccessTest.group=\u7EFC\u5408\u4E1A\u52A1-\u63A5\u53E3\u81EA\u52A8\u5316
AccessTest.resultUrl=http://tst.deploy.dui88.com/view/duibaTest/job/duibaAccess_interface/HTML_Report/suite1_test1_results.html
JenkinsTest.project=综合业务(单品抽奖/秒杀/游戏)
JenkinsTest.project=\u7EFC\u5408\u4E1A\u52A1(\u5355\u54C1\u62BD\u5956/\u79D2\u6740/\u6E38\u620F)
JenkinsTest.names=zhaoran,qianwenjun
JenkinsTest.group=综合业务-接口自动化
JenkinsTest.group=\u7EFC\u5408\u4E1A\u52A1-\u63A5\u53E3\u81EA\u52A8\u5316
JenkinsTest.resultUrl=http://tst.deploy.dui88.com/view/duibaTest/job/duibaAccess_interface/HTML_Report/suite1_test1_results.html
ExchangeTest.project=普兑业务
ExchangeTest.project=\u666E\u5151\u4E1A\u52A1
ExchangeTest.names=panyuli
ExchangeTest.group=普兑业务-接口自动化
ExchangeTest.group=\u666E\u5151\u4E1A\u52A1-\u63A5\u53E3\u81EA\u52A8\u5316
ExchangeTest.resultUrl=http://tst.deploy.dui88.com/view/duibaTest/job/duibaExchange_interface/HTML_Report/suite1_test1_results.html
SeckillTest.project=秒杀业务
SeckillTest.project=\u79D2\u6740\u4E1A\u52A1
SeckillTest.names=qianwenjun
SeckillTest.group=秒杀业务-接口自动化
SeckillTest.group=\u79D2\u6740\u4E1A\u52A1-\u63A5\u53E3\u81EA\u52A8\u5316
SeckillTest.resultUrl=http://tst.deploy.dui88.com/view/duibaTest/job/Seckill_interface/HTML_Report/suite1_test1_results.html
\ 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