Commit 59a41de3 authored by 钱雯君's avatar 钱雯君

add

parent b3c64c71
/**
* Copyright (C), 2015-2018
* FileName: 集卡_出奖方式测试_DuibaTest
* Author: qianwenjun
* Date: 2018/3/6 20:29
* Description:
*/
package http.cases.CollectActivityTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.NewActivityService;
import http.service.Manager.EditManagerInfoService;
import http.service.Manager.GetManagerInfoService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/3/6
* @since 1.0.0
*/
public class 集卡_出奖方式测试_DuibaTest extends DuibaTestBase {
@Autowired
NewActivityService newActivityService;
@Autowired
GetManagerInfoService getManagerInfoService;
@Autowired
EditManagerInfoService editManagerInfoService;
private static DuibaLog logger = DuibaLog.getLogger();
@Test
public void 集卡_直接出奖_中奖() throws Exception {
//获取集卡活动配置的奖品信息
Response awardResponse = getManagerInfoService.getCollectAwardsInfo("239");
String data = awardResponse.jsonPath().getString("data.config.rewards[0]");
String awardsName = awardResponse.jsonPath().getString("data.config.rewards[0].rlName");
String awardsType = awardResponse.jsonPath().getString("data.config.rewards[0].rlType");
//自定义活动游戏 结果
Response response = playNewActivityResult("19929", "r3oq9gqkf", "239",2720);
//校验中奖结果类型
Assert.assertEquals(String.valueOf(response.jsonPath().getString("lottery.type")), "collectGoods", "校验中奖类型失败");
logger.info("校验中奖类型成功,自定义活动游戏中奖奖品类型为" + response.jsonPath().getString("lottery.type"));
//集卡获取信息
// Response collectGoodsInfo = newActivityService.getCollectGoodsInfo("239");
// logger.info("收集的中奖卡的信息如下:");
// collectGoodsInfo.prettyPrint();
//集卡结束后开奖--开奖类型:直接开奖
Response openResponse = playCollectResult("239", "19929",2720);
Assert.assertEquals(openResponse.jsonPath().getString("lottery.title"), awardsName, "校验奖项失败");
Assert.assertEquals(openResponse.jsonPath().getString("lottery.type"), awardsType, "校验奖项失败");
logger.info("校验活动中奖信息name和type成功,奖品信息为:" + openResponse.jsonPath().getString("lottery.title"));
}
@Test
public void 集卡_直接出奖_库存不足_不中奖() throws Exception {
//获取集卡活动配置的奖品信息
Response awardResponse = getManagerInfoService.getCollectAwardsInfo("242");
String data = awardResponse.jsonPath().getString("data.config.rewards[0]");
String awardsName = awardResponse.jsonPath().getString("data.config.rewards[0].name");
String awardsType = awardResponse.jsonPath().getString("data.config.rewards[0].rlType");
//自定义活动游戏 结果
Response response = playNewActivityResult("19932", "r3oq9gqkf", "4",2720);
Assert.assertEquals(String.valueOf(response.jsonPath().getString("lottery.type")), "collectGoods", "校验中奖类型失败");
logger.info("校验中奖奖品信息成功,自定义活动游戏中奖奖品类型" + response.jsonPath().getString("lottery.type"));
//集卡结束后开奖--开奖类型:直接开奖
Response openResponse = newActivityService.openCollectGoodsPrize2("242", "19932","服务器异常 请稍后再次领奖");
logger.info("集卡奖品缺货,开奖失败,校验错误信息成功,错误信息为" + openResponse.jsonPath().getString("message"));
}
@Test
public void 集卡_插件出奖_中奖() throws Exception {
//获取集卡活动配置的奖品信息--插件235的奖品信息
Response awardResponse = getManagerInfoService.getPluginInfo("235");
String data = awardResponse.jsonPath().getString("prizes");
String awardsDescription = awardResponse.jsonPath().getString("prizes[1].description");
String awardsType = awardResponse.jsonPath().getString("prizes[1].type");
//自定义活动游戏 结果
Response response = this.playNewActivityResult("19930", "r3oq9gqkf", "240",2720);
//校验中奖结果类型
Assert.assertEquals(String.valueOf(response.jsonPath().getString("lottery.type")), "collectGoods", "校验中奖类型失败");
logger.info("校验中奖奖品类型成功,自定义活动游戏中奖奖品类型" + response.jsonPath().getString("lottery.type"));
Response openResponse = this.playCollectResult("240", "19930",2720);
Assert.assertEquals(openResponse.jsonPath().getString("lottery.title"), awardsDescription, "校验奖项失败");
Assert.assertEquals(openResponse.jsonPath().getString("lottery.type"), awardsType, "校验奖项失败");
Assert.assertTrue(openResponse.jsonPath().getString("lottery.link").contains("/activity/takePrizeNew?recordId"));
logger.info("集卡开奖奖品类型校验成功,奖品信息为:" + openResponse.jsonPath().getString("lottery.title"));
}
@Test
public void 集卡_插件出奖_缺货_不中奖() throws Exception {
//获取集卡活动配置的奖品信息--插件235的奖品信息
Response awardResponse = getManagerInfoService.getPluginInfo("240");
String data = awardResponse.jsonPath().getString("prizes");
String awardsDescription = awardResponse.jsonPath().getString("prizes[0].description");
String awardsType = awardResponse.jsonPath().getString("prizes[0].type");
//自定义活动游戏 结果
Response response = this.playNewActivityResult("19931", "r3oq9gqkf", "241",2720);
//校验中奖结果类型
Assert.assertEquals(String.valueOf(response.jsonPath().getString("lottery.type")), "collectGoods", "校验中奖类型失败");
logger.info("校验中奖奖品类型成功,自定义活动游戏中奖奖品类型" + response.jsonPath().getString("lottery.type"));
Response openResponse = this.playCollectResult("241", "19931",2720);
Assert.assertEquals(openResponse.jsonPath().getString("lottery.type"), awardsType, "校验奖项失败");
logger.info("校验奖品信息type成功, 奖品信息为:" + openResponse.jsonPath().getString("lottery.type"));
}
public Response playNewActivityResult(String activityId, String token, String collectRuleId,Integer uid) throws Exception {
Response response = newActivityService.doJoin4(activityId, token, collectRuleId, uid);
Response playResponse = response;
//playResponse.prettyPrint();
String orderId = playResponse.jsonPath().getString("orderId");
Response statusResponse = newActivityService.getOrderStatus21(orderId,uid);
// statusResponse.prettyPrint();
String playResult = statusResponse.jsonPath().getString("result");
int i = 30;
while (i > 0 && (playResult.equals("0"))) {
Thread.sleep(1000);
statusResponse = newActivityService.getOrderStatus21(orderId,uid);
// statusResponse.prettyPrint();
playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
i--;
// statusResponse.prettyPrint();
}
return statusResponse;
}
public Response playCollectResult(String collectRuleId, String activityId,Integer uid) throws Exception {
Response openResponse = newActivityService.openCollectGoodsPrize3(collectRuleId, activityId,uid);
// openResponse.prettyPrint();
String orderId = openResponse.jsonPath().getString("orderId");
Response statusResponse = newActivityService.getOrderStatus31(orderId,uid);
// logger.info("开奖结果如下1:");
// statusResponse.prettyPrint();
String playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
int i = 8;
while (i > 0 && (playResult.equals("0"))) {
Thread.sleep(1000);
statusResponse = newActivityService.getOrderStatus31(orderId,uid);
playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
i--;
// logger.info("开奖结果如下2:");
// statusResponse.prettyPrint();
}
return statusResponse;
}
}
\ No newline at end of file
package http.cases.CollectActivityTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
/**
* 〈集卡助力抽奖〉
*
* @author zhaoran
* @create 2018/07/04
* @since 1.0.0
*/
public class 集卡_助力集卡测试_DuibaTest extends DuibaTestBase {
@Autowired
NewActivityService newActivityService;
@Autowired
ManagerService managerService;
private static DuibaLog logger = DuibaLog.getLogger();
// private MysqlUtils jdbc;
private static String shareCode;
@BeforeMethod
//获取2720用户书旗活动邀请码
public void before() throws Exception {
shareCode=null;
Response response = newActivityService.getShareCode("25902","hdtool");
shareCode = String.valueOf(response.jsonPath().getString("shareCode"));
logger.info("2720用户书旗活动邀请码为:"+shareCode);
// jdbc = MysqlUtils.mysqlDuiba("act_com_conf");
try {
jdbc.update("delete from act_com_conf.tb_share_code_record where invited_consumer_id = '100028002' and share_code = '11nknk8'", null);
} catch (Exception e) {
e.printStackTrace();
}
}
// @AfterClass
// public void after(){
// jdbc.releaseConn();
// }
@DataProvider
public Object[][] providerMethod(Method method){
Object[][] result = null;
if(method.getName().equals("助力集卡抽奖")) {
result = new Object[][]{
new Object[]{1, 2720, "自己为自己助力"},
new Object[]{2, 2721, "他人为自己重复助力"},
new Object[]{3, 2721, "分享码无效"},
new Object[]{4, 2722, "分享助力成功抽卡"}
};
}
return result;
}
@Test(dataProvider = "providerMethod")
public void 助力集卡抽奖(int casenum,int userId,String casename) throws Exception {
logger.info("-------------------------------------"+casename+"-------------------------------------");
logger.info("2720用户书旗活动邀请码为:"+shareCode);
Assert.assertEquals(shareCode, "11nknk8", "校验shareCode失败");
//获取2720用户集卡信息
Response response = newActivityService.getCollectGoodsInfo("2364");
String count = String.valueOf(response.jsonPath().getString("collectGoods[3].count"));
logger.info("助力前2720用户修仙卡数量为:"+count);
count = String.valueOf(Integer.valueOf(count)+1);
//根据case选择对应的校验项
switch(casenum){
case 1:
response = newActivityService.helpShareCodeV2(userId,"780","25902","hdtool",shareCode);
Assert.assertEquals(response.jsonPath().getString("errorCode"),"100005","校验errorCode失败");
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
Assert.assertEquals(response.jsonPath().getString("message"),"不能为自己助力,请输入他人的分享码!","校验message失败");
logger.info("校验项:errorCode,message,success成功");
break;
case 2:
response = newActivityService.helpShareCodeV2(userId,"780","25902","hdtool",shareCode);
Assert.assertEquals(response.jsonPath().getString("errorCode"),"100007","校验errorCode失败");
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
Assert.assertEquals(response.jsonPath().getString("message"),"不能重复助力!","校验message失败");
logger.info("校验项:errorCode,message,success成功");
break;
case 3:
response = newActivityService.helpShareCodeV2(userId,"780","25902","hdtool","asdasfsadsad");
Assert.assertEquals(response.jsonPath().getString("errorCode"),"100006","校验errorCode失败");
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
Assert.assertEquals(response.jsonPath().getString("message"),"分享码无效,请输入正确的分享码!","校验message失败");
logger.info("校验项:errorCode,message,success成功");
break;
case 4:
response = newActivityService.helpShareCodeV2(userId,"780","25902","hdtool",shareCode);
//logger.info("XXXXXXXXX"+response.asString());
Assert.assertEquals(response.jsonPath().getString("itmeId"),"29085","校验itmeId失败");
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验success失败");
Assert.assertEquals(response.jsonPath().getString("message"),"请求成功","校验message失败");
logger.info("校验项:itmeId,message,success成功,助力出卡成功");
//获取2720用户集卡信息
response = newActivityService.getCollectGoodsInfo("2364");
String countNew = String.valueOf(response.jsonPath().getString("collectGoods[3].count"));
logger.info("助力后2720用户修仙卡数量为:"+countNew);
Assert.assertEquals(countNew,count,"分享助力出卡未加上分享者账号");
break;
}
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: 集卡_多奖项_用户中奖限制测试_DuibaTest
* Author: qianwenjun
* Date: 2018/3/14 21:01
* Description: 多奖项-中奖限制测试
*/
package http.cases.CollectActivityTest;
import base.DuibaLog;
import base.DuibaTestBase;
import cn.com.duiba.activity.center.api.dto.activity.CLRewardDto;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import http.model.CollectGoodsInfo;
import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService;
import http.service.Manager.EditManagerInfoService;
import http.service.Manager.GetManagerInfoService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import java.util.List;
/**
* 〈多奖项-中奖限制测试〉
*
* @author qianwenjun
* @create 2018/3/14
* @since 1.0.0
*/
public class 集卡_多奖项_用户中奖限制测试 extends DuibaTestBase {
@Autowired
NewActivityService newActivityService;
@Autowired
ManagerService managerService;
@Autowired
GetManagerInfoService getManagerInfoService;
@Autowired
EditManagerInfoService editManagerInfoService;
private static DuibaLog logger = DuibaLog.getLogger();
// @BeforeMethod
//每个方法之前清理数据库数据,保证无脏数据影响测试结果
public void clearDb() {
try {
Boolean clearResult1 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey like '%activity-centerwinOptionNum_100025007_19934_hdtool%'",null);
Boolean clearResult2 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey like '%cl_good_cid_Crule_grade_100025007_244%'",null);
Boolean clearResult3 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey in ('cl_good_cid_itemId_100025007_27218','cl_good_cid_itemId_100025007_27219')",null);
Boolean clearResult4 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey = 'activity-centerjoinNum_100025007_19934'",null);
} catch (Exception e) {
e.printStackTrace();
}
}
//规则id=244,设置多奖项开关-打开
//奖项:1-集卡6;2-集卡7
//用例设计:
//第一次游戏中奖-奖项1
//校验点:1、奖项2不能中奖,7卡不能收集,只能中谢谢参与
@Test
public void 集卡_多奖项_中奖限制测试() throws Exception{
//获取集卡活动配置的奖品信息
Response awardResponse = getManagerInfoService.getCollectAwardsInfo("244");
List<CLRewardDto> cLRewards = awardResponse.jsonPath().getJsonObject("data.config.rewards");
CLRewardDto cLReward0 = JSONObject.parseObject(JSON.toJSONString(cLRewards.get(1)),CLRewardDto.class);
logger.info("奖品信息"+cLReward0);
Response response = playNewActivityResult("19934", "r3oq9gqkf", "244",2720);
Assert.assertEquals(String.valueOf(response.jsonPath().getString("lottery.type")), "collectGoods", "校验中奖类型失败");
logger.info("中奖卡片id为"+response.jsonPath().getString("lottery.itemId"));
Response myCollectInfoResponse = newActivityService.getCollectGoodsInfo2("244",2720);
List<CollectGoodsInfo> myCollectInfos = myCollectInfoResponse.jsonPath().getList("collectGoods",CollectGoodsInfo.class);
logger.info("myCollectInfo的信息为"+JSON.toJSONString(myCollectInfos));
Response openResponse = playCollectResult("244", "19934",2720);
Assert.assertEquals(openResponse.jsonPath().getString("lottery.title"), cLReward0.getName(), "校验奖项失败");
Assert.assertEquals(openResponse.jsonPath().getString("lottery.type"), cLReward0.getRlType(), "校验奖项失败");
//
// for(int i=0;i<2;i++){
// if (i==0){
// //第一次中集卡商品A,开奖得到奖项1的奖品
// Response response = playNewActivityResult("19934", "r3oq9gqkf", "244",2721);
// Assert.assertEquals(String.valueOf(response.jsonPath().getString("lottery.type")), "collectGoods", "校验中奖类型失败");
// //集卡获取信息
// Response collectGoodsInfo = newActivityService.getCollectGoodsInfo("244");
// logger.info("收集的中奖卡的信息如下:");
// collectGoodsInfo.prettyPrint();
//// 集卡结束后开奖--开奖类型:直接开奖
// Response openResponse = playCollectResult("244", "19934",2721);
// Assert.assertEquals(openResponse.jsonPath().getString("lottery.title"), cLReward0.getRlName(), "校验奖项失败");
// Assert.assertEquals(openResponse.jsonPath().getString("lottery.type"), cLReward0.getRlType(), "校验奖项失败");
//
// logger.info("校验集卡活动中奖项1信息成功,奖品信息为:" + openResponse.jsonPath().getString("lottery.title"));
// }else if (i==1){
// Response setResponse = editManagerInfoService.
// saveCustomHdtool3("3949", "【勿动】自动化-集卡-多奖项限制测试", "129","14154",
// "27218_0_A6_【勿动】自动化-集卡商品-A6_14155",
// "27219_100_A7_【勿动】自动化-集卡商品-A7_14156");
// Thread.sleep(60000);
// Response response = playNewActivityResult("19934", "r3oq9gqkf", "244",2721);
// String type = String.valueOf(response.jsonPath().getString("lottery.type"));
// Assert.assertTrue((type.contains("thanks"))||(type.contains("lucky")));
// logger.info("校验多奖项限制,第二次抽奖奖品为谢谢参与成功,奖品类型为" + response.jsonPath().getString("lottery.type"));
// }
//
// }
// //为第二次循环执行准备
// Response setResponse = editManagerInfoService.
// saveCustomHdtool3("3949", "【勿动】自动化-集卡-多奖项限制测试", "129","14154",
// "27218_100_A6_【勿动】自动化-集卡商品-A6_14155",
// "27219_0_A7_【勿动】自动化-集卡商品-A7_14156");
// Thread.sleep(60000);
}
public Response playNewActivityResult(String activityId, String token, String collectRuleId,Integer uid) throws Exception {
Response response = newActivityService.doJoin4(activityId, token, collectRuleId, uid);
Response playResponse = response;
// playResponse.prettyPrint();
String orderId = playResponse.jsonPath().getString("orderId");
Response statusResponse = newActivityService.getOrderStatus21(orderId,uid);
statusResponse.prettyPrint();
String playResult = statusResponse.jsonPath().getString("result");
int i = 8;
while (i > 0 && (playResult.equals("0"))) {
Thread.sleep(1000);
statusResponse = newActivityService.getOrderStatus21(orderId,uid);
playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
i--;
// statusResponse.prettyPrint();
}
return statusResponse;
}
public Response playCollectResult(String collectRuleId, String activityId,Integer uid) throws Exception {
Response openResponse = newActivityService.openCollectGoodsPrize3(collectRuleId, activityId,uid);
openResponse.prettyPrint();
String orderId = openResponse.jsonPath().getString("orderId");
Response statusResponse = newActivityService.getOrderStatus31(orderId,uid);
// logger.info("开奖结果如下1:");
// statusResponse.prettyPrint();
String playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
int i = 8;
while (i > 0 && (playResult.equals("0"))) {
Thread.sleep(1000);
statusResponse = newActivityService.getOrderStatus31(orderId,uid);
playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
i--;
// logger.info("开奖结果如下2:");
// statusResponse.prettyPrint();
}
return statusResponse;
}
@AfterMethod
//每个方法之前清理数据库数据,保证无脏数据影响测试结果
public void tearDb() {
try {
Boolean clearResult1 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey like '%activity-centerwinOptionNum_100025007_19934_hdtool%'",null);
Boolean clearResult2 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey like '%cl_good_cid_Crule_grade_100025007_244%'",null);
Boolean clearResult3 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey in ('cl_good_cid_itemId_100025007_27218','cl_good_cid_itemId_100025007_27219')",null);
Boolean clearResult4 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey = 'activity-centerjoinNum_100025007_19934'",null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: 集卡_指定卡片_不同奖项中奖条件测试
* Author: qianwenjun
* Date: 2018/3/13 17:06
* Description: 设置不同条件-中奖
*/
package http.cases.CollectActivityTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.NewActivityService;
import http.service.Manager.EditManagerInfoService;
import http.service.Manager.GetManagerInfoService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
* 〈设置不同条件-中奖〉
*
* @author qianwenjun
* @create 2018/3/13
* @since 1.0.0
*/
public class 集卡_指定卡片_DuibaTest extends DuibaTestBase {
@Autowired
NewActivityService newActivityService;
@Autowired
GetManagerInfoService getManagerInfoService;
@Autowired
EditManagerInfoService editManagerInfoService;
private static DuibaLog logger = DuibaLog.getLogger();
@BeforeMethod
//每个方法之前清理数据库数据,保证无脏数据影响测试结果
public void clearDb() {
try {
Boolean clearResult1 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey like '%activity-centerwinOptionNum_100025007_19936_hdtool%'",null);
Boolean clearResult2 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey like '%cl_good_cid_Crule_grade_100025007_246%'",null);
Boolean clearResult3 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey in ('cl_good_cid_itemId_100025007_27221')",null);
Boolean clearResult4 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey = 'activity-centerjoinNum_100025007_19936'",null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void 集卡_中奖条件集卡A_3() throws Exception {
//获取集卡活动配置的奖品信息
Response awardResponse = getManagerInfoService.getCollectAwardsInfo("246");
String data = awardResponse.jsonPath().getString("data.config.rewards[0]");
String awardsName = awardResponse.jsonPath().getString("data.config.rewards[0].rlName");//"【勿动】自动化测试虚拟商品"
String awardsType = awardResponse.jsonPath().getString("data.config.rewards[0].rlType");//virtual
//自定义活动游戏 结果
for(int i=0;i<3;i++) {
Response response = playNewActivityResult("19936", "r3oq9gqkf", "246");
//校验中奖结果类型
Assert.assertEquals(String.valueOf(response.jsonPath().getString("lottery.type")), "collectGoods", "校验中奖类型失败");
logger.info("校验中奖奖品类型成功,自定义活动游戏中奖奖品类型" + response.jsonPath().getString("lottery.type"));
}
// Thread.sleep(8000);
Response collectGoodsInfoResponse = newActivityService.getCollectGoodsInfo2("246",2720);
collectGoodsInfoResponse.prettyPrint();
//集卡结束后开奖--开奖类型:直接开奖
Response openResponse = playCollectResult("246", "19936");
Assert.assertEquals(openResponse.jsonPath().getString("lottery.title"), awardsName, "校验奖项失败");
Assert.assertEquals(openResponse.jsonPath().getString("lottery.type"), awardsType, "校验奖项失败");
logger.info("校验集卡抽奖奖项type、name成功,奖品信息为:" + openResponse.jsonPath().getString("lottery.title"));
}
@Test
public void 集卡_不满足开奖条件() throws Exception{
for(int i=0;i<1;i++){
Response response = playNewActivityResult("19936", "r3oq9gqkf", "246");
//校验中奖结果类型
Assert.assertEquals(String.valueOf(response.jsonPath().getString("lottery.type")), "collectGoods", "校验中奖类型失败");
logger.info("校验中奖奖品类型成功,自定义活动游戏中奖奖品类型" + response.jsonPath().getString("lottery.type"));
}
//集卡结束后开奖--开奖类型:直接开奖
Response openResponse = newActivityService.openCollectGoodsPrize2("246", "19936","未满足 中奖条件");
openResponse.prettyPrint();
logger.info("开奖结果是:" + openResponse.jsonPath().getString("lottery.message"));
}
public Response playNewActivityResult(String activityId, String token, String collectRuleId) throws Exception {
Response playResponse = newActivityService.doJoin3(activityId, token, collectRuleId);
playResponse.prettyPrint();
String orderId = playResponse.jsonPath().getString("orderId");
Response statusResponse = newActivityService.getOrderStatus2(orderId);
// statusResponse.prettyPrint();
String playResult = statusResponse.jsonPath().getString("result");
int i = 30;
while (i > 0 && (playResult.equals("0"))) {
Thread.sleep(1000);
statusResponse = newActivityService.getOrderStatus2(orderId);
playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
i--;
// statusResponse.prettyPrint();
}
return statusResponse;
}
public Response playCollectResult(String collectRuleId, String activityId) throws Exception {
Response openResponse = newActivityService.openCollectGoodsPrize(collectRuleId, activityId);
openResponse.prettyPrint();
String orderId = openResponse.jsonPath().getString("orderId");
Response statusResponse = newActivityService.getOrderStatus3(orderId);
// logger.info("开奖结果如下1:");
// statusResponse.prettyPrint();
String playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
int i = 30;
while (i > 0 && (playResult.equals("0"))) {
Thread.sleep(1000);
statusResponse = newActivityService.getOrderStatus3(orderId);
playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
i--;
// logger.info("开奖结果如下2:");
// statusResponse.prettyPrint();
}
return statusResponse;
}
// @AfterMethod
//每个方法之前清理数据库数据,保证无脏数据影响测试结果
public void tearDb() {
try {
Boolean clearResult1 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey like '%activity-centerwinOptionNum_100025007_19936_hdtool%'",null);
Boolean clearResult2 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey like '%cl_good_cid_Crule_grade_100025007_246%'",null);
Boolean clearResult3 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey in ('cl_good_cid_itemId_100025007_27221')",null);
Boolean clearResult4 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey = 'activity-centerjoinNum_100025007_19936'",null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: 集卡_指定卡片_不同奖项中奖条件测试
* Author: qianwenjun
* Date: 2018/3/13 17:06
* Description: 设置不同条件-中奖
*/
package http.cases.CollectActivityTest;
import base.DuibaLog;
import base.DuibaTestBase;
import com.alibaba.fastjson.JSON;
import http.model.CollectGoodsInfo;
import http.service.Activity.NewActivityService;
import http.service.Manager.EditManagerInfoService;
import http.service.Manager.GetManagerInfoService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.List;
/**
* 〈设置不同条件-中奖〉
*
* @author qianwenjun
* @create 2018/3/13
* @since 1.0.0
*/
public class 集卡_随机卡片_DuibaTest extends DuibaTestBase {
@Autowired
NewActivityService newActivityService;
@Autowired
GetManagerInfoService getManagerInfoService;
@Autowired
EditManagerInfoService editManagerInfoService;
private static DuibaLog logger = DuibaLog.getLogger();
@BeforeMethod
//每个方法之前清理数据库数据,保证无脏数据影响测试结果
public void clearDb() {
try {
Boolean clearResult2 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey like '%cl_good_cid_Crule_grade_100025007_247%'",null);
Boolean clearResult3 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey in ('cl_good_cid_itemId_100025007_27222','cl_good_cid_itemId_100025007_27223')",null);
Boolean clearResult4 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey = 'activity-centerjoinNum_100025007_19937'",null);
Boolean clearResult1 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey in ('cl_good_cid_itemId_100025007_27226')",null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void 集卡_中奖条件随机卡_2() throws Exception {
//获取集卡活动配置的奖品信息
Response awardResponse = getManagerInfoService.getCollectAwardsInfo("247");
String data = awardResponse.jsonPath().getString("data.config.rewards[0]");
String awardsName = awardResponse.jsonPath().getString("data.config.rewards[0].rlName");//"【勿动】自动化测试虚拟商品"
String awardsType = awardResponse.jsonPath().getString("data.config.rewards[0].rlType");//virtual
//自定义活动游戏 结果
Response playResponse = playNewActivityResult("19937", "r3oq9gqkf", "247");
playResponse.prettyPrint();
//校验中奖结果类型
String itemId= playResponse.jsonPath().getString("lottery.itemId");
Assert.assertEquals(String.valueOf(playResponse.jsonPath().getString("lottery.type")), "collectGoods", "校验中奖类型失败");
logger.info("校验中奖奖品类型成功,自定义活动游戏中奖奖品类型" + playResponse.jsonPath().getString("lottery.type"));
logger.info("中奖卡片id为" + itemId);
Response myCollectInfoResponse = newActivityService.getCollectGoodsInfo2("247",2720);
List<CollectGoodsInfo> myCollectInfos = myCollectInfoResponse.jsonPath().getList("collectGoods",CollectGoodsInfo.class);
logger.info("myCollectInfo的信息为"+JSON.toJSONString(myCollectInfos));
for (CollectGoodsInfo info:myCollectInfos){
if (info.getId().equals(itemId)){
Assert.assertEquals(info.getCount(),"1","校验卡片数量失败");
}else {
break;
}
}
//集卡结束后开奖--开奖类型:直接开奖
Response openResponse = playCollectResult("247", "19937");
Assert.assertEquals(openResponse.jsonPath().getString("lottery.title"), awardsName, "校验奖项失败");
Assert.assertEquals(openResponse.jsonPath().getString("lottery.type"), awardsType, "校验奖项失败");
logger.info("校验集卡抽奖奖项type、name成功,奖品信息为:" + openResponse.jsonPath().getString("lottery.title"));
Response myCollectInfoResponse2 = newActivityService.getCollectGoodsInfo2("247",2720);
List<CollectGoodsInfo> myCollectInfos2 = myCollectInfoResponse2.jsonPath().getList("collectGoods",CollectGoodsInfo.class);
logger.info("开奖之后,myCollectInfo的信息为"+JSON.toJSONString(myCollectInfos2));
for (CollectGoodsInfo info:myCollectInfos2){
if (info.getId().equals(itemId)){
Assert.assertEquals(info.getCount(),"0","校验开奖后卡片数量减少失败");
}else {
break;
}
}
}
@Test
public void 集卡_随机卡_不满足开奖条件() throws Exception{
String itemId = null;
for(int i=0;i<2;i++){
Response playResponse = playNewActivityResult("19938", "r3oq9gqkf", "248");
//校验中奖结果类型
itemId= playResponse.jsonPath().getString("lottery.itemId");
Assert.assertEquals(String.valueOf(playResponse.jsonPath().getString("lottery.type")), "collectGoods", "校验中奖类型失败");
logger.info("校验中奖奖品类型成功,自定义活动游戏中奖奖品类型" + playResponse.jsonPath().getString("lottery.type"));
logger.info("中奖卡片id为" + itemId);
}
Response myCollectInfoResponse = newActivityService.getCollectGoodsInfo2("248",2720);
List<CollectGoodsInfo> myCollectInfos = myCollectInfoResponse.jsonPath().getList("collectGoods",CollectGoodsInfo.class);
logger.info("myCollectInfo的信息为"+JSON.toJSONString(myCollectInfos));
for (CollectGoodsInfo info:myCollectInfos){
if (info.getId().equals(itemId)){
Assert.assertEquals(info.getCount(),"2","校验卡片数量失败");
}else {
break;
}
}
//集卡结束后开奖--开奖类型:直接开奖
Response openResponse = newActivityService.openCollectGoodsPrize2("248", "19938","未满足 中奖条件");
openResponse.prettyPrint();
logger.info("开奖结果是:" + openResponse.jsonPath().getString("lottery.message"));
}
public Response playNewActivityResult(String activityId, String token, String collectRuleId) throws Exception {
Response playResponse = newActivityService.doJoin3(activityId, token, collectRuleId);
playResponse.prettyPrint();
String orderId = playResponse.jsonPath().getString("orderId");
Response statusResponse = newActivityService.getOrderStatus2(orderId);
// statusResponse.prettyPrint();
String playResult = statusResponse.jsonPath().getString("result");
int i = 8;
while (i > 0 && (playResult.equals("0"))) {
Thread.sleep(1000);
statusResponse = newActivityService.getOrderStatus2(orderId);
playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
i--;
// statusResponse.prettyPrint();
}
return statusResponse;
}
public Response playCollectResult(String collectRuleId, String activityId) throws Exception {
Response openResponse = newActivityService.openCollectGoodsPrize(collectRuleId, activityId);
openResponse.prettyPrint();
String orderId = openResponse.jsonPath().getString("orderId");
Response statusResponse = newActivityService.getOrderStatus3(orderId);
// logger.info("开奖结果如下1:");
// statusResponse.prettyPrint();
String playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
int i = 8;
while (i > 0 && (playResult.equals("0"))) {
Thread.sleep(1000);
statusResponse = newActivityService.getOrderStatus3(orderId);
playResult = String.valueOf(statusResponse.jsonPath().getString("result"));
i--;
// logger.info("开奖结果如下2:");
// statusResponse.prettyPrint();
}
return statusResponse;
}
// @AfterMethod
//每个方法之前清理数据库数据,保证无脏数据影响测试结果
public void tearDb() {
try {
//清除自定义活动-中奖奖品数量信息(5种)
Boolean clearResult1 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey like '%activity-centerwinOptionNum_100025007_19123_hdtool%'",null);
//清除集卡规则n等级奖项-中奖次数(集卡规则id:8)
Boolean clearResult2 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey like '%cl_good_cid_Crule_grade_100025007_8%'",null);
//清除收集的集卡商品数量(集卡商品id:27148,27147,27146,27145,27144)
Boolean clearResult3 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey in ('cl_good_cid_itemId_100025007_27154','cl_good_cid_itemId_100025007_27155','cl_good_cid_itemId_100025007_27156','cl_good_cid_itemId_100025007_27157','cl_good_cid_itemId_100025007_27158')",null);
//清除用户参与活动次数(活动id:19009)
Boolean clearResult4 = jdbc.update("delete from ckvtable.tb_kvtable_0687 where consumer_id = 100025007 and vkey = 'activity-centerjoinNum_100025007_19123'",null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
\ No newline at end of file
/** /**
* Copyright (C), 2015-2018 * Copyright (C), 2015-2018
* FileName: 兑吧_优惠券秒杀商品兑换测试_AccessTest * FileName: 兑吧_优惠券秒杀商品兑换测试_ScekillTest
* Author: qianwenjun * Author: qianwenjun
* Date: 2018/5/31 17:57 * Date: 2018/5/31 17:57
* Description: 开发者自有秒杀商品测试 * Description: 开发者自有秒杀商品测试
...@@ -29,7 +29,7 @@ import java.util.Map; ...@@ -29,7 +29,7 @@ import java.util.Map;
* @create 2018/5/31 * @create 2018/5/31
* @since 1.0.0 * @since 1.0.0
*/ */
public class 兑吧_优惠券秒杀商品兑换测试_AccessTest extends DuibaTestBase { public class 兑吧_优惠券秒杀商品兑换测试_ScekillTest extends DuibaTestBase {
@Autowired @Autowired
......
/** /**
* Copyright (C), 2015-2018 * Copyright (C), 2015-2018
* FileName: 兑吧_优惠券秒杀商品兑换测试_AccessTest * FileName: 兑吧_优惠券秒杀商品兑换测试_ScekillTest
* Author: qianwenjun * Author: qianwenjun
* Date: 2018/5/31 17:57 * Date: 2018/5/31 17:57
* Description: 开发者自有秒杀商品测试 * Description: 开发者自有秒杀商品测试
...@@ -29,7 +29,7 @@ import java.util.Map; ...@@ -29,7 +29,7 @@ import java.util.Map;
* @create 2018/5/31 * @create 2018/5/31
* @since 1.0.0 * @since 1.0.0
*/ */
public class 兑吧_实物秒杀商品兑换测试_AccessTest extends DuibaTestBase { public class 兑吧_实物秒杀商品兑换测试_ScekillTest extends DuibaTestBase {
@Autowired @Autowired
......
/** /**
* Copyright (C), 2015-2018 * Copyright (C), 2015-2018
* FileName: 天天秒杀_秒杀活动兑换测试_AccessTest * FileName: 天天秒杀_秒杀活动兑换测试_ScekillTest
* Author: qianwenjun * Author: qianwenjun
* Date: 2018/6/20 20:38 * Date: 2018/6/20 20:38
* Description: * Description:
...@@ -37,7 +37,7 @@ import static io.restassured.RestAssured.given; ...@@ -37,7 +37,7 @@ import static io.restassured.RestAssured.given;
* @create 2018/6/20 * @create 2018/6/20
* @since 1.0.0 * @since 1.0.0
*/ */
public class 天天秒杀_秒杀活动兑换测试_AccessTest extends DuibaTestBase { public class 天天秒杀_秒杀活动兑换测试_ScekillTest extends DuibaTestBase {
@Autowired @Autowired
SeckillService seckillService; SeckillService seckillService;
......
/** /**
* Copyright (C), 2015-2018 * Copyright (C), 2015-2018
* FileName: 天天秒杀_秒杀详情测试_AccessTest * FileName: 天天秒杀_秒杀详情测试_ScekillTest
* Author: qianwenjun * Author: qianwenjun
* Date: 2018/6/20 11:46 * Date: 2018/6/20 11:46
* Description: * Description:
...@@ -36,7 +36,7 @@ import static io.restassured.RestAssured.given; ...@@ -36,7 +36,7 @@ import static io.restassured.RestAssured.given;
* @create 2018/6/20 * @create 2018/6/20
* @since 1.0.0 * @since 1.0.0
*/ */
public class 天天秒杀_秒杀详情测试_AccessTest extends DuibaTestBase { public class 天天秒杀_秒杀详情测试_ScekillTest extends DuibaTestBase {
@Autowired @Autowired
SeckillService seckillService; SeckillService seckillService;
......
/** /**
* Copyright (C), 2015-2018 * Copyright (C), 2015-2018
* FileName: 秒杀_秒杀商品详情测试_AccessTest * FileName: 秒杀_秒杀商品详情测试_ScekillTest
* Author: qianwenjun * Author: qianwenjun
* Date: 2018/5/31 19:19 * Date: 2018/5/31 19:19
* Description: * Description:
...@@ -27,7 +27,7 @@ import utils.MatcherString; ...@@ -27,7 +27,7 @@ import utils.MatcherString;
* @create 2018/5/31 * @create 2018/5/31
* @since 1.0.0 * @since 1.0.0
*/ */
public class 秒杀_秒杀商品详情测试_AccessTest extends DuibaTestBase { public class 秒杀_秒杀商品详情测试_ScekillTest extends DuibaTestBase {
@Autowired @Autowired
SeckillService seckillService; SeckillService seckillService;
......
/** /**
* Copyright (C), 2015-2018 * Copyright (C), 2015-2018
* FileName: 兑吧_优惠券秒杀商品兑换测试_AccessTest * FileName: 兑吧_优惠券秒杀商品兑换测试_ScekillTest
* Author: qianwenjun * Author: qianwenjun
* Date: 2018/5/31 17:57 * Date: 2018/5/31 17:57
* Description: 开发者自有秒杀商品测试 * Description: 开发者自有秒杀商品测试
...@@ -29,7 +29,7 @@ import java.util.Map; ...@@ -29,7 +29,7 @@ import java.util.Map;
* @create 2018/5/31 * @create 2018/5/31
* @since 1.0.0 * @since 1.0.0
*/ */
public class 秒杀商品_兑换异常库存不足测试_AccessTest extends DuibaTestBase { public class 秒杀商品_兑换异常库存不足测试_ScekillTest extends DuibaTestBase {
@Autowired @Autowired
......
/** /**
* Copyright (C), 2015-2018 * Copyright (C), 2015-2018
* FileName: 兑吧_优惠券秒杀商品兑换测试_AccessTest * FileName: 兑吧_优惠券秒杀商品兑换测试_ScekillTest
* Author: qianwenjun * Author: qianwenjun
* Date: 2018/5/31 17:57 * Date: 2018/5/31 17:57
* Description: 开发者自有秒杀商品测试 * Description: 开发者自有秒杀商品测试
...@@ -27,7 +27,7 @@ import utils.MatcherString; ...@@ -27,7 +27,7 @@ import utils.MatcherString;
* @create 2018/5/31 * @create 2018/5/31
* @since 1.0.0 * @since 1.0.0
*/ */
public class 秒杀商品_地址限制兑换异常测试_AccessTest extends DuibaTestBase { public class 秒杀商品_地址限制兑换异常测试_ScekillTest extends DuibaTestBase {
@Autowired @Autowired
......
/** /**
* Copyright (C), 2015-2018 * Copyright (C), 2015-2018
* FileName: 兑吧_优惠券秒杀商品兑换测试_AccessTest * FileName: 兑吧_优惠券秒杀商品兑换测试_ScekillTest
* Author: qianwenjun * Author: qianwenjun
* Date: 2018/5/31 17:57 * Date: 2018/5/31 17:57
* Description: 开发者自有秒杀商品测试 * Description: 开发者自有秒杀商品测试
...@@ -29,7 +29,7 @@ import java.util.Map; ...@@ -29,7 +29,7 @@ import java.util.Map;
* @create 2018/5/31 * @create 2018/5/31
* @since 1.0.0 * @since 1.0.0
*/ */
public class 秒杀商品_达到兑换限制异常测试_AccessTest extends DuibaTestBase { public class 秒杀商品_达到兑换限制异常测试_ScekillTest extends DuibaTestBase {
@Autowired @Autowired
......
/** /**
* Copyright (C), 2015-2018 * Copyright (C), 2015-2018
* FileName: 兑吧_优惠券秒杀商品兑换测试_AccessTest * FileName: 兑吧_优惠券秒杀商品兑换测试_ScekillTest
* Author: qianwenjun * Author: qianwenjun
* Date: 2018/5/31 17:57 * Date: 2018/5/31 17:57
* Description: 开发者自有秒杀商品测试 * Description: 开发者自有秒杀商品测试
...@@ -29,7 +29,7 @@ import java.util.Map; ...@@ -29,7 +29,7 @@ import java.util.Map;
* @create 2018/5/31 * @create 2018/5/31
* @since 1.0.0 * @since 1.0.0
*/ */
public class 自有_优惠券秒杀商品兑换测试_AccessTest extends DuibaTestBase { public class 自有_优惠券秒杀商品兑换测试_ScekillTest extends DuibaTestBase {
@Autowired @Autowired
......
/** /**
* Copyright (C), 2015-2018 * Copyright (C), 2015-2018
* FileName: 兑吧_优惠券秒杀商品兑换测试_AccessTest * FileName: 兑吧_优惠券秒杀商品兑换测试_ScekillTest
* Author: qianwenjun * Author: qianwenjun
* Date: 2018/5/31 17:57 * Date: 2018/5/31 17:57
* Description: 开发者自有秒杀商品测试 * Description: 开发者自有秒杀商品测试
...@@ -29,7 +29,7 @@ import java.util.Map; ...@@ -29,7 +29,7 @@ import java.util.Map;
* @create 2018/5/31 * @create 2018/5/31
* @since 1.0.0 * @since 1.0.0
*/ */
public class 自有_实物秒杀商品兑换测试_AccessTest extends DuibaTestBase { public class 自有_实物秒杀商品兑换测试_ScekillTest extends DuibaTestBase {
@Autowired @Autowired
......
/** /**
* Copyright (C), 2015-2018 * Copyright (C), 2015-2018
* FileName: 兑吧_优惠券秒杀商品兑换测试_AccessTest * FileName: 兑吧_优惠券秒杀商品兑换测试_ScekillTest
* Author: qianwenjun * Author: qianwenjun
* Date: 2018/5/31 17:57 * Date: 2018/5/31 17:57
* Description: 开发者自有秒杀商品测试 * Description: 开发者自有秒杀商品测试
...@@ -30,7 +30,7 @@ import java.util.Map; ...@@ -30,7 +30,7 @@ import java.util.Map;
* @create 2018/5/31 * @create 2018/5/31
* @since 1.0.0 * @since 1.0.0
*/ */
public class 自有_虚拟商品秒杀商品兑换测试_AccessTest extends DuibaTestBase { public class 自有_虚拟商品秒杀商品兑换测试_ScekillTest extends DuibaTestBase {
@Autowired @Autowired
......
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